platform_bionic/linker
Christopher R. Palmer 1d53e3197d linker: Add support for dynamic SHIM libraries
Author: Christopher R. Palmer <crpalmer@gmail.com>
Date:   Tue Nov 3 16:44:44 2015 -0500

    linker: Add support for dynamic "shim" libs

    Add a new environment variable

    LD_SHIM_LIBS

    that is a colon (":") separated list of vertical bar ("|") separated pairs.
    The pairs are the name for a soinfo reference (executable or shared library)
    followed by the name of the shim library to load.  For example:

    LD_SHIM_LIBS=rmt_storage|libshim_ioprio.so:/system/lib/libicuuv.so|libshim_icu53.so

    will instruct the linker to load the dynamic library libshim_ioprio.so
    whenver rmt_storage is executed [*] and will load libshim_icu53.so whenever
    any executable or other shared library links against /system/lib/libicuuv.so.

    There are no restrictions against circular references.  In this example,
    libshim_icu53.so can link against libicuuv.so which provides a simple and
    convenient means of adding compatibility symbols.

    [*] Note that the absolute path is not available to the linker and therefore
    using the name of executables does depend on the invocation and therefore
    should only be used if absolutely necessary.  That is, running
    /system/bin/rmt_storage would not load any shim libs in this example because
    it does not match the name of the invocation of the command.

    If you have trouble determining the sonames being loaded, you can also set
    the environment variable LD_DEBUG=1 which will cause additional information
    to be logged to help trace the detection of the shim libs.

    Change-Id: I0ef80fa466167f7bcb7dac90842bef1c3cf879b6

Author: Christopher R. Palmer <crpalmer@gmail.com>
Date:   Sun Nov 15 14:26:32 2015 -0500

    linker: Fix the fact that shim libs do not properly call constructors

    Change-Id: I34333e13443a154e675b853fa41442351bc4243a

Author: Christopher R. Palmer <crpalmer@gmail.com>
Date:   Tue Dec 1 07:10:36 2015 -0500

    linker: Don't try to walk the g_active_shim_libs when doing dlsym

    This is a bug in the original shim_lib implementation which was
    doing the shim lib resolution both when loading the libraries
    and when doing the dynamic symbol resolution.

    Change-Id: Ib2df0498cf551b3bbd37d7c351410b9908eb1795

Author: Christopher R. Palmer <crpalmer@gmail.com>
Date:   Sun Nov 29 08:28:10 2015 -0500

    linker: Reset the active shim libs each time we do a dlopen

    We use the active libs to avoid recursively trying to load the
    same library:

    A -> shimlibs add B -> depends on A -> shimlibs add B -> ...

    However, when we repeatedly dlopen the same library we need
    to reset the active shim libs to avoid failing to add B the
    second time we dlopen A.

    Change-Id: I27580e3d6a53858e8bca025d6c85f981cffbea06

Author: Danny Baumann <dannybaumann@web.de>
Date:   Fri Dec 11 10:29:16 2015 +0100

    Make shim lib load failure non-fatal.

    Instead, print an appropriate warning message. Aborting symbol
    resolution on shim lib load failure leads to weird symbol lookup
    failures, because symbols in libraries referenced after the one loading
    the shim won't be loaded anymore without a log message stating why that
    happened.

    Change-Id: Ic3ad7095ddae7ea1039cb6a18603d5cde8a16143

Author: Christopher R. Palmer <crpalmer@gmail.com>
Date:   Sat Dec 12 06:10:09 2015 -0500

    bionic: Do not allow LD_SHIM_LIBS for setuid executables

    That's really not safe...

    Change-Id: If79af951830966fc21812cd0f60a8998a752a941

Author: Christopher R. Palmer <crpalmer@gmail.com>
Date:   Sun Feb 14 11:38:44 2016 -0500

    bionic: linker: Load shim libs *before* the self-linked libs

    By loading them earlier, this allows us to override a symbol in
    a library that is being directly linked.

    I believe this explains why some people have had problems shimming
    one lib but when the changet he shim to be against a different
    lib it magically works.

    It also makes it possible to override some symbols that were
    nearly impossible to override before this change.  For example, it is
    pretty much impossible to override a symbol in libutils without
    this change because it's loaded almost everywhere so no matter
    where you try to place the shimming, it will be too late and
    the other symbol will have priority.

    In particularly, this is necessary to be able to correctly
    shim the VectorImpl symbols for dlx.

    Change-Id: I461ca416bc288e28035352da00fde5f34f8d9ffa

Author: Chirayu Desai <chirayudesai1@gmail.com>
Date:   Thu Aug 25 19:02:41 2016 +0530

    linker: Update find_library call for shimlibs

    commits 0cdef7e7f3
    "Respect caller DT_RUNPATH in dlopen()."
    and 42d5fcb9f4
    "Introducing linker namespaces"
    added new arguments to find_library, add them here.

    Change-Id: I8f35a45b00d14f8b2ce01a0a96d2dc7759be04a6

Author: Chippa-a <vusal1372@gmail.com>
Date:   Sat Aug 27 14:56:30 2016 +0200

    linker: Update LD_SHIM_LIBS parser function

     * Upgrade the code using the same changes as
        42d5fcb9f4
        bda20e78f0

    Change-Id: Ic8be0871945bd9feccd0f94a6770f3cc78a70a0f

Author: Danny Baumann <dannybaumann@web.de>
Date:   Wed Sep 7 16:54:06 2016 +0200

    Inject shim libs as if they were DT_NEEDED.

    The previous separate approach had one flaw: If the shim lib requires
    another lib that's already loaded, find_library_internal() would return
    the previously loaded copy, but the later load action would fail as the
    ELF reader map of the initial loading round was already discarded and
    thus a new ElfReader instance for the soinfo instance was created, which
    didn't know about the previous reading/loading state.

    Change-Id: Ib224dbd35d114197097e3dee14a077cc9130fedb

Author: jrior001 <jriordan001@gmail.com>
Date:   Fri Oct 7 19:36:51 2016 -0400

    linker: load shims prior to DT_NEEDED check

    This allows shims to override existing symbols, not just
    inject new symbols.

    Change-Id: Ib9216bcc651d8d38999c593babb94d76dc1dbc95

Author: Adrian DC <radian.dc@gmail.com>
Date: Sat, 8 Apr 2017 22:40:01 +0200

     * Adapt to latest AOSP Oreo bionic linker changes
     * Additional header to avoid unused function

    Change-Id: Ib9216bcc651d8d38999c593babb94d76dc1dbc95

Author: Paul Keith <javelinanddart@gmail.com>
Date:   Thu Feb 15 21:57:33 2018 +0100

    linker: Move shims to TARGET_LD_SHIM_LIBS

    * To reduce security exposure, let's set this at compile time,
      and block off all the code unless the board flag is set

    Change-Id: Ieec5f5d9e0f39a798fd48eae037ecffe9502474c

Author: Nich <nctrenco@gmail.com>
Date:   Fri Jun 8 09:48:17 2018 +0800

    linker: Provide soinfo path of the shimmed binary

    This is a forward port of part of the original change that was missed out
    since the initial port of the shim logic to O.

    Change-Id: I1f7ff98472cfef5cb2d2bcb303082784898cd0c6

Author: Nich <nctrenco@gmail.com>
Date:   Tue Jun 5 13:36:43 2018 +0800

    linker: Remove unused find_libraries declaration

    commit "Inject shim libs as if they were DT_NEEDED." removed references
    to the forward declaration.

    Change-Id: I5f1aaa3a96f2af3edef07d4ea4e204b586424631

Author: Nich <nctrenco@gmail.com>
Date:   Sun Jun 10 00:45:51 2018 +0800

    linker: Make shim reference path absolute

    This way, we can filter out non-existent binaries, and ensure we get
    its absolute path before matching with get_realpath(). This for one
    allows the use of symlinks in TARGET_LD_SHIM_LIBS.

    Change-Id: I823815271b3257965534b6b87d8ea36ffb68bc08

Author: Nich <nctrenco@gmail.com>
Date:   Fri Jun 15 03:59:05 2018 +0800

    linker: Ensure active matching pairs

    Change-Id: I54c666b4560dbfb40839b0bf9132a7fd8d3ed2dd

Author: Nich <nctrenco@gmail.com>
Date:   Thu Jun 21 01:58:10 2018 +0800

    linker: Don't involve shim in for_each_dt_needed

    for_each_dt_needed may have other usages that shouldn't involve the
    shim, for example, in the unloading of soinfos.

    Change-Id: Id38de183d90c3f707767bdca032a5ea2bc82fde8

Author: Jiyong Park <jiyong@google.com>
Date:   Fri Jan 25 18:18:01 2019 +0900

    Call realpath(3) only when the path is accessible for read

    Suppress the SELinux denial log spam by not calling realpath(3) when the
    path does not exist or is not accessible for read, and then not auditing
    access(2) failure.

    Change-Id: I729ecb8ea0bb581069eb849bae7cd28e6ab636cc

Change-Id: Ic3ad7095ddae7ea1039cb6a18603d5cde8a16152
Signed-off-by: Wang Han <416810799@qq.com>
2024-09-07 23:54:33 +02:00
..
arch [riscv][bionic] Prototype TLS Descriptor support 2024-06-07 14:30:22 -07:00
testdata bionic: linker-unit-tests: Add crt_pad_segment tests 2024-02-07 16:20:48 -08:00
Android.bp linker: Add support for dynamic SHIM libraries 2024-09-07 23:54:33 +02:00
dlfcn.cpp Revert "Linker support for MTE globals." 2023-12-06 19:01:46 +00:00
ld.config.format.md linker: Cleanup for Android's inclusive language guidance 2020-07-31 11:37:28 +08:00
ld_android.cpp Add the recoverable GWP-ASan feature. 2023-02-02 15:35:25 -08:00
ldd.sh Ignore LD_LIBRARY_PATH when determining file type in ldd. 2021-03-02 16:56:39 +00:00
linked_list.h Keep allocation of tail_ outside of LinkedList 2022-02-01 21:32:30 -08:00
linked_list_test.cpp Switch linker tests to Android.bp. 2019-02-15 14:40:08 -08:00
linker.arm.map Add the recoverable GWP-ASan feature. 2023-02-02 15:35:25 -08:00
linker.cpp linker: Add support for dynamic SHIM libraries 2024-09-07 23:54:33 +02:00
linker.generic.map Add the recoverable GWP-ASan feature. 2023-02-02 15:35:25 -08:00
linker.h linker: Add support for dynamic SHIM libraries 2024-09-07 23:54:33 +02:00
linker_auxv.cpp linker: add the L3 cache auxv constants. 2023-10-23 18:42:00 -07:00
linker_auxv.h linker: add LD_SHOW_AUXV support. 2023-08-22 14:25:01 -07:00
linker_block_allocator.cpp linker_block_alloctor: Remove 4k page size assumption 2023-08-04 23:08:34 +00:00
linker_block_allocator.h Change default block size alignment to be 4 for memory saving on 32-bit arch 2022-02-03 16:55:37 -08:00
linker_block_allocator_test.cpp Change default block size alignment to be 4 for memory saving on 32-bit arch 2022-02-03 16:55:37 -08:00
linker_cfi.cpp Remove PAGE_SIZE call sites. 2023-06-12 10:59:39 -07:00
linker_cfi.h Switch the rest of our internal headers to #pragma once. 2018-02-13 14:27:17 -08:00
linker_common_types.h Remove unused mips/mips64 code from the linker. 2020-02-13 15:58:48 -08:00
linker_config.cpp Introduce hwasan mode for linker 2023-04-14 01:33:30 -07:00
linker_config.h Introduce hwasan mode for linker 2023-04-14 01:33:30 -07:00
linker_config_test.cpp Introduce hwasan mode for linker 2023-04-14 01:33:30 -07:00
linker_crt_pad_segment_test.cpp loader: Only extend segments if kernel supports page size migration 2024-05-02 11:06:51 -07:00
linker_debug.cpp Create linker_log[_va_list] functions 2020-01-06 16:06:37 -08:00
linker_debug.h Fix bugprone-macro-parentheses warnings 2020-03-04 13:22:05 -08:00
linker_debuggerd.h Add the recoverable GWP-ASan feature. 2023-02-02 15:35:25 -08:00
linker_debuggerd_android.cpp Add API to allow apps to attach extra information to tombstones. 2024-02-13 13:41:12 -08:00
linker_debuggerd_stub.cpp Add the recoverable GWP-ASan feature. 2023-02-02 15:35:25 -08:00
linker_dlwarning.cpp
linker_dlwarning.h Switch the rest of our internal headers to #pragma once. 2018-02-13 14:27:17 -08:00
linker_gdb_support.cpp
linker_gdb_support.h Switch the rest of our internal headers to #pragma once. 2018-02-13 14:27:17 -08:00
linker_globals.cpp Enable BTI in bionic linker 2020-09-23 17:53:28 -07:00
linker_globals.h Hold the loader mutex in linker_main once constructors are running 2023-07-21 23:14:46 -07:00
linker_gnu_hash.h Neon-optimized version of the GNU symbol calculation 2020-01-13 13:29:25 -08:00
linker_gnu_hash_benchmark.cpp Neon-optimized version of the GNU symbol calculation 2020-01-13 13:29:25 -08:00
linker_gnu_hash_test.cpp Neon-optimized version of the GNU symbol calculation 2020-01-13 13:29:25 -08:00
linker_libc_support.c
linker_libcxx_support.cpp
linker_logger.cpp Remove debug.ld.greylist_disabled property 2020-07-30 19:29:17 -07:00
linker_logger.h Remove debug.ld.greylist_disabled property 2020-07-30 19:29:17 -07:00
linker_main.cpp linker: Add support for dynamic SHIM libraries 2024-09-07 23:54:33 +02:00
linker_main.h Revert "Linker support for MTE globals." 2023-12-06 19:01:46 +00:00
linker_mapped_file_fragment.cpp Remove PAGE_SIZE call sites. 2023-06-12 10:59:39 -07:00
linker_mapped_file_fragment.h Clean up bionic_macros.h a bit. 2018-10-25 11:00:00 -07:00
linker_memory.cpp Add aligned_alloc to linker_memory.cpp 2023-07-24 13:08:34 -07:00
linker_namespaces.cpp linker: Cleanup for Android's inclusive language guidance 2020-07-31 11:37:28 +08:00
linker_namespaces.h linker_namespace: move sonames instead of copying 2022-12-01 16:23:03 +09:00
linker_note_gnu_property.cpp Enable BTI in bionic linker 2020-09-23 17:53:28 -07:00
linker_note_gnu_property.h Enable BTI in bionic linker 2020-09-23 17:53:28 -07:00
linker_note_gnu_property_test.cpp Enable BTI in bionic linker 2020-09-23 17:53:28 -07:00
linker_phdr.cpp linker: remove useless comments. 2024-05-16 21:46:24 +00:00
linker_phdr.h loader: Only extend segments if kernel supports page size migration 2024-05-02 11:06:51 -07:00
linker_reloc_iterators.h Optimize GNU hash linking for large inputs 2020-01-13 13:29:25 -08:00
linker_relocate.cpp [riscv][bionic] Prototype TLS Descriptor support 2024-06-07 14:30:22 -07:00
linker_relocate.h Optimize GNU hash linking for large inputs 2020-01-13 13:29:25 -08:00
linker_relocs.h Use the R_RISCV_TLSDESC constant in the linker. 2023-10-18 14:12:31 -07:00
linker_sdk_versions.cpp Add some slack at the end of large allocations when target SDK level < S. 2021-03-05 14:29:17 -08:00
linker_sleb128.h Revert "Linker support for MTE globals." 2023-12-06 19:01:46 +00:00
linker_sleb128_test.cpp Switch linker tests to Android.bp. 2019-02-15 14:40:08 -08:00
linker_soinfo.cpp ldd: skip relocation processing, TLS modules, CFI 2024-03-14 14:01:04 -07:00
linker_soinfo.h Call relocate_relr before the ifunc resolvers 2024-04-04 03:23:04 -07:00
linker_test_globals.cpp bionic: linker-unit-tests: Add crt_pad_segment tests 2024-02-07 16:20:48 -08:00
linker_tls.cpp ldd: skip relocation processing, TLS modules, CFI 2024-03-14 14:01:04 -07:00
linker_tls.h Implement arm64 TLSDESC 2019-01-29 08:33:09 +00:00
linker_translate_path.cpp Refactor translateSystemPathToApexPath 2020-05-19 02:32:07 +02:00
linker_translate_path.h Copy translateSystemPathToApexPath to linker_translate_path.cpp 2020-05-14 22:17:45 +02:00
linker_transparent_hugepage_support.cpp Fix it to call the lambda function 2022-05-19 02:13:39 +00:00
linker_utils.cpp Remove PAGE_SIZE call sites. 2023-06-12 10:59:39 -07:00
linker_utils.h Remove PAGE_SIZE call sites. 2023-06-12 10:59:39 -07:00
linker_utils_test.cpp 16k: Fix linker_utils_test to support 4kb and 16kb page sizes 2023-12-08 00:01:04 +00:00
linker_wrapper.cpp Remove host_bionic_inject 2021-06-14 12:25:05 -07:00
MODULE_LICENSE_BSD Fix/update notices. 2021-02-16 15:06:50 -08:00
NOTICE Update linker/NOTICE. 2024-02-09 09:27:33 -08:00
rt.cpp