summaryrefslogtreecommitdiff
path: root/linker/linker.cpp
AgeCommit message (Collapse)Author
2014-08-21Run constructors before resolving ifunc functionsDmitriy Ivanov
Bug: 17177284 Change-Id: I5714b9bc2d1ca8f8711806bfb68da3d524213e99
2014-08-19Revert "Add support for protected local symbol lookup."Dmitriy Ivanov
This reverts commit d97e9f546ea195686a78e539315b273393609b9e. Bug: 17107521 (cherry picked from commit 9419420919ea846bbad5510850c7aaec95021648) Change-Id: I1a6df946ac8075699e77d68ffa6ac4a21b88e4bf
2014-08-12Merge "Added test for ifunc support in dynamic linker."Dmitriy Ivanov
2014-08-13Optimize symbol lookupDmitriy Ivanov
Do not run symbol lookup on already visited soinfos Not taking into account already visited libraries dramatically slows down dlsym in cases when there are multiple occurrences of a large library in dependency tree. Bug: 16977077 Change-Id: I1379f30ed8b06758dd1cc76b80833ac8589afa50
2014-08-08Added test for ifunc support in dynamic linker.Brigid Smith
ifuncs now work in i386 and x86_64 when called in the same library as well as in a different library. Bug:6657325 Change-Id: Ic0c48b1b0a76cb90f36c20c79f68294cc3fd44a1
2014-07-29Fix dlsym(3) to do breadth first search.Dmitriy Ivanov
dlsym(3) with handle != RTLD_DEFAULT|RTLD_NEXT performs breadth first search through the dependency tree. Bug: 16653281 Change-Id: I017a6975d1a62abb0218a7eb59ae4deba458e324
2014-07-28Fix 'adb shell /system/bin/linker' crashDmitriy Ivanov
Bug: https://code.google.com/p/android/issues/detail?id=63174 Change-Id: I072290ea11109c07f277ad3dec7f44fcb7bf6aa6
2014-07-24Fix global variable initialization for linkerDmitriy Ivanov
Linker now calls init functions for itself. Change-Id: Ibd099812493041ac70f591e3f379ee742b4683b8
2014-07-08Change android_dlextinfo flags to uint64_tDmitriy Ivanov
Change-Id: Id27e8f8e58dbcf6ae79644f2ad3af3dd0aef9ae7
2014-07-03Revert "Reenable support for non-PIE executables"Nick Kralevich
/system/bin/tf_daemon on Nakasi has been updated so it's a PIE executable. We can now drop non-PIE support. This reverts commit d81b3b275dff99561cbe5905ca63a1c72fa54a17. Bug: 15086752 Bug: 15732002 Bug: 14566672 Change-Id: I832c4de01a8fa050754ea64da317d1639990265e
2014-07-02Build fixDmitriy Ivanov
Change-Id: Ib43e0f055e3c5f07b50393bfcab9738454835ac3
2014-07-02Load library using file handle.Dmitriy Ivanov
* This patch enables dlopen by file descriptor instead of path/name. Bug: 15984217 Change-Id: Ib39051e00567fb97070bf96d8ce63993877c0a01
2014-07-01Write message to stderr on __libc_fatal()Dmitriy Ivanov
Change-Id: Ia8d6e256768fa51786d0139d3f3b6e9e4bebe027
2014-07-01Add support for protected local symbol lookup.Dmitriy Ivanov
Bug: http://code.google.com/p/android/issues/detail?id=66048 Change-Id: Ib334223df27adad9477fb241ab099c5e26df4a7d
2014-06-30Reinstate the x86 dynamic linker warning for text relocations.Elliott Hughes
Bug: 11358761 Change-Id: I4fc56ce7d76c9703a307ddd4d371d5e98bc6f51d
2014-06-29Disallow dlopen("egl/blah.so") on LP64Dmitriy Ivanov
Bug: 7465467 Change-Id: Ibd3a4f1a6095f4397bde4f656e3c11b67f7edd47
2014-06-19Reenable support for non-PIE executablesNick Kralevich
On Nakasi builds, /system/bin/tf_daemon is a pre-compiled vendor supplied binary. When support for non-PIE executables was removed, that daemon failed to start, which induced a number of bugs. * keystore is broken * CTS runs will hang after a certain period of time Temporarily reenable non-PIE support for 32-bit platforms until Nakasi is fixed. This rolls back the following commits: Cleanup: updated comments * 6275f2083415d22a6ce0de55645079cd47e0cc80 Cleanup: remove AARCH/ARM_COPY relocation support * b906e13c55c9fe9b4157ba548534a0230434882b And restricts the following patch to 64 bit only: Remove support for non-PIE executables * 2aebf5429bb1241a3298b5b642d38f73124c2026 Bug: 14566672 Bug: 15086752 Bug: 15732002 Change-Id: Ia2501aa14bd30feb4a6ce66bdb7c9f066dba0b5f
2014-06-03Remove an unused parameter from the dlopen implementation.Elliott Hughes
Change-Id: I9297913a743bb570b48ebbe594ff711a481e89e0
2014-06-03Turn on -Wunused and fix the mistakes it uncovers.Elliott Hughes
Change-Id: I023d2d8b547fbc21d4124bb7510d42b06a0dc501
2014-05-23Merge "Do not add arcs to the soinfo graph on dlopen"Dmitriy Ivanov
2014-05-22Do not add arcs to the soinfo graph on dlopenBjorn Andersson
While introducing RTLD_NOLOAD in b648a8a5 a change in how soinfo structs are connected was also introduced. When calling dlopen the library that is loaded is added as a child to the soinfo from which the caller comes - i.e. building a dependency graph. Unfortunately this shows issues upon unloading, such as blowing the stack if there are loops in the graph. This change reverts that part of b648a8a5, keeping everything as a child of the root soinfo. Change-Id: I604ee9210613b19f693a568158e69707620a95db Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
2014-05-22Remove unnecessary #includes of <sys/atomics.h>.Elliott Hughes
Bug: 14903517 Change-Id: I7b5bcebe58774a441da986cc02376dd88e00ea0e
2014-05-20Merge "Add R_X86_64_64 to the list of possible weak relocs"Dmitriy Ivanov
2014-05-20Add RTLD_NOLOAD support and some related changes.Dmitriy Ivanov
* Aligned RTLD_ values with glibc for lp64 * dlopen supports RTLD_NOLOAD flag * soinfo_unload calls find_library(.., RTLD_NOLOAD) instead of naive find_loaded_library_by_name() * dlopen changed to add child to caller soinfo instead of somain. Bug: https://code.google.com/p/android/issues/detail?id=64069 Change-Id: I1a65f2c34f3e0edc6d2c41a2e408b58195feb640
2014-05-20Add R_X86_64_64 to the list of possible weak relocsPavel Chupin
Change-Id: I768a5948d89701a1719734954a3524d3c7187e6a Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2014-05-19Fix lookup-by-base-name for lp64Dmitriy Ivanov
Bug:https://code.google.com/p/android/issues/detail?id=6670 Change-Id: I5b70e7cde7f40799148aca0a91fb2bb08e0f2b54
2014-05-14Improve detection of already loaded librariesDmitriy Ivanov
Linker is now able to resolve symlinked libraries correctly. soinfo is extended to save the graph of dependencies during load/unload. Dependencies are used only in CallConstructor. Bug: 9741592 Change-Id: Id9c48a74c46aa89bcdf3d54ec2f8ba3d398130b1
2014-05-14Switch to g_ for globals.Elliott Hughes
That's what the Google style guide recommends, and we're starting to get a mix. Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
2014-05-13Merge "Refactor linker allocator"Dmitriy Ivanov
2014-05-12Refactor linker allocatorDmitriy Ivanov
Makes it reusable for different fixed sized and not very big structures (<PAGE_SIZE). Change-Id: Id5ec13fc6541b1935ef7fe3671c22b98685abbae
2014-05-12Cleanup: updated commentsDmitriy Ivanov
Bug: 14566672 Change-Id: I49ad28e3914b7d559db1e98542fee919db768f49
2014-05-12Cleanup: remove AARCH/ARM_COPY relocation supportDmitriy Ivanov
They are only legal for ET_EXEC binaries and these are no longer supported. Bug: 14566672 Change-Id: I99e0ff47e8c572db474bc5e52df870a72269abb3
2014-05-08Remove support for non-PIE executablesNick Kralevich
Don't support the dynamic linker loading ET_EXEC executables. Only support ET_DYN executables. Bug: 14566672 Change-Id: Ia1f2bfffe7ea867c1cd62e67d7fd637c60c0728d
2014-05-02Disallow dlopen("egl/blah.so") on LP64Dmitriy Ivanov
Change-Id: I9a563a9dada6522129b1890bc1292667230e80a5
2014-04-22Fix arm64/x86 build.Torne (Richard Coles)
Add missing second param to soinfo_link_image in a section that's not compiled on ARM. Bug: 13005501 Change-Id: Id0ede8e03da4e05b25c0aeb24a840f868031d4e8
2014-04-22Merge "Allow sharing the RELRO section via a file."Torne (Richard Coles)
2014-04-22Merge "Support loading libraries to a reserved address."Torne (Richard Coles)
2014-04-22Merge "Add android_dlopen_ext() interface to linker."Torne (Richard Coles)
2014-04-18Temporarily disable text relocation warnings for x86 librariesDu Chenyang
Too many such warnings will cause CTS failed. This issue still exists in some x86 version libraries: libdvm.so/libart.so. $scanelf -qT out/target/product/generic_x86/system/lib/libdvm.so libdvm.so: (memory/data?) [0x2BAC7] in (optimized out: previous dvmAsmInstructionStartCode) [0x2B2F8] libdvm.so: (memory/data?) [0x2BB98] in (optimized out: previous dvmAsmInstructionStartCode) [0x2B2F8] libdvm.so: (memory/data?) [0x2EB28] in (optimized out: previous dvmAsmInstructionStartCode) [0x2B2F8] libdvm.so: (memory/data?) [0x2EF87] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63] libdvm.so: (memory/data?) [0x2EFAF] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63] libdvm.so: (memory/data?) [0x2EFD7] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63] libdvm.so: (memory/data?) [0x2EFFF] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63] libdvm.so: (memory/data?) [0x2F027] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63] Bug: https://code.google.com/p/android/issues/detail?id=68431 Change-Id: I11ecac282f1163e49a82156fce2a76cc2d619960
2014-04-17Allow sharing the RELRO section via a file.Torne (Richard Coles)
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
2014-04-17Support loading libraries to a reserved address.Torne (Richard Coles)
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
2014-04-17Add android_dlopen_ext() interface to linker.Torne (Richard Coles)
Add a function "android_dlopen_ext()", defined in <android/dlext.h>. This is an extended version of dlopen() which takes a struct for passing additional parameters for Android-specific functionality. This will be used to support RELRO section sharing between separate processes. Bug: 13005501 Change-Id: I9c99b2f2a02ee329dedaeba09ef3a1113b17b2d6
2014-03-25Use __unused instead of UNUSED in linker.cppKito Cheng
- sys/cdefs.h already define __unused, just use it instead of define a local one. Change-Id: Iacf3da9193e65e1f34b12760b28bcb64b67cb790
2014-02-19Linker writes to wrong memory location when processing DT_MIPS_RLD_MAPBenjamin Adolphi
When bionic's dynamic linker processes the .dynamic section of a MIPS ELF binary and encounters the DT_MIPS_RLD_MAP dynamic array tag, it calculates the address of where to write a pointer to the _r_debug structure. The current implementation simply reads the value given in the d_ptr field and writes the pointer address to that location. However, this value has to be adjusted to reflect the real load address of the binary. Otherwise the linker will write to a faulty location possibly resulting in a crash when linking a MIPS binary that includes DT_MIPS_RLD_MAP. This change corrects that problem. Change-Id: I1a91874f7ab47289001fe72d9016660c14c70362 Signed-off-by: Benjamin Adolphi <b.adolphi@gmail.com>
2014-02-12Remove unused variables not spotted by GCC.Elliott Hughes
Change-Id: I49a16096bc0f41f3ad0007249161e8bdfcf3438c
2014-02-11Clean up all the lint cpplint can find in the dynamic linker.Elliott Hughes
Change-Id: Ic9ee7153817c22a252cc4b309283e355b623cab9
2014-02-11[MIPS64] Dynamic linkerChris Dearman
Change-Id: I937c7c776cae3d66e214798d5217a922cd106bfc Signed-off-by: Chris Dearman <chris.dearman@imgtec.com> Signed-off-by: Duane Sand <duane.sand@imgtec.com>
2014-02-10Switch <elf.h> over to linux uapi under the covers.Elliott Hughes
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
2014-02-10Fix <link.h>.Elliott Hughes
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
2014-01-28bionic: Change the type of soinfo's size to size_tWeiwu Chen
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>