summaryrefslogtreecommitdiffstats
path: root/linker/dlfcn.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Lock on dl_interate_phdrDmitriy Ivanov2015-06-291-0/+5
| | | | | | | | | | There is possibility of someone dlclosing a library while dl_iterate_phdr in progress which can lead to dl_iterate_phdr calling callback with invalid address if it was unmapped by dlclose. Bug: http://b/22047255 Change-Id: I3fc0d9fd2c51fb36fd34cb035f37271fa893a7be
* Backward compatibility for dlsym(RTLD_DEFAULT, ...)Dmitriy Ivanov2015-06-021-0/+2
| | | | | | | | | Do not skip RTLD_LOCAL libraries in dlsym(RTLD_DEFAULT, ...) if the library is opened by application with target api level <= 22 Bug: http://b/21565766 Bug: http://b/17512583 Change-Id: Ic45ed1e4f53e84cba9d74cab6b0049c0c7aa8423
* Work around incorrect dt_needed entriesDmitriy Ivanov2015-05-281-0/+2
| | | | | | | | | This applies for apps targeting sdk<=22 and only for lp32 platforms. Bug: http://b/21364029 Change-Id: I903e81c9ccda2a8beaba1d132d68c77d30a4cdb2 (cherry picked from commit d974e8804689058714dc4fe9adcb57ee9a6996a8)
* Add functions to provide target sdk versionDmitriy Ivanov2015-05-271-14/+26
| | | | | | Bug: http://b/21364029 Change-Id: I8648d1bff6c8fd6e7cd12da7f128e048b9f2829a (cherry picked from commit 79fd668bb4ddb22432eeda2ebd8d10359013d9a8)
* Support symbol versioningDmitriy Ivanov2015-04-161-1/+1
| | | | | Bug: http://b/20139821 Change-Id: I64122a0fb0960c20b2ce614161b7ab048456b681
* Add realpath for soinfoDmitriy Ivanov2015-04-061-15/+20
| | | | | | | | | | | | This change adds realpath to soinfo and extends limit on filenames from 128 to PATH_MAX. It also removes soinfo::name field, linker uses dt_soname instead. Bug: http://b/19818481 Bug: https://code.google.com/p/android/issues/detail?id=80336 Change-Id: I9cff4cb5bda3ee2bc74e1bbded9594ea7fbe2a08
* Look into local group on dlsym with RTLD_DEFAULTDmitriy Ivanov2015-04-021-10/+5
| | | | | | | | Fix dlsym to look into local group when called with RTLD_DEFAULT and RTLD_NEXT. Bug: 17512583 Change-Id: I541354e89539c712af2ea4ec751e546913027084
* Implement lookup by DT_SONAMEDmitriy Ivanov2015-03-181-0/+1
| | | | | | | | | This CL also fixes SEARCH_NAME hack and resolves https://code.google.com/p/android/issues/detail?id=6670 once and for all. Bug: https://code.google.com/p/android/issues/detail?id=6670 Change-Id: I9b8d6a672cd722f30fbfbb40cdee8d9b39cfe56e
* Add missing includes.Elliott Hughes2015-01-281-0/+1
| | | | Change-Id: Ibf549266a19a67eb9158d341a69dddfb654be669
* Merge "Count references for groups instead of instances"Dmitriy Ivanov2014-12-021-3/+4
|\
| * Count references for groups instead of instancesDmitriy Ivanov2014-12-021-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Count references on the group level to avoid partially unloading function that might be referenced by other libraries in the local_group Bonus: with this change we can correctly unload recursively linked libraries. is_recursive check is removed. Also dynamic executables (not .so) with 0 DT_NEEDED libraries are now correctly linked. Change-Id: Idfa83baef402840599b93a875f2881d9f020dbcd
* | Build our benchmarks against glibc too.Elliott Hughes2014-12-011-1/+1
|/ | | | | Bug: 18556607 Change-Id: I455ac8b93c0835836180e549486bc52d393ee6a6
* Rename soinfo methods and fieldsDmitriy Ivanov2014-11-131-7/+7
| | | | Change-Id: If68fbe287d3ad954238b1688f71013371f3f7fae
* Add support for hash-style=gnuDmitriy Ivanov2014-11-121-1/+1
| | | | Change-Id: I171434a587420895feac8a9b1ad2342087197568
* Add file_offset parameter to android_extinfoDmitriy Ivanov2014-10-061-1/+1
| | | | | Bug: 17762003 Change-Id: I8fb267a3155acef3dba534038cf5d1ef00d7154b
* Fix unused DT entry warnings.Dmitriy Ivanov2014-09-301-1/+2
| | | | | | | | DT_STRSZ Implement strtab boundary checks DT_FLAGS_1 Warn if flags other than DF_1_NOW|DF_1_GLOBAL are set Bug: 17552334 Change-Id: Iaad29cd52f5b2d7d2f785fb351697906dc1617d9
* Remove has_DT_SYMBOLIC flagDmitriy Ivanov2014-09-161-1/+0
| | | | | | | | | | From the elf-spec: "Symbolically bound shared objects are identified by the .dynamic entry DT_SYMBOLIC. This tag is informational only; the runtime linker processes symbol lookups from these objects in the same manner as any other object." Change-Id: I4aae0e502ed9fac096fbf076f4d6b2e055d784f6
* Fix dlsym() to take into account RTLD_GLOBAL/LOCALDmitriy Ivanov2014-09-151-1/+1
| | | | | | | | Symbols from libraries opened with RTLD_LOCAL (default) should not be visible via dlsym(RLTD_DEFAULT/RTLD_NEXT, .) Bug: 17512583 Change-Id: I1758943081a67cf3d49ba5808e061b8251a91964
* Add IFUNC support for arm64 and IRELATIVE relocDmitriy Ivanov2014-09-111-2/+2
| | | | | | | | | | | | | | | There are number of changes in the way IFUNC related relocations are done: 1. IRELATIVE relocations are now supported for x86/x86_64 and arm64. 2. IFUNC relocations are now relying on static linker to generate them in correct order - this removes necessety of additional relocation pass for ifuncs. 3. Related to 2: rela?.dyn relocations are preformed before .plt ones. 4. Ifunc are resolved on symbol lookup this approach allowed to avoid mprotect(PROT_WRITE) call on r-x program segments. Bug: 17399706 Bug: 17177284 Change-Id: I414dd3e82bd47cc03442c5dfc7c279949aec51ed
* Load libraries in breadth-first orderDmitriy Ivanov2014-09-081-0/+1
| | | | | | | | | | 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-1/+0
| | | | | | This reverts commit a3ad450a2e3fb6b3fe359683b247eba20896f646. Change-Id: Ia2b838ad2159c643b80c514849582f4b4f4f40e5
* Load libraries in breadth-first orderDmitriy Ivanov2014-09-031-0/+1
| | | | | | | | | 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-23/+23
| | | | Change-Id: Iad50be617d318ca98883b843229c960ad5b9afa9
* Bump soinfo versionDmitriy Ivanov2014-08-221-8/+3
| | | | | | | | | This includes: 1. Placing has_ifunc after fields with version = 0 2. Switch to has_min_version(v) function. 3. Minor soinfo initialization refactoring (placement new + ctor) Change-Id: I1bf5fde4d930914012ce5f3ad5acb48217da9b2d
* Revert "Add support for protected local symbol lookup."Dmitriy Ivanov2014-08-191-9/+16
| | | | | | | | | This reverts commit d97e9f546ea195686a78e539315b273393609b9e. Bug: 17107521 (cherry picked from commit 9419420919ea846bbad5510850c7aaec95021648) Change-Id: I1a6df946ac8075699e77d68ffa6ac4a21b88e4bf
* Fix dlsym(3) to do breadth first search.Dmitriy Ivanov2014-07-291-2/+1
| | | | | | | | dlsym(3) with handle != RTLD_DEFAULT|RTLD_NEXT performs breadth first search through the dependency tree. Bug: 16653281 Change-Id: I017a6975d1a62abb0218a7eb59ae4deba458e324
* Add support for protected local symbol lookup.Dmitriy Ivanov2014-07-011-16/+9
| | | | | Bug: http://code.google.com/p/android/issues/detail?id=66048 Change-Id: Ib334223df27adad9477fb241ab099c5e26df4a7d
* Merge "Revert "HACK: linker: check for handle==0xffffffff on LP64""Colin Cross2014-06-261-2/+2
|\
| * Revert "HACK: linker: check for handle==0xffffffff on LP64"Colin Cross2014-06-161-2/+2
| | | | | | | | | | | | This reverts commit 346fea0805b8c2a20171c9b4ab1aac5f66ede5de. Change-Id: Id3fd79451e4218e68e39ce22f21408cbf93255ee
* | Fix weak function lookupsDmitriy Ivanov2014-06-171-1/+1
|/ | | | | | | | * Linker now correctly resolves function defined with __attribute__((weak)). Bug: https://code.google.com/p/android/issues/detail?id=70206 Change-Id: I82efb905676c25fefb1b11a13f5fecb0f1384657
* Remove an unused parameter from the dlopen implementation.Elliott Hughes2014-06-031-8/+4
| | | | Change-Id: I9297913a743bb570b48ebbe594ff711a481e89e0
* Removed dlsym handle != NULL check for lp64Dmitriy Ivanov2014-05-211-2/+5
| | | | | | | | | | | * Removed unnecessary NULL check in dlsym * Fixed dlsym_failure test to account for correct RTLD_DEFAULT value * Added temporary check for legacy RTLD_DEFAULT value for non-yet-recompiled binaries Bug: 15146875 Change-Id: I089fa673762629f5724b6e4fbca019d9cfc39905
* HACK: linker: check for handle==0xffffffff on LP64Colin Cross2014-05-201-1/+1
| | | | | | | | | bionic RTLD_NEXT was changed from 0xffffffff to -1L, which breaks existing binaries compiled. Temporarily look either until we can get recompiled binaries. Bug: 15113039 Change-Id: I1568fa0e4a832c5e6df21da74a33b22bde7f16f6
* Add RTLD_NOLOAD support and some related changes.Dmitriy Ivanov2014-05-201-7/+15
| | | | | | | | | | | | * 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
* Improve detection of already loaded librariesDmitriy Ivanov2014-05-141-72/+20
| | | | | | | | | | 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
* Switch to g_ for globals.Elliott Hughes2014-05-141-21/+21
| | | | | | | That's what the Google style guide recommends, and we're starting to get a mix. Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
* Add android_dlopen_ext() interface to linker.Torne (Richard Coles)2014-04-171-11/+18
| | | | | | | | | | 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
* Clean up all the lint cpplint can find in the dynamic linker.Elliott Hughes2014-02-111-2/+2
| | | | Change-Id: Ic9ee7153817c22a252cc4b309283e355b623cab9
* [MIPS64] Dynamic linkerChris Dearman2014-02-111-1/+1
| | | | | | 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-19/+13
| | | | | | | | | | | | 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: rename aarch64 target to arm64Colin Cross2014-01-231-1/+1
| | | | | | | Rename aarch64 build targets to arm64. The gcc toolchain is still aarch64. Change-Id: Ia92d8a50824e5329cf00fd6f4f92eae112b7f3a3
* Make it possible for code to query the dynamic linker's default search path.Elliott Hughes2014-01-131-38/+37
| | | | | | | | | 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
* AArch64: Linker64 support for AArch64Marcus Oakland2013-12-171-2/+2
| | | | | | | Addition of support for AArch64 in the linker64 target. Change-Id: I8dfd9711278f6706063e91f626b6007ea7a3dd6e Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
* Don't allow text relocations on 64-bit.Elliott Hughes2013-10-281-0/+2
| | | | | | I've also updated our <sys/exec_elf.h> to match upstream. Change-Id: I52f9fce3167541811208d273ff23ceaa112f7135
* Clean up linker architecture macros.Elliott Hughes2013-10-281-7/+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
* 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
* Fix __errno for LP64 and clean up __get_tls.Elliott Hughes2013-10-091-2/+1
| | | | | | | | | | | If __get_tls has the right type, a lot of confusing casting can disappear. It was probably a mistake that __get_tls was exposed as a function for mips and x86 (but not arm), so let's (a) ensure that the __get_tls function always matches the macro, (b) that we have the function for arm too, and (c) that we don't have the function for any 64-bit architecture. Change-Id: Ie9cb989b66e2006524ad7733eb6e1a65055463be
* Use C99 structure initializer designator style.Elliott Hughes2013-10-081-44/+48
| | | | | | clang warns about using the GCC style of designator. Change-Id: I86ec79f06c8774618082859f48d7d1f576520e32
* x86_64 linker.Elliott Hughes2013-10-081-24/+72
| | | | | | | 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-2/+2
| | | | Change-Id: I2c1f3d34c33685799aade8866eec44479ff9f963