Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: third_party/android_crazy_linker/src/src/crazy_linker_elf_loader.cpp

Issue 1072533002: crazy linker: convert relocation unpacking to Android style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates to gn to match gyp. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "crazy_linker_elf_loader.h" 5 #include "crazy_linker_elf_loader.h"
6 6
7 #include <limits.h> // For PAGE_SIZE and PAGE_MASK 7 #include <limits.h> // For PAGE_SIZE and PAGE_MASK
8 8
9 #include "crazy_linker_debug.h" 9 #include "crazy_linker_debug.h"
10 #include "linker_phdr.h" 10 #include "linker_phdr.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // it overlaps an existing, possibly system, mapping. 186 // it overlaps an existing, possibly system, mapping.
187 bool ElfLoader::ReserveAddressSpace(Error* error) { 187 bool ElfLoader::ReserveAddressSpace(Error* error) {
188 ELF::Addr min_vaddr; 188 ELF::Addr min_vaddr;
189 load_size_ = 189 load_size_ =
190 phdr_table_get_load_size(phdr_table_, phdr_num_, &min_vaddr, NULL); 190 phdr_table_get_load_size(phdr_table_, phdr_num_, &min_vaddr, NULL);
191 if (load_size_ == 0) { 191 if (load_size_ == 0) {
192 error->Set("No loadable segments"); 192 error->Set("No loadable segments");
193 return false; 193 return false;
194 } 194 }
195 195
196 uint8_t* addr = reinterpret_cast<uint8_t*>(min_vaddr); 196 uint8_t* addr = NULL;
197 int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS; 197 int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS;
198 198
199 // Support loading at a fixed address. 199 // Support loading at a fixed address.
200 if (wanted_load_address_) { 200 if (wanted_load_address_) {
201 addr = static_cast<uint8_t*>(wanted_load_address_); 201 addr = static_cast<uint8_t*>(wanted_load_address_);
202 } 202 }
203 203
204 LOG("%s: address=%p size=%p\n", __FUNCTION__, addr, load_size_); 204 LOG("%s: address=%p size=%p\n", __FUNCTION__, addr, load_size_);
205 void* start = mmap(addr, load_size_, PROT_NONE, mmap_flags, -1, 0); 205 void* start = mmap(addr, load_size_, PROT_NONE, mmap_flags, -1, 0);
206 if (start == MAP_FAILED) { 206 if (start == MAP_FAILED) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 if (zeromap == MAP_FAILED) { 340 if (zeromap == MAP_FAILED) {
341 error->Format("Could not zero-fill gap: %s", strerror(errno)); 341 error->Format("Could not zero-fill gap: %s", strerror(errno));
342 return false; 342 return false;
343 } 343 }
344 } 344 }
345 } 345 }
346 return true; 346 return true;
347 } 347 }
348 348
349 } // namespace crazy 349 } // namespace crazy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698