aboutsummaryrefslogtreecommitdiffstats
path: root/linker/linker_phdr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix crash when trying to load invalid ELF file.Dmitriy Ivanov2015-06-251-2/+16
| | | | | | Bug: http://b/22047255 Bug: http://b/22091640 Change-Id: I6c51cff43287a6ac4b25fa9ce6a6fc3d232fd047
* Add flag that makes linker honor min(p_vaddr)Dmitriy Ivanov2015-06-181-1/+7
| | | | | | | | (cherry picked from commit 8a1162835597be38705b381ac34c07da17932568) Bug: 21924613 Bug: http://b/21523078 Change-Id: I3f944a08dd2ed1df4d8a807da4fee423fdd35eb7
* linker: never mark pages simultaneously writable / executableNick Kralevich2015-04-011-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the Android dynamic linker handles a text relocation, it first relaxes the permissions on the segment being modified, performs the modifications, and then restores the page permissions. The relaxation worked by adding PROT_WRITE to whatever protection bits were set in the section. In effect, the pages were getting set to PROT_READ|PROT_WRITE|PROT_EXEC, modified, then restored to PROT_READ|PROT_EXEC The SELinux kernel code differentiates between 4 different kinds of executable memory: * Executable stack (execstack) * Executable heap (execheap) * File-based executable code which has been modified (execmod) * All other executable memory (execmem) The execmod capability is only triggered by the kernel when a dirty but non-executable mmap()ed page becomes executable. When that occurs, an SELinux policy check is done to see if the execmod capability is provided by policy. However, if the page is already executable, and PROT_WRITE is added to the page, it's considered an execmem permission check, not an execmod permission check. There are certain circumstances where we may want to distinguish between execmod and execmem. This change adjusts the dynamic linker to avoid using RWX pages, so that an RX -> RW -> RX transition will properly be detected as an execmod permission check instead of an execmem permission check. Bug: 20013628 Change-Id: I14d7be29170b156942f9809023f3b2fc1f37846c
* Revert "Remove text-relocation support for lp32"Dimitry Ivanov2015-04-011-0/+64
| | | | | | | | This reverts commit cb00add1b382d1e3045876d7e1ccbee2fdce976b. Bug: 20020312 Bug: 20013628 Change-Id: I8baa3d4b6c7fef50c9e2531257d5b96762099eb3
* Remove text-relocation support for lp32Dmitriy Ivanov2015-03-311-64/+0
| | | | | Bug: 20013628 Change-Id: Idaf8012f00ee1304d429c3b42f9ebc6b648c55b8
* Fix long lines and replace macros with functions.Dmitriy Ivanov2015-03-311-10/+19
| | | | Change-Id: I4e1cab488d5b2c8e4289da617350a86e72a4ba12
* Add support for packed relocations.Dmitriy Ivanov2015-03-061-1/+1
| | | | Change-Id: I796a4ce86d3fccb8361c19889419c96147ee3c9f
* Add missing includes.Elliott Hughes2015-01-281-0/+1
| | | | Change-Id: Ibf549266a19a67eb9158d341a69dddfb654be669
* Enable -Wold-style-cast warnings for linkerDmitriy Ivanov2015-01-221-3/+3
| | | | | | And fix old style casts. Change-Id: I37e7a3e3fd852528ea76f02d967c7bd8cd5b06c9
* Kill <machine/exec.h>.Elliott Hughes2014-12-021-2/+15
| | | | | Bug: 18546535 Change-Id: I479e003deab21e31eb5caa5393067ed1dc558387
* Rename library_offset to library_fd_offsetDmitriy Ivanov2014-10-211-8/+2
| | | | | | | | replace lseek() and use pread() instead add test for library_fd_offset > file_size case Bug: 17762003 Change-Id: I4555f0be635124efe849c1f226985bcba72ffcbd
* Fix misleading comment.Robert Grosse2014-10-151-3/+3
| | | | Change-Id: I9e2aa6c2ba938c8f8d7c74eba32d313c866c77b2
* Add file_offset parameter to android_extinfoDmitriy Ivanov2014-10-061-5/+12
| | | | | Bug: 17762003 Change-Id: I8fb267a3155acef3dba534038cf5d1ef00d7154b
* Fix gdb could not get shared library list issueNingsheng Jian2014-09-261-1/+6
| | | | | | | | | | Get dynamic flags from phdr table's correct entry rather the first entry, so that the following DT_DEBUG entry can be set. Also fix the undefined reference to LoadTask::deleter issue under gcc -O0 option. Bug: 17524778 Change-Id: I9c679af197b034761fb739d6c980e628ff2ab84c
* Load libraries in breadth-first orderDmitriy Ivanov2014-09-081-23/+6
| | | | | | | | | | This patch fixes the problem with symbol search order for dlsym(RTLD_DEFAULT/RTLD_NEXT, .) by loading libraries and ld_preloads in correct order. Bug: https://code.google.com/p/android/issues/detail?id=74255 Change-Id: If1ba5c807322409faa914e27ecb675e2c4541f0d Attempt: 2
* Revert "Load libraries in breadth-first order"Dmitriy Ivanov2014-09-051-6/+23
| | | | | | This reverts commit a3ad450a2e3fb6b3fe359683b247eba20896f646. Change-Id: Ia2b838ad2159c643b80c514849582f4b4f4f40e5
* Load libraries in breadth-first orderDmitriy Ivanov2014-09-031-23/+6
| | | | | | | | | This patch fixes the problem with symbol search order for dlsym(RTLD_DEFAULT/RTLD_NEXT, .) by loading libraries and ld_preloads in correct order. Bug: https://code.google.com/p/android/issues/detail?id=74255 Change-Id: I4cf84c70dbaabe99310230dfda12385ae5401859
* Replace NULL with nullptrDmitriy Ivanov2014-08-291-16/+16
| | | | Change-Id: Iad50be617d318ca98883b843229c960ad5b9afa9
* Use VDSO for clock_gettime(2) and gettimeofday(2).Elliott Hughes2014-07-161-4/+1
| | | | | Bug: 15387103 Change-Id: Ifc3608ea65060c1dc38120b10b6e79874f182a36
* Load library using file handle.Dmitriy Ivanov2014-07-021-3/+0
| | | | | | | | * This patch enables dlopen by file descriptor instead of path/name. Bug: 15984217 Change-Id: Ib39051e00567fb97070bf96d8ce63993877c0a01
* Handle empty relro segment or incorrectly sized file.Torne (Richard Coles)2014-05-021-3/+13
| | | | | | | | | | | | | | | | If the file has no relro segment, the generated relro file will have length 0, which caused mmap to fail. If the relro file has nonzero size, but is too short (e.g. because it's for the wrong version of the library), the linker would segfault while comparing the data. Fix both these issues: don't try to map a zero length file, and don't try to compare data that would be beyond the end of the file. Improve test to explicitly generate two versions of the library: one with -z relro, and one with -z norelro, so we can test both cases; also explicitly test the case where the relro file has length 0. Bug: 14299541 Change-Id: Id8b95585edda90e8bb5de452a35b70ed2d224934
* Allow sharing the RELRO section via a file.Torne (Richard Coles)2014-04-171-0/+126
| | | | | | | | | | | | Add flags and a file descriptor to android_dlopen_ext() to allow writing the RELRO section of the loaded library to a file after relocation processing, and to allow mapping identical pages from the file over the top of relocated memory in another process. Explicitly comparing the pages is required in case a page contains a reference to a symbol defined in another library loaded at a random base address. Bug: 13005501 Change-Id: Ibb5b2d384edfaa5acf3e97a5f8b6115c10497a1e
* Support loading libraries to a reserved address.Torne (Richard Coles)2014-04-171-8/+30
| | | | | | | | | | | | | | | Add flags and parameters to android_dlopen_ext() to allow loading a library at an already-reserved fixed address. If the library to be loaded will not fit within the space reserved, then the linker will either fail, or allocate its own address space as usual, according to which flag has been specified. This behaviour only applies to the specific library requested; any other libraries loaded as dependencies will be loaded in the normal fashion. There is a new gtest included to cover the functionality added. Bug: 13005501 Change-Id: I5d1810375b20fc51ba6a9b3191a25f9792c687f1
* Clean up all the lint cpplint can find in the dynamic linker.Elliott Hughes2014-02-111-7/+7
| | | | Change-Id: Ic9ee7153817c22a252cc4b309283e355b623cab9
* Switch <elf.h> over to linux uapi under the covers.Elliott Hughes2014-02-101-162/+164
| | | | | | | | | | | | Remove the linker's reliance on BSD cruft and use the glibc-style ElfW macro. (Other code too, but the linker contains the majority of the code that needs to work for Elf32 and Elf64.) All platforms need dl_iterate_phdr_static, so it doesn't make sense to have that part of the per-architecture configuration. Bug: 12476126 Change-Id: I1d7f918f1303a392794a6cd8b3512ff56bd6e487
* bionic: Do not use magic number for portabilityQiming Shi2014-01-271-3/+3
| | | | | | | | | Do not use the magic number 0xFFFFFFFFU to represent the max value of an address as it's not correct on 64bit platform. We should use UINTPTR_MAX instead. Change-Id: I1fc6f5864a651b2eddea2333cb0788f9d9223270 Signed-off-by: Qiming Shi <qiming.shi@intel.com> Signed-off-by: Weiwu Chen <weiwu.chen@intel.com>
* AArch64: Linker64 support for AArch64Marcus Oakland2013-12-171-11/+2
| | | | | | | Addition of support for AArch64 in the linker64 target. Change-Id: I8dfd9711278f6706063e91f626b6007ea7a3dd6e Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
* Clean up linker architecture macros.Elliott Hughes2013-10-281-11/+7
| | | | | | | | | | | | | | | | We don't need our own architecture macros; the standard ones will do. This patch also fixes some __x86_64__ tests to be USE_RELA tests instead, because they're not actually x86_64-specific. I've cleaned up architecture-specific code slightly so where possible all the code corresponding to a particular architecture is together. This patch also fixes a bug in LP64 DT_PLTGOT handling, which should be an error rather than falling through into DT_DEBUG! There was another #ifdef bug where we'd only report unexpected DT_ entries on MIPS. Change-Id: Id1d04e372611f641c1aa278a18e379f28af9eaf5
* x86_64 linker.Elliott Hughes2013-10-081-4/+25
| | | | | | | Based on I8dc3e2cb596f75dc58ae82e4dc58f8c177dd3323 by Pavel Chupin <pavel.v.chupin@intel.com>. Change-Id: Icd582d277cbe273477b450f2848343d72c86ec9f
* Remove 32-bit assumptions from the ELF code.Elliott Hughes2013-09-301-107/+71
| | | | Change-Id: I2c1f3d34c33685799aade8866eec44479ff9f963
* Add more information to error due to truncated Elf32_EhdrBrian Carlstrom2013-08-141-1/+2
| | | | Change-Id: I24f30bd0c1120bcf85d77f5c4e69f0fefe9a2478
* Honor p_vaddr if setBrian Carlstrom2013-06-071-20/+27
| | | | | | (cherry picked from commit 88ff15c2c279d2bbe3569101b36cd2aa0931a0a9) Change-Id: I4aabbe911d30aea8ace69e29bb6e980a4e89de90
* Fix bionic linker to support segments with zero p_fileszBrian Carlstrom2013-05-211-10/+13
| | | | | | (cherry picked from commit 96362fb9d11beef6233aa03db396f25688e70860) Change-Id: Ib075a6dfc45d5d0746d8b278f317dd9b8d772f2a
* More linker cleanup.Elliott Hughes2013-03-051-231/+233
| | | | Change-Id: I9fb3c7c0d4b4ffef0eeaf092d4e30ffe63a08671
* Minor linker cleanup, primarily to use Elf32_DynBrian Carlstrom2013-03-051-2/+2
| | | | Change-Id: Ifa9408e9859c6f79444715bed4808b7c13fdced5
* [MIPS] Set DT_DEBUG dyntab entry if it is writableChris Dearman2013-01-141-1/+6
| | | | | | | | This is primarily for MIPS exutables that do not have a DT_MIPS_RLD_MAP entry. Change-Id: I4c221d92debcfed961eeee2515123f3fb21ec8e6 Signed-off-by: Chris Dearman <chris@mips.com>
* More dynamic linker cleanup.Elliott Hughes2012-10-301-0/+643
I still want to break linker_format out into its own library so we can reuse it for malloc debugging and so forth. (There are many similar pieces of code in bionic, but the linker's one seems to be the most complete/functional.) Change-Id: If3721853d28937c8e821ca1d23cf200e228a409a