aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dlfcn_test.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add bootstrap directory to bootstrap linker's search path.Peter Collingbourne2019-06-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | A proposed set of changes: https://android-review.googlesource.com/q/topic:"no-dup-hwasans" will cause the HWASAN runtime to be moved from /system/lib64 to /system/lib64/bootstrap. This causes a problem in the case where libc is built with HWASAN but init is not built with HWASAN. In this case, libc.so will have a DT_NEEDED dependency on the HWASAN runtime but init will not. Currently, init and other bootstrap executables arrange to load bootstrap libraries by setting rpath, but rpath only has an effect on libraries directly depended on by the main executable, not libraries indirectly depended on by it. This means that the loading of the HWASAN runtime will fail. Instead of relying on rpath to find the bootstrap libraries, modify the bootstrap linker so that it searches the bootstrap library directory after searching the rpath. Bug: http://b/134503977 Test: Builds Change-Id: I297be32e04ecd316ee12b8e694588e1249e2bb89 Merged-In: I297be32e04ecd316ee12b8e694588e1249e2bb89 (cherry picked from commit ea11be0cc85cb5355ca7ed4ee8736ea52b72e38d)
* Merge "bionic tests: use GTEST_SKIP."Elliott Hughes2019-03-271-15/+13
|\
| * bionic tests: use GTEST_SKIP.Elliott Hughes2019-03-121-15/+13
| | | | | | | | | | | | | | | | Also be a bit more to the point in our messages, focusing on "why" not "what". Test: ran tests Change-Id: I297806c7a102bd52602dcd2fcf7a2cd34aba3a11
* | linker: Handle libraries with disjoint mappings correctly.Peter Collingbourne2019-03-081-0/+30
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's possible and sometimes beneficial for a library to have disjoint mappings and for other libraries to be mapped into the gap between the mappings using ANDROID_DLEXT_RESERVED_ADDRESS. See for example the proposal for partitioning in lld [1]. Because the find_containing_library and do_dl_unwind_find_exidx functions use a simple bounds check to figure out whether a pointer belongs to a library they will, given a pointer into a library mapped into the gap of a library with disjoint mappings, return a pointer to the soinfo for the outer library instead of the inner one, because the outer library will appear before the inner one in the solist. From a user perspective this means that we won't be able to unwind the inner library's frames on 32-bit ARM with libgcc, dladdr() will return information for the outer library given a pointer to the inner one and dlopen() et al will use the linker namespace of the outer library when called from the inner one (although they will usually be the same). To make this work correctly, make it so that once find_containing_library sees a match for the bounds check, it examines the library's PT_LOADs to make sure that there is a mapping for the given address. This is similar to how libgcc and libunwind_llvm already handle finding the PT_GNU_EH_FRAME on non-ARM32 platforms [2,3]. do_dl_unwind_find_exidx is reimplemented in terms of find_containing_library. [1] http://lists.llvm.org/pipermail/llvm-dev/2019-February/130583.html [2] https://github.com/llvm/llvm-project/blob/e739ac0e255597d818c907223034ddf3bc18a593/libunwind/src/AddressSpace.hpp#L523 [3] https://android.googlesource.com/toolchain/gcc/+/master/gcc-4.9/libgcc/unwind-dw2-fde-dip.c#294 Test: /data/nativetest{,64}/bionic-unit-tests/bionic-unit-tests on walleye-userdebug Change-Id: I368fe6ad3c470b3dff80f7d9b04253566d63a7d2
* Add tests for dynamic ELF TLSRyan Prichard2019-01-291-13/+0
| | | | | | | Bug: http://b/78026329 Test: bionic unit tests Merged-In: I508fa38b331eeec7dae53039b4b1ec6cedea3034 Change-Id: I508fa38b331eeec7dae53039b4b1ec6cedea3034
* Disable the dlfcn.dlopen_library_with_ELF_TLS testRyan Prichard2019-01-251-0/+6
| | | | | | | | | | | | | This test is verifying that an ELF TLS solib can't be loaded, but once ELF TLS is implemented, it *can* be loaded. Removing the test requires coordinated changes with internal test suites. I could modify the test to verify that the solib was successfully loaded, but support for dynamic ELF TLS appears across a few different CLs. Bug: http://b/78026329 Test: bionic unit tests Change-Id: If8cd798f456568a5c76310b754cea48ca8edaa82
* Handle R_GENERIC_TLS_TPREL relocationsRyan Prichard2019-01-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This relocation is used for static TLS's initial-exec (IE) accesses. A TLS symbol's value is its offset from the start of the ELF module's TLS segment. It doesn't make sense to add the load_bias to this value, so skip the call to soinfo::resolve_symbol_address. Allow TLS relocations to refer to an unresolved weak symbol. In that case, sym will be non-zero, but lsi will be nullptr. The dynamic linker resolves the TPREL relocation to 0, making &missing_weak_symbol equal the thread pointer. Recognize Gold-style relocations to STB_LOCAL TLS symbols/sections and issue an error. Remove the "case R_AARCH64_TLS_TPREL64", because the R_GENERIC_TLS_TPREL case handles it. Remove the no-op R_AARCH64_TLSDESC handler. It's better to issue an error. dlopen_library_with_ELF_TLS now fails with a consistent error about an unimplemented dynamic TLS relocation. Bug: http://b/78026329 Test: bionic unit tests (elftls tests are added in a later CL) Change-Id: Ia08e1b5c8098117e12143d3b4ebb4dfaa5ca46ec
* Move isolated test runner out of bionic.Christopher Ferris2018-09-271-15/+17
| | | | | | | | | Use a global gtest isolation runner rather than the custom one in bionic. Test: Ran all unit tests and verified same behavior before and after. Change-Id: I24a7cf17cf8e018d0f51969c64b53ce9059cc779
* Add secondary counter in place of tls_nodelete flagdimitry2018-05-301-13/+135
| | | | | | | | | | | | | | | | The tls_nodelete state should apply to load_group not isolated soinfo. This actually also means that multiple soinfos may have tls_counter on their dso_handles. This change replaces TLS_NODELETE flag with secondary counter. Note that access to the secondary counter (located inside soinfo) is pretty expensive because it requires soinfo lookup by dso_handle whereas dso_handle counter is much faster. This is why it is updated only when dso_handle counter starts or hits 0. Bug: http://b/80278285 Test: bionic-unit-tests --gtest_filter=dl* Change-Id: I535583f6714e45fa2a7eaf7bb3126da20ee7cba9
* Define DT_ANDROID_REL[A] correctly for a testRyan Prichard2018-05-231-4/+7
| | | | | | | | | | | | | | | | | | | DT_ANDROID_REL is 0x6000000f, but this code defined it as 0x60000002. DT_ANDROID_RELA is 0x60000011, but this code defined it as 0x60000004. compat_elf_hash_and_relocation_tables tests that certain shared libraries are linked with ordinary relocations and not with packed relocations. A shared library will only have one kind of relocation table, so the test mostly still worked by requiring DT_REL[A]. Previously, this test would have allowed libdl.so to have packed relocations. Test: /data/nativetest/bionic-unit-tests/bionic-unit-tests \ --gtest_filter=dlext.compat_elf_hash_and_relocation_tables Test: manual Bug: none Change-Id: Ic8aa919a68fb6ed01a7994b69c0c7dd3798d6b67
* Break libdl.so and ld-android.so's dependency on libc.so.Ryan Prichard2018-03-301-4/+9
| | | | | | | | | | | | | * Specify "nocrt: true" to avoid calling __cxa_finalize. * Define a dummy __aeabi_unwind_cpp_pr0 for arm32. Bug: b/62815515 Bug: b/73873002 Test: boot AOSP hikey960-userdebug Test: run ndk_cxa_example in special /system/bin/debug namespace Test: run Bionic unit tests Change-Id: I59bcb100a2753286b59c51a47d7a183507219a07
* Reject .so files using ELF TLS.Elliott Hughes2018-03-231-0/+7
| | | | | | Bug: http://b/74361956 Test: ran tests Change-Id: I53e71252eb08c607c2c436dcba433374c8c53887
* Be clearer about linker warnings.Elliott Hughes2018-02-281-1/+1
| | | | | | | | | | | | Explicitly say "warning" for warnings, explicitly say what action we're going to take (such as "(ignoring)"), always provide a link to our documentation when there is one, explicitly say what API level the behavior changes at, and explicitly say why we're allowing the misbehavior for now. Bug: http://b/71852862 Test: ran tests, looked at logcat Change-Id: I1795a5af45deb904332b866d7d666690dae4340b
* Fix RTLD_NEXT/DEFAULT lookupdimitry2018-02-201-1/+1
| | | | | | | | | | | | | | RTLD_NEXT/DEFAULT lookup should not skip handle lookup in the case when the load group is RTLD_GLOBAL. Note that there is a difference between load group is local group. The local group includes externally referenced libraries where the load group does not. The external reference in this context is a DT_NEEDED library that belongs to a previously loaded group. Bug: http://b/72237367 Test: bionic-unit-tests --gtest_filter=dl* Change-Id: I8997cc961c13a5396f1756161798b45ed1cab16c
* The VDSO soname varies by architecture.Elliott Hughes2018-02-161-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | From http://man7.org/linux/man-pages/man7/vdso.7.html: user ABI vDSO name ───────────────────────────── aarch64 linux-vdso.so.1 arm linux-vdso.so.1 ia64 linux-gate.so.1 mips linux-vdso.so.1 ppc/32 linux-vdso32.so.1 ppc/64 linux-vdso64.so.1 s390 linux-vdso32.so.1 s390x linux-vdso64.so.1 sh linux-gate.so.1 * i386 linux-gate.so.1 * x86-64 linux-vdso.so.1 x86/x32 linux-vdso.so.1 Note that Android "x86" is Linux's "i386", which is the odd one out amongst Android's supported architectures. Bug: http://b/72831787 Test: ran tests Change-Id: I0a28127af042e2fd7673f24bbb30f8a50556cf96
* Fixing app compat issue b/72143978Ian Pedowitz2018-01-181-0/+78
| | | | | | | | | | | | | | | | | | | This is a squash revert of a4a4854 and 1b0f2b4 Revert "Remove a test for backwards compatibility we no longer support." This reverts commit a4a485454a3a117eccdca1113681f770d765d865. # This is the commit message #2: Revert "Remove obsolete workaround." This reverts commit 1b0f2b49d528c90842b4263269d9039d7e07415e. Bug: 72143978 Bug: 24465209 Test: Tested failing case on sailfish, reverted back all CL's since Test: 3471433 for b/24465209 and apps open
* Remove a test for backwards compatibility we no longer support.Elliott Hughes2018-01-121-78/+0
| | | | | | Bug: http://b/24465209 Test: ran tests Change-Id: I80bb86379f108d88a6f4abb031450d13ac87c7b9
* Fix dlclose for libraries with thread_local dtorsdimitry2018-01-101-0/+78
| | | | | | | | | | | Introduce new flag to mark soinfo as TLS_NODELETE when there are thread_local dtors associated with dso_handle belonging to it. Test: bionic-unit-tests --gtest_filter=dl* Test: bionic-unit-tests-glibc --gtest_filter=dl* Bug: https://github.com/android-ndk/ndk/issues/360 Change-Id: I724ef89fc899788f95c47e6372c38b3313f18fed
* Add test checking library unload on dlclosedimitry2017-11-071-0/+16
| | | | | | Bug: http://b/68262627 Test: Run bionic-unit-tests --gtest_filter=dl*:Dl* Change-Id: Ied85bc4ab37524cfcdbc33fd6c6e69b8d87ee08a
* Fix for dlfcn.rtld_next_from_library.Raj Mamadgi2017-11-031-9/+9
| | | | | | | | | | | Using fclose to get the same address for the test assertion because Samsung already uses LD_PRELOAD to intercept `close`. Bug: http://b/67978141 Bug: http://b/68855476 Test: ran tests Change-Id: I2da463e8b27e0db5cb1ba370d30f0402d7531396 Signed-off-by: Raj Mamadgi <r.mamadgi@samsung.com>
* Fix: linker segfault on dlopen of a DF_1_GLOBAL soJiyong Park2017-10-191-0/+5
| | | | | | | | Added the missing null check routine. Bug: 67755729 Test: dlfcn.dlopen_df_1_global added and it passes Change-Id: Ibe8db18b0b5a481e2e9937041abef6d6b179dd87
* Fix dlopen_vdso testdimitry2017-10-111-0/+9
| | | | | | | | | arm32 is still missing vdso (at least on some kernels). This commit adds explicit check for it and skip the test if AT_SYSINFO_EHDR is not set. Test: run 32bit bionic-unit-tests --gtest_filter=dlfcn.dlopen_vdso on angler Change-Id: I7fae78c6a4f819601a4ac9e8e1da53ff07c833ff
* Link vdso before linking the main executabledimitry2017-09-261-0/+6
| | | | | | | | | | Also set linked flag after it is linked and call constructors. Set RTLD_NODELETE flag to prevent accidental unloads. Test: bionic-unit-tests --gtest_filter=dl*:Dl* Test: bionic-unit-tests-glibc --gtest_filter=dl* Change-Id: Ib2178849b918cbefd6f8fcfe6d1f78889fe0bf76
* Enable dlfcn.dt_runpath_absolute_path in glibc testsDimitry Ivanov2017-06-271-15/+15
| | | | | | | | | dlfcn.dt_runpath_absolute_path no longer fails when running bionic-unit-tests on glibc Bug: http://b/25320359 Test: bionic-unit-tests-glibc --gtest_filter=dlfcn.dt* Change-Id: Ia0ecf43293cb0fed28516fd8cb87e7f5f2d6e648
* Add #defines for some key enums.Elliott Hughes2017-06-151-0/+16
| | | | | | | | | | | | | | | Building ruby actually trips over both of these: * if the RTLD_ constants aren't #defined, it uses its own incorrect values. * if the REG_ constants aren't #defined, it confuses x86 with x86-64. In all other places where we have enums in our headers, we already match existing glibc practice. Bug: http://b/62531921 Test: builds Change-Id: I5b3aab25a1a24611bdc58f2eda4104a78e9f841c
* Remove known failures from arm ifunc testsDimitry Ivanov2017-05-031-10/+0
| | | | | | | | | | | Since clang does not produce IRELATIVE relocations this test started passing when we switched away from gcc This is still a problem because it now leads to situation where static ifuncs become globally visible but this is a different problem. Test: bionic-unit-tests --gtest_filer=dl* Change-Id: Id27ba5093b88519c00acbc43ab8a991a671a9f51
* Add ifunc for variable test-caseDimitry Ivanov2017-05-021-7/+41
| | | | | | | Also move ifunc tests to clang and c++. Test: bionic-unit-tests --gtest_filter=dlfcn.ifunc* Change-Id: I008c4fc01470c8e4d314003c03a2b63ff9bf7fd8
* Move scopeguard into android::baseTom Cherry2017-04-051-11/+5
| | | | | Test: boot bullhead, bionic unit tests Change-Id: I223249684867655ecb53713b10da41d3014f96ae
* Disable compat_elf_hash_and_relocation_tables test for x86Dimitry Ivanov2017-03-241-3/+3
| | | | | | Bug: http://b/36571076 Test: run bionic-unit-tests on fugu Change-Id: I2f901bc99e55f15b06fe6a5b0d7a125d1b8241a8
* Fix greylist exception to account for linked namespacesDimitry Ivanov2017-02-271-5/+0
| | | | | | | | | | | | | Do not load second copy of libraries that are supposed to be provided by linked namespaces. Also do not print error in the log if caller tries to open shared library using absolute path for apps targeting N+. Bug: http://b/35454141 Bug: http://b/26833548 Bug: http://b/35338922 Test: run bionic-unit-tests --gtest_filter=dl* Change-Id: Icf3aeedff18d287d2ba0b3df3808b100f3ef5f7a
* loader: fix d-tor call orderDimitry Ivanov2017-02-101-2/+8
| | | | | | | | | | | | | | | | In the case when there are multiple dependencies on the same library in the local_group the unload may in some situations (covered now by tests) result calling d-tors for some libraries prematurely. In order to have correct call order loader checks if this is last dependency in local group before adding it to BFS queue. Bug: http://b/35201832 Test: bionic-unit-tests --gtest_filter=dl*:Dl* Test: bionic-unit-tests-glibc --gtest_filter=dl* Change-Id: I4c6955b9032acc7147a51d9f09b61d9e0818700c
* Add test checking init/fini call orderDimitry Ivanov2017-02-091-0/+22
| | | | | | | | | | This test is checking that loader complies with the order described in http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#init_fini Bug: http://b/35201832 Test: bionic-unit-tests --gtest_filter=dl*:Dl* Test: bionic-unit-tests-glibc --gtest_filter=dl* Change-Id: I4cdf878c043112442c191e82aa9f5d5077e4d8c4
* Fix bionic-unit-tests in arch with binary translatorVictor Khimenko2017-01-251-3/+36
| | | | | | | | | | | If binary translator is involved then libc is not place in /system/lib or /system/lib64. It's placed into /syste/lib/arm, /system/lib/arm64, etc. FUGU is an example of such an architecture. Support both cases by picking right path at runtime. Test: run bionic-unit-tests --gtest_filter=dlfcn.dladdr_libc Change-Id: I8345c0f6c19376ebe5106f9670fd2addeb9b9080
* Mark ifunc tests failing on arm as known failuresDimitry Ivanov2017-01-231-0/+10
| | | | | | Bug: http://b/27930475 Test: run bionic-unit-tests on arm and arm64 Change-Id: I5084b6a5ef4b56ca9985da63a5e6896f771810f0
* Merge "Add test for elf-hash and packed relocations"Dimitry Ivanov2016-12-151-0/+84
|\
| * Add test for elf-hash and packed relocationsDimitry Ivanov2016-12-141-0/+84
| | | | | | | | | | | | | | | | | | | | | | | | This adds CTS test for system libraries to support workaround for http://b/24465209: some apps require a subset of system libs to have elf-hash and not to use packed relocations. Bug: http://b/32917341 Bug: http://b/24465209 Test: bionic-unit-tests --gtest_filter=Dl*:dl* Change-Id: Ia0bc28506b1f1f97d4cf902d73b0769e2815fed3
* | Add test for empty symbol lookupDimitry Ivanov2016-12-141-0/+10
|/ | | | | | | | | Check that dlsym(handle, "") fails. Bug: http://b/33530622 Test: bionic-unit-tests --gtest_filter=dlfcn* Test: bionic-unit-tests-glibc --gtest_filter=dlfcn* Change-Id: Iae572bd1d9b798be619c5018de2a5450bf37977e
* Fix bionic-unit-tests-glibcDimitry Ivanov2016-11-281-10/+26
| | | | | | | | Also add another test for dlsym(RTLD_NEXT, ..) Bug: http://b/33106624 Test: run bionic-unit-tests-glibc and bionic-unit-tests Change-Id: I340165d66bf2360b0e3273d3561a08cb5e7bd025
* Improve dlerror_concurrent testDimitry Ivanov2016-11-171-12/+34
| | | | | | | Add a test to check if result is thread-local, not only buffer. Test: run bionic-unit-tests Change-Id: Ia95f88c0d76aa86f7f439836393abd67a57dd396
* Add test for libraries with textrelsDimitry Ivanov2016-10-191-0/+22
| | | | | | | | | Make sure android fails to load them. Bug: http://b/30795430 Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid* Test: cts-tradefed run singleCommand cts --skip-preconditions -m CtsBionicTestCases Change-Id: Id0ebdf336b2f297007479ceb1bbccf778a7ca3f2
* bionic-unit-tests: remove dependency on ANDROID_DATADimitry Ivanov2016-10-101-30/+29
| | | | | | | | | | Replace references to ANDROID_DATA enviroment variable with references to g_testlib_root. Bug: http://b/22182538 Test: build and run bionic-unit-tests --gtest_filter=dl*:Dl* Test: make cts && cts-tradefed run singleCommand cts --skip-preconditions -m CtsBionicTestCases Change-Id: I5667e991551cec55b9b664f2f0063039671ff34b
* bionic-unit-tests: Create symlinks in runtimeDimitry Ivanov2016-10-101-2/+5
| | | | | | | | | | Instead of creating symlinks in build time and then relying on usage of adb sync (adb push follows symlinks) - create them in test run time. Test: mm && run bionic-unit-tests --gtest_filter=dl*:Dl* Bug: http://b/22182538 Change-Id: I9d2a873e3ba303533c14ba5e3b779e4a67925462
* Move test libraries under /data/nativetestsDimitry Ivanov2016-09-021-19/+34
| | | | | | | | | Move libraries used in bionic-unit-tests out of system partition to /data/nativetests../bionic-loader-test-libs Bug: http://b/22182538 Test: build bionic and run bionic-unit-tests Change-Id: I170177bef782839d0b4970ae4418bf54d0a77836
* [mips] Add missing linker shdr testsNikola Veljkovic2016-08-161-1/+1
| | | | | Test: bionic-unit-tests for mips, mips64. Change-Id: I8ed5f03df8d129e74fa04be2b203bd113a381888
* Merge "linker: add test for zeroed out shdr_table_"Treehugger Robot2016-08-151-0/+8
|\
| * linker: add test for zeroed out shdr_table_Dimitry Ivanov2016-08-151-0/+8
| | | | | | | | | | | | Bug: http://b/30795430 Change-Id: I86b658d01b64670d3e702ddb1d3f9db4f75d784f Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
* | Merge "linker: add test for zero shdr offset"Treehugger Robot2016-08-151-0/+8
|\|
| * linker: add test for zero shdr offsetDimitry Ivanov2016-08-151-0/+8
| | | | | | | | | | | | Bug: http://b/30795430 Change-Id: I03853257c4b632ad9daaf1e90f9620678397cff0 Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
* | Merge "[MIPS] Fix bionic test build"Treehugger Robot2016-08-151-1/+1
|\ \ | |/ |/|
| * [MIPS] Fix bionic test buildLazar Trsic2016-08-151-1/+1
| | | | | | | | | | | | | | Group of libtest_invalid* libraries does not exists for mips architecture, so disable relevant tests. Change-Id: I3a4fef94933eb33654c4274aa249ea5d61d6cf9b