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

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: Created 5 years, 8 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // it overlaps an existing, possibly system, mapping. 188 // it overlaps an existing, possibly system, mapping.
189 bool ElfLoader::ReserveAddressSpace(Error* error) { 189 bool ElfLoader::ReserveAddressSpace(Error* error) {
190 ELF::Addr min_vaddr; 190 ELF::Addr min_vaddr;
191 load_size_ = 191 load_size_ =
192 phdr_table_get_load_size(phdr_table_, phdr_num_, &min_vaddr, NULL); 192 phdr_table_get_load_size(phdr_table_, phdr_num_, &min_vaddr, NULL);
193 if (load_size_ == 0) { 193 if (load_size_ == 0) {
194 error->Set("No loadable segments"); 194 error->Set("No loadable segments");
195 return false; 195 return false;
196 } 196 }
197 197
198 uint8_t* addr = reinterpret_cast<uint8_t*>(min_vaddr); 198 uint8_t* addr = NULL;
199 int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS; 199 int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS;
200 200
201 // Support loading at a fixed address. 201 // Support loading at a fixed address.
202 if (wanted_load_address_) { 202 if (wanted_load_address_) {
203 addr = static_cast<uint8_t*>(wanted_load_address_); 203 addr = static_cast<uint8_t*>(wanted_load_address_);
204 } 204 }
205 205
206 LOG("%s: address=%p size=%p\n", __FUNCTION__, addr, load_size_); 206 LOG("%s: address=%p size=%p\n", __FUNCTION__, addr, load_size_);
207 void* start = mmap(addr, load_size_, PROT_NONE, mmap_flags, -1, 0); 207 void* start = mmap(addr, load_size_, PROT_NONE, mmap_flags, -1, 0);
208 if (start == MAP_FAILED) { 208 if (start == MAP_FAILED) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 if (zeromap == MAP_FAILED) { 395 if (zeromap == MAP_FAILED) {
396 error->Format("Could not zero-fill gap: %s", strerror(errno)); 396 error->Format("Could not zero-fill gap: %s", strerror(errno));
397 return false; 397 return false;
398 } 398 }
399 } 399 }
400 } 400 }
401 return true; 401 return true;
402 } 402 }
403 403
404 } // namespace crazy 404 } // namespace crazy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698