summaryrefslogtreecommitdiff
path: root/linker/tests
AgeCommit message (Collapse)Author
2019-02-15Switch linker tests to Android.bp.Elliott Hughes
Life is easier if we just keep test code in the same directory as the stuff it's testing... Test: tests still build and pass Change-Id: I9b35d689098bdc28a71d69645b0ca9fdd6ea0108
2019-01-25Move the linker allocator into libcRyan Prichard
Rename LinkerMemoryAllocator -> BionicAllocator Rename LinkerSmallObjectAllocator -> BionicSmallObjectAllocator libc and the linker need to share an instance of the allocator for allocating and freeing dynamic ELF TLS memory (DTVs and segments). The linker also continues to use this allocator. Bug: http://b/78026329 Test: /data/nativetest/bionic-unit-tests-static Test: /data/nativetest64/bionic-unit-tests-static Test: /data/nativetest/linker-unit-tests/linker-unit-tests32 Test: /data/nativetest64/linker-unit-tests/linker-unit-tests64 Change-Id: I2da037006ddf8041a75f3eba2071a8fcdcc223ce
2018-11-14switch to using android-base/file.h instead of android-base/test_utils.hMark Salyzyn
Test: compile Bug: 119313545 Change-Id: I664fb32522d01909c603d7b903475c4e9aea9223
2018-11-14linker unit tests requires liblogMark Salyzyn
Test: compile Bug: 119313545 Change-Id: Ic6263c7db55d27ccb5075478aedae30c58ad0044
2018-11-13Move API levels from `uint32_t` to `int`.Elliott Hughes
(cherrypick of a6c71a09670ca636cca5cfea9d74b03a951e2b5e.) Bug: N/A Test: builds Change-Id: I9c414e30e3c4fe2a4e16a2fe4ce18eae85fe4844
2018-10-08Fix normalize_path's handling of "/.."Ryan Prichard
Currently it normalizes the path to a string with a single uninitialized byte. It should instead normalize it to "/". Bug: none Test: /data/nativetest/linker-unit-tests/linker-unit-tests32 Test: /data/nativetest64/linker-unit-tests/linker-unit-tests64 Change-Id: I06e0f7598d16acfa21875dad53efbc293cfeb44d
2018-06-18Resolve paths of dir.${section} if possibleInseob Kim
Some devices place some of their partitions under /system. If the linker resolves that paths, verboseness of ld.config.txt will be reduced as we don't need to add both /system/{partition} and /{partition}. Bug: http://b/80422611 Test: m -j, boot on taimen, atest Change-Id: I6b712170bb89229b764026e2cc517c426e6e6063
2018-01-25linker: Allow link namespaces without name filtersLogan Chien
This commit allows users to create a link without soname filters between two linker namespaces. The motivation is to establish one-way shared library isolation. For example, assume that there are two linker namespaces `default` and `vndk`. We would like to limit the shared libraries that can be used by the `default` namespace. In the meanwhile, we would like to allow the `vndk` namespace to use shared libs from the `default` namespace if the soname cannot be find in the search path or loaded sonames of the `vndk` namespace. shared_libs = %VNDK_CORE_LIBRARIES% shared_libs += %VNDK_SAMEPROCESS_LIBRARIES% vndk <-------------------------------------------- default \_______________________________________________/^ allow_all_shared_libs = true android_link_namespaces_all_libs() is added to libdl, but it is versioned as LIBC_PRIVATE. android_link_namespaces_all_libs() is only for unit tests. Bug: 69824336 Test: adb shell /data/nativetest/linker-unit-tests/linker-unit-tests32 Test: adb shell /data/nativetest64/linker-unit-tests/linker-unit-tests64 Test: adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests Test: adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests Test: Update /system/etc/ld.config*.txt and check whether the vndk linker namespace of the vendor process can access the shared libs from the default linker namespace. Change-Id: I2879f0c5f5af60c7e56f8f743ebd2872e552286b
2017-12-01Allow property += value in ld.config.txtJiyong Park
ld.config.txt currently does not support split line. As the file gets larger, this limitation makes the file very unreadable. Now, long lines can be avoided by breaking one line into multiple lines using += operator. ex) namespace.default.search.paths = /system/${LIB} namespace.default.search.paths += /system/${LIB} Delimitor (':' for *.paths and *.shared_libs, and ',' for *.links) is automatically added. Bug: 69888716 Test: linker-unit-tests passes Change-Id: I4b94fd4e7f8a76d59db8d1096c86aa2118e46625
2017-10-04Revert "linker: disable ld.config.txt in ASAN mode"Jiyong Park
This reverts commit 81b175747d2c7831c010e7e94a6f2572d6dfe437. Reason: 02586a2a34e6acfccf359b94db840f422b6c0231 fixed the bug that prevented us from using LD_PRELOAD with multiple namespaces. Bug: 38114603 Test: 1. ./external/compiler-rt/lib/asan/scripts/asan_device_setup --lib prebuilts/clang/host/linux-x86/clang-stable/lib64/clang/5.0/lib/linux 2. enable talkback shortcut 3. in the home screen, hold vol-up/down together 4. device does not reboots and talkback shortcut is toggled Test: bionic-unit-tests and linker-unit-tests successful (cherry picked from commit 6ab40bbf537d45b171f4830cfa6d82949d4cb258) Merged-In: I25a05927ffbb28b9fa72303652893f43918ccec6 Change-Id: If264f0ce5d7187816d3acc790b6e31d479b628ee
2017-06-19Merge "linker_config_test: allow search paths of systems without a vendor ↵Jaesung Chung
partition" am: b1b7eda11e am: 12b44daa11 Change-Id: I7ec1a1f6a541cfd951093a63da175f521babcb4d
2017-06-19linker_config_test: allow search paths of systems without a vendor partitionJaesung Chung
linker_config#smoke and linker_config.asan_smoke are trying to find paths under the /vendor directory. If there is no vendor partition, the real path of them is started with /system/vendor. This CL allows those paths in the tests by getting the resolved paths for systems without a vendor partition. Bug: http://b/62562515 Test: linker_config_test passes without a vendor partition. Change-Id: Id6d16ef623efd81ab9083c3e819da2ad22a28bf8
2017-05-27Merge "linker: disable ld.config.txt in ASAN mode" into oc-devJiyong Park
am: 41e0ceb5c9 Change-Id: I6e9faedbb26d94aab7064c2c8620362c776143be
2017-05-27linker: disable ld.config.txt in ASAN modeJiyong Park
Currently, multiple namespaces does not support ASAN mode where some symbols should be intercepted via LD_PRELOAD; LD_PRELOADed libs are not preloaded into the linked namespaces other than the default namespace. Until we fix the problem, we temporarily disable ld.config.txt in ASAN mode. Bug: 38114603 Test: 1. ./external/compiler-rt/lib/asan/scripts/asan_device_setup --lib prebuilts/clang/host/linux-x86/clang-stable/lib64/clang/3.8/lib/linux 2. enable talkback shortcut 3. in the home screen, hold vol-up/down together 4. device does not reboots and talkback shortcut is toggled Test: bionic-unit-tests and linker-unit-tests successful Change-Id: I091874dd36b36f56dff2ad899d76ff86931909ed
2017-05-03Move libc_log code into libasync_safe.Christopher Ferris
This library is used by a number of different libraries in the system. Make it easy for platform libraries to use this library and create an actual exported include file. Change the names of the functions to reflect the new name of the library. Run clang_format on the async_safe_log.cpp file since the formatting is all over the place. Bug: 31919199 Test: Compiled for angler/bullhead, and booted. Test: Ran bionic unit tests. Test: Ran the malloc debug tests. Change-Id: I8071bf690c17b0ea3bc8dc5749cdd5b6ad58478a
2017-04-28linker: add android_get_exported_namespaceJiyong Park
Depending on how ld.config.txt is configured, there can be multiple built-in namespaces created by the linker from the beginning of a process. android_get_exported_namespace is a platform only API for getting a handle (android_namespace_t*) to one of the built-in namespaces with given name. The returned namespace can then be given to android_dlopen_ext in order to explicitly specify the target namespace where the library is searched and loaded from. Note that this function only returns 'exported' namespaces created via ld.config.txt file. In order to export a namespace, the visible property should be set to true: namespace.<name>.visible = true Namespaces are hidden by default. Hidden namespaces and namespaces that are created programmatically, notably 'classloader-namespace', aren't returned by this function. Bug: 36851137 Test: confirmed that namespaces created with ld.config.txt is retrieved. Test: linker-unit-tests passes Merged-in: I714b510fa24f77e42c3dfc4c827b3befa8bb2951 Change-Id: I0d05fa7e0e116009edf8ea362ab46774bc617cbf (cherry picked from commit d7c4832e6a640be972017e85ab21e72950dfeddd)
2017-04-06linker: add android_get_exported_namespaceJiyong Park
Depending on how ld.config.txt is configured, there can be multiple built-in namespaces created by the linker from the beginning of a process. android_get_exported_namespace is a platform only API for getting a handle (android_namespace_t*) to one of the built-in namespaces with given name. The returned namespace can then be given to android_dlopen_ext in order to explicitly specify the target namespace where the library is searched and loaded from. Note that this function only returns 'exported' namespaces created via ld.config.txt file. In order to export a namespace, the visible property should be set to true: namespace.<name>.visible = true Namespaces are hidden by default. Hidden namespaces and namespaces that are created programmatically, notably 'classloader-namespace', aren't returned by this function. Bug: 36851137 Test: confirmed that namespaces created with ld.config.txt is retrieved. Test: linker-unit-tests passes Change-Id: I0d05fa7e0e116009edf8ea362ab46774bc617cbf
2017-04-05Move scopeguard into android::baseTom Cherry
Test: boot bullhead, bionic unit tests Change-Id: I223249684867655ecb53713b10da41d3014f96ae
2017-03-24Load namespace configuration from ld.config.txtDimitry Ivanov
This change allows customization of default namespace configuration for different executables. It also enables target_sdk_version setup for binaries (note that this option should explicitly be enabled in ld.config.txt). Bug: http://b/30706810 Bug: http://b/30435785 Test: run linker-unit-tests/bionic-unit-tests, boot angler Change-Id: Ibbe87209acf1538fc9cec04944f3d22a190c38f1
2017-03-13Extract format_string function.Dimitry Ivanov
Extract format_string function and add a test. Test: run linker-unit-tests Change-Id: I794a29aaf62e184438ce1a9224b88aa0586c17b5
2017-02-15Unify linker files under one license (BSD)Dimitry Ivanov
Historically we had part of the linker licensed under BSD and another part under Apache 2 license. This commit makes all the linker code licensed under BSD license. Test: m Change-Id: I11b8163ae75966b5768d3fe992679de376106515
2016-08-08Extract soinfo and globals to separate files.Dimitry Ivanov
Move soinfo and globals out of linker.cpp to separate files. Breaking up huge linker.cpp into smaller peaces in order to make it easier to extract part of the code that belongs to libdl.so and remove parts of the code that do not belong to linker (refactoring part 2 of many) Change-Id: I868417f4b8d2b84d0e8265e354bc7977161497e2
2016-04-05linker: Add unit-test for sleb128_decoderDimitry Ivanov
Add missing test for sleb128_decoder. Also remove dependency to static library because it exposes malloc/free which interfere with libc.so malloc/free causing test to crash. Change-Id: Iedd3268011df9f67ed58c0b58c71f34e30370b23
2016-02-16Revert "Revert "Split out liblinker_malloc static library""Dimitry Ivanov
This reverts commit 3bbeca7a1ae3d31cddd97fb6a0140c4cf7e39f8e. Change-Id: I5a757fcd52a14442c2eb7ca53f7d1f1923a4efe9
2016-02-15Revert "Split out liblinker_malloc static library"Dimitry Ivanov
This reverts commit a80564318a87c1efe76224b8591c707c54d51d2d. Change-Id: I63f16739a38f40ad930692176a4297ad1ce89570
2016-02-11Split out liblinker_malloc static libraryDimitry Ivanov
Bug: http://b/14998480 Bug: http://b/25716705 Change-Id: I8c7ba3971d1b17dbfc1a2ab5553aa04fe5da6677
2016-01-21linker: align allocated blocks to 16 bytesDimitry Ivanov
C/C++ requires the result of malloc/new to be aligned for any primitive type. Change-Id: I715b7679e738f34b3b409993fb3ef242e1321b7f
2015-12-09Add permitted_when_isolated_path to linker namespacesDimitry Ivanov
The permitted_when_isolated_path is a way to white-list directories not present in search-path. It is ignored for not isolated namespaces. Bug: http://b/25853516 Bug: http://b/22548808 Change-Id: Ib1538037268eea69323ea49968a34a4a1d1938a5
2015-11-20Move some utility functions to linker_utilsDmitriy Ivanov
Also adds unit-tests for page_start, page_offset, and safe_add Change-Id: Ia1325b4682d367328a01599a19848e4ffcd2c0ea
2015-11-15Introducing linker namespacesDmitriy Ivanov
Bug: http://b/22548808 Change-Id: Ia3af3c0a167f1d16447a3d83bb045d143319b1e1
2015-11-05Fix linked_list::remove_if()Dmitriy Ivanov
When remove_if removes last element from the list following push_back stops working. Change-Id: Ia3e92763b83a2e172eaa10de7aecfb7a4be452d7
2015-10-07Make dt_runpath work for libraries opened from apkDmitriy Ivanov
This patch also fixes realpath for libraries opened directly from apks. Bug: http://b/21960914 Bug: http://b/21961857 Change-Id: I35ade661c87f1d448191f385811f6e9fd3cacf11
2015-10-05Fix linker testsDmitriy Ivanov
Change-Id: I4794f2d9dcc5ceb419e1bf9151607a650eb801d9
2015-08-10Move up to C++14.Dan Albert
The default standard version is now ahead of us. Stop specifying C++11 so we get that too. Change-Id: Ic96942cd7fd134118e29b744601b0119e49b6ac4
2015-03-16General purpose memory allocator for linker.Dmitriy Ivanov
Add basic general purpose memory allocator to linker in order to enable usage of other libraries like libziparchive. Change-Id: I4a680ebb36ed5ba67c61249f81dba9f567808434
2015-03-10Rename LinkerAllocator and LinkerAllocatorPageDmitriy Ivanov
Change-Id: I87d80fbcd4ec26c0ee4f601b9c4c64f600418dd9
2015-03-10Refactoring: rename linker_allocator filesDmitriy Ivanov
Change-Id: Ifc08e64b3a85205f072b7abab1149c7ab71e2f75
2015-01-24Remove obsolete BUILD_TINY_ANDROID.Elliott Hughes
Change-Id: If2fc97134340fd09ec2583b666ace2f673cbdf66
2014-09-08Load libraries in breadth-first orderDmitriy Ivanov
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
2014-09-02Implement LinkedList::visit()Dmitriy Ivanov
Change-Id: Ibd9d133dddf1f2e6e65660e3cd2dacafcc0c84d9
2014-08-29Erase elements in LinkedList::remove_ifDmitriy Ivanov
Change-Id: I5119a78c73ffe780a81c53ab5ff0266d5c82d319
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-24Fix global variable initialization for linkerDmitriy Ivanov
Linker now calls init functions for itself. Change-Id: Ibd099812493041ac70f591e3f379ee742b4683b8
2014-07-01Native tests are now multilib=both by defaultDmitriy Ivanov
Change-Id: I788ac0b871703c137727a65e017c4466127c0190
2014-06-03Turn on -Wunused and fix the mistakes it uncovers.Elliott Hughes
Change-Id: I023d2d8b547fbc21d4124bb7510d42b06a0dc501
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-14Fix for linker allocatorDmitriy Ivanov
Change-Id: I18a3f1a8515657f0deb69266184fb516a27f90e8
2014-05-13Remove page level mprotectsDmitriy Ivanov
Freeing block mprotects on the page which it turn may lead to application crash if linker subsequently tries to modify another block on the page. Bug: 14895266 Change-Id: I8ff7f5df467d7be184242de652032b3c84e24b76
2014-05-12Refactor linker allocatorDmitriy Ivanov
Makes it reusable for different fixed sized and not very big structures (<PAGE_SIZE). Change-Id: Id5ec13fc6541b1935ef7fe3671c22b98685abbae