summaryrefslogtreecommitdiffstats
path: root/linker/linker.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove unused variables not spotted by GCC.Elliott Hughes2014-02-121-10/+4
| | | | Change-Id: I49a16096bc0f41f3ad0007249161e8bdfcf3438c
* Clean up all the lint cpplint can find in the dynamic linker.Elliott Hughes2014-02-111-71/+48
| | | | Change-Id: Ic9ee7153817c22a252cc4b309283e355b623cab9
* [MIPS64] Dynamic linkerChris Dearman2014-02-111-41/+48
| | | | | | Change-Id: I937c7c776cae3d66e214798d5217a922cd106bfc Signed-off-by: Chris Dearman <chris.dearman@imgtec.com> Signed-off-by: Duane Sand <duane.sand@imgtec.com>
* Switch <elf.h> over to linux uapi under the covers.Elliott Hughes2014-02-101-224/+191
| | | | | | | | | | | | 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
* Fix <link.h>.Elliott Hughes2014-02-101-17/+17
| | | | | | | | | Also move some of the stuff that should be in <link.h> out of the private "linker.h", to make it clearer that these are public API known to gdb that we can't change. Bug: 12554197 Change-Id: I830e1260d3d8b833ed99bc1518f1c6b6102be8af
* bionic: Change the type of soinfo's size to size_tWeiwu Chen2014-01-281-1/+1
| | | | | | | | | Some system functions like munmap expect soinfo's size to be size_t, but currently it is unsigned. Change it to size_t to fit 64bit's portability. Change-Id: I0bf6d522b38b0cd9bf1db05b004b5326217412a2 Signed-off-by: Weiwu Chen <weiwu.chen@intel.com> Signed-off-by: Qiming Shi <qiming.shi@intel.com>
* Make it possible for code to query the dynamic linker's default search path.Elliott Hughes2014-01-131-9/+12
| | | | | | | | | We're not going to have init(1) set LD_LIBRARY_PATH globally on 64-bit. This patch makes it possible for libnativehelper to set LD_LIBRARY_PATH in each Java VM (to support System.loadLibrary) without also hard-coding the default search path there. Change-Id: If13961fae976e06dd80d5ef522f31e8b7eb01154
* Improve dynamic linker diagnostics for internal errors.Elliott Hughes2013-12-221-5/+8
| | | | | | If the linker can't resolve its own internal references to symbols, we currently exit silently (albeit with EXIT_FAILURE). Not very helpful. Change-Id: I1614fc970dee4560b38832ede1987b65a8e53a1e
* AArch64: Linker64 support for AArch64Marcus Oakland2013-12-171-4/+219
| | | | | | | Addition of support for AArch64 in the linker64 target. Change-Id: I8dfd9711278f6706063e91f626b6007ea7a3dd6e Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
* Fix debugging issues in vdso handlingPavel Chupin2013-12-121-1/+3
| | | | | | | | | | | Under valgrind ehdr_vdso is null and causing segfault. Adding debug info for vdso producing plenty of issues on debugging through gdbserver, removing it. It doesn't seem it should be here. Unwinding through vdso test still works. Change-Id: I1a7e233c493f2268d725fa8d7279822d07decc49 Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
* Fix linker crashes during unknown symbol lookupSergey Melnikov2013-10-311-8/+10
| | | | | | | | | | | | Integration of kernel VDSO into internal bionic data structures using common functions. Fix for dl_iterate_phdr function: the function provides incorrect address of object in case of nonzero virtual and base addresses. Location in address space of a particular program header should be calculated using the formula: addr = base_addr + virtual_addr. Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com> Change-Id: Ie2ab4257fd456242aab8afed0bd5bd6b29e81d6d
* Don't allow text relocations on 64-bit.Elliott Hughes2013-10-281-10/+17
| | | | | | I've also updated our <sys/exec_elf.h> to match upstream. Change-Id: I52f9fce3167541811208d273ff23ceaa112f7135
* Clean up linker architecture macros.Elliott Hughes2013-10-281-118/+97
| | | | | | | | | | | | | | | | 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
* Revert "Don't warn about x86 text relocations. They're too prevalent."Elliott Hughes2013-10-241-2/+0
| | | | | | This reverts commit 5be2c5998c996ff9d5efb94c127d9b832a295822. Change-Id: I3fc8ca530cdbd74c834fb9cfabe812c9386419fc
* Don't warn about x86 text relocations. They're too prevalent.Elliott Hughes2013-10-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | We should fix this (and disallow it for x86_64), but for now let's get CTS running again. libdvm.so and libcutils.so are the main problems. $ scanelf -qT out/target/product/generic_x86/symbols/system/lib/libcutils.so libcutils.so: (memory/data?) [0x4125] in (optimized out: previous android_memset16) [0x4100] libcutils.so: (memory/data?) [0x424F] in (optimized out: previous android_memset16) [0x4100] libcutils.so: (memory/data?) [0x42F8] in (optimized out: previous android_memset16) [0x4100] libcutils.so: (memory/data?) [0x4349] in (optimized out: previous android_memset16) [0x4100] libcutils.so: (memory/data?) [0x4406] in (optimized out: previous android_memset16) [0x4100] libcutils.so: (memory/data?) [0x45AC] in (optimized out: previous android_memset32) [0x4590] libcutils.so: (memory/data?) [0x4650] in (optimized out: previous android_memset32) [0x4590] libcutils.so: (memory/data?) [0x46F9] in (optimized out: previous android_memset32) [0x4590] libcutils.so: (memory/data?) [0x474A] in (optimized out: previous android_memset32) [0x4590] libcutils.so: (memory/data?) [0x4807] in (optimized out: previous android_memset32) [0x4590] Bug: 11353056 Change-Id: Id4a76b310be7fe858a8a60d0d260b09913b66be9
* change wording on text relocation message.Nick Kralevich2013-10-221-2/+2
| | | | | | The current message is too alarmist. Change-Id: I53e8eadca239f867b4e6b9c193eba96e267950c3
* x86_64: Add R_X86_64_64 relocation handlingPavel Chupin2013-10-161-0/+8
| | | | | Change-Id: I86ffc56fa6a9053bed44e92a579530c2beb8eb2c Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
* x86_64: Rename 64-bit linker to linker64Pavel Chupin2013-10-091-0/+4
| | | | | | | That's for having both on the same system. Change-Id: Ic2bc2c015e6486e8b6a7576f7b28d2d027534368 Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
* Fix x86_64 build, clean up intermediate libraries.Elliott Hughes2013-10-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | The x86_64 build was failing because clone.S had a call to __thread_entry which was being added to a different intermediate .a on the way to making libc.so, and the linker couldn't guarantee statically that such a relocation would be possible. ld: error: out/target/product/generic_x86_64/obj/STATIC_LIBRARIES/libc_common_intermediates/libc_common.a(clone.o): requires dynamic R_X86_64_PC32 reloc against '__thread_entry' which may overflow at runtime; recompile with -fPIC This patch addresses that by ensuring that the caller and callee end up in the same intermediate .a. While I'm here, I've tried to clean up some of the mess that led to this situation too. In particular, this removes libc/private/ from the default include path (except for the DNS code), and splits out the DNS code into its own library (since it's a weird special case of upstream NetBSD code that's diverged so heavily it's unlikely ever to get back in sync). There's more cleanup of the DNS situation possible, but this is definitely a step in the right direction, and it's more than enough to get x86_64 building cleanly. Change-Id: I00425a7245b7a2573df16cc38798187d0729e7c4
* Use /system/lib64 and /vendor/lib64 for 64-bit libraries.Elliott Hughes2013-10-081-0/+5
| | | | Change-Id: I4886aeb3070bf97b4cfe8053388ecb1bda288017
* x86_64 linker.Elliott Hughes2013-10-081-37/+199
| | | | | | | 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-78/+77
| | | | Change-Id: I2c1f3d34c33685799aade8866eec44479ff9f963
* Add the dl_iterate_phdr function to libdl for arm.Christopher Ferris2013-09-061-3/+1
| | | | | | | | | | Bug: 8410085 Merge from internal master. (cherry-picked from cb491bc66dc0abc145930b09086eb9189a30f6c2) Change-Id: I94ed51bc5d4c626df7552c0e85c31ccee2d6568f
* Make mips_relocate_got tolerate a missing gotBrian Carlstrom2013-08-211-17/+15
| | | | | | | | Bug: 10094803 (cherry picked from commit 7ee26878065abb494600595349ce58b2b2db3709) Change-Id: Ib15bccecaee421dc463d46a3956b054051708759
* Kernel dso support for 'dl_iterate_phdr' functionSergey Melnikov2013-06-251-0/+24
| | | | | | | | | | Kernel provides virtual DSO for stack unwinding/exception handlind info for signal usage case. Stack unwinding routines use 'dl_iterate_phdr' function for additional DWARF info gathering from DSOs. Patch enables virtual DSO enumeration via dl_iterate_phdr function. Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com> Change-Id: Ic2882b28f40b456a088bc1e63c50cbfda7e4a102
* linker: Emit a warning on text relocationsNick Kralevich2013-06-211-0/+2
| | | | | | | | | | | Text relocations unnecessarily mark pages as dirty, preventing them from being swapped out, wasting memory. Also, text relocations prevent the code from running on certain hardened systems. Print a message in logcat and stderr when we see a text relocation, to encourage developers to fix their code. Change-Id: I6051a7463911e090ae5727a355397d539669d5b9
* Make LD_PRELOAD failures just warnings.Elliott Hughes2013-06-181-7/+8
| | | | | | | | This matches glibc and makes life easier for developers who want to sometimes preload a library from init (which has no conditionals); they can simply move/remove the library to disable. Change-Id: I579b8633f958235af6e46bb53b378b9e363afb1f
* Small cleanup of soinfo_elf_lookup.Christopher Ferris2013-06-031-5/+2
| | | | | | | - Remove unnecessary line. - Move declarations to first use. Change-Id: I1d8398d6c13f7cb86bffe0b68af849e35a4b234d
* Don't fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library ↵Elliott Hughes2013-05-091-38/+24
| | | | | | | | | | | | | has DT_PREINIT_ARRAY constructors. The GNU dynamic linker silently ignores a DT_PREINIT_ARRAY section in a shared library. We had ineffectual code that tried to report an error, which I tried to fix but got wrong --- my version still wouldn't report the error to the caller, but would prevent us from continuing to call constructors. Bug: 8825226 Change-Id: I4fd8450ecc44d8767a1cb808aeecfbfbfc77c070
* linker: only re-open std* for setuid programs.Nick Kralevich2013-04-251-5/+6
| | | | | | | | | | | | | | | | | | | get_AT_SECURE() was getting called before linker_env_init() had been called, and returning the default value ("true"). This was causing us to reopen closed stdin, stdout, and stderr for ALL processes, not just privileged (setuid) processes. Calling path: - __linker_init - soinfo_link_image - get_AT_SECURE - __linker_init_post_relocation - linker_env_init This change restores the intended behavior of only re-opening stdin, stdout, and stderr for privileged processes. Change-Id: I8b085ea6597710ac4c1a3c93f1bf8b81eecb08c0
* Make abort messages available to debuggerd.Elliott Hughes2013-04-051-4/+6
| | | | | | | | | | | | | This adds __libc_fatal, cleans up the internal logging code a bit more, and switches suitable callers over to __libc_fatal. In addition to logging, __libc_fatal stashes the message somewhere that the debuggerd signal handler can find it before calling abort. In the debuggerd signal handler, we pass this address to debuggerd so that it can come back with ptrace to read the message and present it to the user. Bug: 8531731 Change-Id: I416ec1da38a8a1b0d0a582ccd7c8aaa681ed4a29
* Drop unnecessary execution permission for .cpp/.c/.hKito Cheng2013-03-221-0/+0
| | | | Change-Id: I9ac2b9d8f6bdb4fab8962210c5ec8f9c3e8c0ebf
* Clean up internal libc logging.Elliott Hughes2013-03-151-7/+6
| | | | | | | | | | | We only need one logging API, and I prefer the one that does no allocation and is thus safe to use in any context. Also use O_CLOEXEC when opening the /dev/log files. Move everything logging-related into one header file. Change-Id: Ic1e3ea8e9b910dc29df351bff6c0aa4db26fbb58
* Use more types than just 'unsigned' in the linker.Elliott Hughes2013-03-121-86/+82
| | | | | | | | | | | | | Still chipping away at the situation where every variable in the linker was of type 'unsigned'. This patch switches counts over to being size_t and adds an explicit type for init/fini function pointers and arrays of function pointers. Also improve logging from CallArray. Also remove trailing "\n"s from log messages. Change-Id: Ie036d2622caac50f4d29f0570888bb527661d77e
* Use Elf32_Addr instead of unsigned in linkerKito Cheng2013-03-121-51/+47
| | | | Change-Id: I52dcbb4b0ff0a4052e0ad7a9bbeb2df65c9d2f66
* Fix typo of DT_NEEDED for DT_NULLBrian Carlstrom2013-03-061-1/+1
| | | | | | (cherry-pick of 138b205ea9efc117fe522c2d7191378023a6e2cd) Change-Id: Ia895cb3018df55554627f1f61dcdfdada4a961ce
* Fix TIMING/STATS/COUNT_PAGES dynamic linker buildKito Cheng2013-03-061-3/+3
| | | | Change-Id: I6432ac378816da253b83d1c7fb1d3fb64647b89e
* Fix MIPS linker buildBrian Carlstrom2013-03-061-1/+1
| | | | | | (cherry-picked from 8c7d8c2057e303985f78eab96da747ddaa013c78) Change-Id: Idcf62ab95f8fccbc2d7c3e771a4cfbe768a1555e
* More linker cleanup.Elliott Hughes2013-03-051-195/+27
| | | | Change-Id: I9fb3c7c0d4b4ffef0eeaf092d4e30ffe63a08671
* Minor linker cleanup, primarily to use Elf32_DynBrian Carlstrom2013-03-051-157/+169
| | | | Change-Id: Ifa9408e9859c6f79444715bed4808b7c13fdced5
* Switch to using AT_RANDOM for the stack guards.Elliott Hughes2013-02-081-1/+1
| | | | | Bug: 7959813 Change-Id: I8db4b8912ba649bfe668c6f22aa44690ddd401a2
* Clean up the argc/argv/envp/auxv handling.Elliott Hughes2013-02-071-99/+58
| | | | | | | | There's now only one place where we deal with this stuff, it only needs to be parsed once by the dynamic linker (rather than by each recipient), and it's now easier for us to get hold of auxv data early on. Change-Id: I6314224257c736547aac2e2a650e66f2ea53bef5
* Remove partial implementation of MIPS non-PIC support.Elliott Hughes2013-02-061-14/+0
| | | | Change-Id: I3c287e52aae10559508174e73113367aea40e5c2
* Fix the duplication in the debugging code.Elliott Hughes2013-01-181-3/+3
| | | | | | | | | | | | | | | | | | | We had two copies of the backtrace code, and two copies of the libcorkscrew /proc/pid/maps code. This patch gets us down to one. We also had hacks so we could log in the malloc debugging code. This patch pulls the non-allocating "printf" code out of the dynamic linker so everyone can share. This patch also makes the leak diagnostics easier to read, and makes it possible to paste them directly into the 'stack' tool (by using relative PCs). This patch also fixes the stdio standard stream leak that was causing a leak warning every time tf_daemon ran. Bug: 7291287 Change-Id: I66e4083ac2c5606c8d2737cb45c8ac8a32c7cfe8
* Revert "stack protector: use AT_RANDOM"Nick Kralevich2013-01-161-4/+4
| | | | | | | | | | | | | | | | | | The AT_RANDOM changes broke setuid / setgid executables such as "ping". When the linker executes a setuid program, it cleans the environment, removing any invalid environment entries, and adding "NULL"s to the end of the environment array for each removed variable. Later on, we try to determine the location of the aux environment variable, and get tripped up by these extra NULLs. Reverting this patch will get setuid executables working again, but getauxval() is still broken for setuid programs because of this bug. This reverts commit e3a49a8661125f24aec8a1453e54b3b78005e21e. Change-Id: I05c58a896b1fe32cfb5d95d43b096045cda0aa4a
* stack protector: use AT_RANDOMNick Kralevich2013-01-161-4/+4
| | | | | | | | | | | Populate the stack canaries from the kernel supplied AT_RANDOM value, which doesn't involve any system calls. This is slightly faster (6 fewer syscalls) and avoids unnecessarily reading /dev/urandom, which depletes entropy. Bug: 7959813 Change-Id: If2b43100a2a9929666df3de56b6139fed969e0f1
* Fix my git mistake.Elliott Hughes2013-01-141-1/+2
| | | | | | | This was the formatting change that was supposed to be in cf23905a4bcc7bfdd109be5b6d69ad06877aa217. Change-Id: Ib79fa031b68f6f541f532507eb589afeaedb831f
* [MIPS] Set DT_DEBUG dyntab entry if it is writableChris Dearman2013-01-141-5/+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>
* Fix debug malloc.Elliott Hughes2013-01-031-6/+6
| | | | | | | ...which has been broken since the linker data structures went read-only. Bug: 7941716 Change-Id: If28f6bac0fcb13e371e4d85b064544f561c8d692
* Support System.loadLibrary for libraries with transitive dependencies.Elliott Hughes2012-12-201-83/+73
| | | | | | | | | Also fix the FLAG_ERROR annoyance --- it's not helpful to cache failures. Bug: 7896159 Bug: http://code.google.com/p/android/issues/detail?id=34416 Bug: http://code.google.com/p/android/issues/detail?id=22143 Change-Id: I60f235edb4ea4756e1f7ce56f7739f18e8a50789