History log of /bionic/linker/dlfcn.cpp
Revision Date Author Comments
9ee4591cb4a23b3c1a899f5ae3e4d769d0ba5a15 17-Jan-2018 Logan Chien <loganchien@google.com> linker: Allow link namespaces without name filters

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
06016f226efe7aff2736643cb8e719c513948ecc 05-Jan-2018 dimitry <dimitry@google.com> Fix dlclose for libraries with thread_local dtors

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
8e8c2c001380ad98f2e239c0c840dad80ebec35c 04-Jan-2018 dimitry <dimitry@google.com> Unhardcode linker soname

Set and use DT_SONAME instead.

Test: bionic-unit-tests
Change-Id: I38a246c8a43664792424e8fef96ae2ff5f743ba6
7abea57ba599b9b114031ae33699b5d7fba8cc97 29-Aug-2017 dimitry <dimitry@google.com> Replace artificial symbol table with proper one

This change also replaces elf-hash with gnu-hash.

Test: make
Test: bionic-unit-tests --gtest_filter=dl*:Dl*
Change-Id: Ibc4026f7abc7e8002f69c33eebaf6a193f1d22eb
cd510cbed9dc1e1b65b9d34676fdf6d85101f22c 01-Jun-2017 Dimitry Ivanov <dimitry@google.com> Make dl_iterate_phdr return correct name for first entry

Test: bionic-unit-tests --gtest_filter=link*
Change-Id: Ib3f1e0fbc76fed9a5f27ffdd9bbf847a3e8d3665
01de74e76d1131b5c5b0120d07e8f468ac5f8fac 03-Apr-2017 Jiyong Park <jiyong@google.com> linker: add android_get_exported_namespace

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)
295082b3af2042e52ce44aa75c90755ac97bc4aa 15-Apr-2017 Elliott Hughes <enh@google.com> Avoid "D linker : (null)" with debug.ld.all for dlerror.

We only want to know when dlerror is actually set. The previous change
to this logic moved it so that we only show actual updates to dlerror,
not every string that might end up in dlerror's output. This change
ignores cases where we're _clearing_ dlerror (which happens on every
call to dlerror).

Bug: http://b/37287938
Test: ran tests
Change-Id: I0c30ee199dc76d9aea165c1d90f694ead488518b
d7c4832e6a640be972017e85ab21e72950dfeddd 03-Apr-2017 Jiyong Park <jiyong@google.com> linker: add android_get_exported_namespace

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
e7cdb2953aa8846826082ee11d571e67a4c1246b 28-Mar-2017 Dimitry Ivanov <dimitry@google.com> linker: log only real dlerrors

Currently linker reports all potential dlerrors
for example if library was not found in 'this'
namespace - it initializes linker error buffer
with not found message but when consequent
search in linked namespace succeeds this message
is droped because dlopen was successful.

This commit avoids logging false positive error
messages when debug.ld.* set to dlerror.

Test: manual
Change-Id: I480694a1b1bbacd6bd1d8505cd2ee491710964cc
(cherry picked from commit 11968b80af5be601b820f261e2e102e5b8ed48c4)
11968b80af5be601b820f261e2e102e5b8ed48c4 28-Mar-2017 Dimitry Ivanov <dimitry@google.com> linker: log only real dlerrors

Currently linker reports all potential dlerrors
for example if library was not found in 'this'
namespace - it initializes linker error buffer
with not found message but when consequent
search in linked namespace succeeds this message
is droped because dlopen was successful.

This commit avoids logging false positive error
messages when debug.ld.* set to dlerror.

Test: manual
Change-Id: I480694a1b1bbacd6bd1d8505cd2ee491710964cc
5e2285d3ccdbb64a49ad2e5e521f50c897a3954d 22-Feb-2017 Josh Gao <jmgao@google.com> Allocate thread local buffers in __init_tls.

Thread local buffers were using pthread_setspecific for storage with
lazy initialization. pthread_setspecific shares TLS slots between the
linker and libc.so, so thread local buffers being initialized in a
different order between libc.so and the linker meant that bad things
would happen (manifesting as snprintf not working because the
locale was mangled)

Bug: http://b/20464031
Test: /data/nativetest64/bionic-unit-tests/bionic-unit-tests
everything passes
Test: /data/nativetest/bionic-unit-tests/bionic-unit-tests
thread_local tests are failing both before and after (KUSER_HELPERS?)
Test: /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
no additional failures
Change-Id: I9f445a77c6e86979f3fa49c4a5feecf6ec2b0c3f
bcc4da9b752f0def46d63ed7b31f3f49cc2435ad 16-Feb-2017 Dimitry Ivanov <dimitry@google.com> Unify linker files under one license (BSD)

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
7a34b9d57a762ca7cd6b8d6b9f9fb45c2b991da7 03-Feb-2017 Dimitry Ivanov <dimitry@google.com> Replace public library list with shared lib sonames (part 2/2)

This commit updates interface of libdl.c.

1. android_init_namespaces is replaces with android_init_anonymous_namespace
2. added 2 arguments to android_create_namespace to specify linked namespace
and the list of shared libraries sonames.
3. symbol lookup does not get past boundary libraries (added check and test for it).

Bug: http://b/26833548
Bug: http://b/21879602
Test: bionic-unit-tests --gtest_filter=dl*:Dl*
Change-Id: I32921da487a02e5bd0d2fc528904d1228394bfb9
0a3637d3eb2424d8e825ad1825f843450a888406 06-Jul-2016 Evgenii Stepanov <eugenis@google.com> Runtime support for CFI

Control Flow Integrity support in bionic.

General design:
http://clang.llvm.org/docs/ControlFlowIntegrityDesign.html#shared-library-support

This CL implements subsections "CFI Shadow" and "CFI_SlowPath" in the above document.

Bug: 22033465
Test: bionic device tests
Change-Id: I14dfea630de468eb5620e7f55f92b1397ba06217
a6588e5d6f4b7e566bc5946a676e2edeb4816d6b 12-Dec-2016 Dimitry Ivanov <dimitry@google.com> Fix android_dlwarning lookup

Bug: http://b/33530622
Test: mm
Change-Id: I3eefca58e91b7bbc41f6add9b8c756f1474a7f93
d9e427cf41893377dcdd0650ba20ff7cf7d72209 23-Nov-2016 Dimitry Ivanov <dimitry@google.com> Bionic loader is no longer hijacking libdl.so

Do not hijack libdl.so methods but make libdl proxy calls to
loader instead. This will be replaces by calls to libc.so
once loader functionality is migrated.

Also add a lock to dl_unwind_find_exidx function call.

Test: bionic-unit-tests --gtest_filter=dl*:Dl*
Bug: http://b/27106625
Change-Id: Ic33a7109a86f4262798d63a35f4c61d15b0068bb
dcb846cb4978130d5db6b795e22e08b65e73f3cd 06-Dec-2016 Andreas Gampe <agampe@google.com> Revert "Bionic loader is no longer hijacking libdl.so"

This reverts commit c12acef96bd80c419654e159e1dc24a69513a86d.

Breaks the Mips build.

Bug: 27106625
Change-Id: I27edb7114065c36e1b618e387530d58189cdb184
c12acef96bd80c419654e159e1dc24a69513a86d 23-Nov-2016 Dimitry Ivanov <dimitry@google.com> Bionic loader is no longer hijacking libdl.so

Do not hijack libdl.so methods but make libdl proxy calls to
loader instead. This will be replaces by calls to libc.so
once loader functionality is migrated.

Also add a lock to dl_unwind_find_exidx function call.

Test: bionic-unit-tests --gtest_filter=dl*:Dl*
Bug: http://b/27106625
Change-Id: I9e666e771e4bbca52151cfa7fc4c8677e1480818
5e071a18ce88d93fcffaebb9e0f62524ae504908 12-Aug-2016 Elliott Hughes <enh@google.com> dlerror returns char*, not const char*.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/dlerror.html:

char *dlerror(void);
...
The application shall not modify the string returned.

Change-Id: I5e684bfd3930c39a2a30ea6fd005a5d5d3e5b181
48ec288d40d272e6fe5e68c4c0a9778b55e24f8a 04-Aug-2016 Dimitry Ivanov <dimitry@google.com> Extract soinfo and globals to separate files.

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
769b33fadf45a039741f932672ac2c4f901d7d4a 21-Jul-2016 Dimitry Ivanov <dimitry@google.com> Sync linker with internal branch

This change includes dlwarning implementation and
the compatibility greylist for apps targeting pre-N.

Change-Id: Ibf02a07cc58cbbb1a5aef4ac34558c5d43e4305f
Test: Run bionic-unit-tests --gtest_filter=dl*:Dl*
b996d60493a2e501655f23523b31fe34a63edd5c 12-Jul-2016 Dimitry Ivanov <dimitry@google.com> linker: Enable debug logging via properties

This patch lets developers tune logging of dlopen/dlerror with
setting system property.

Note that for security purposes this option is disabled on user build
for non-debuggable apps.

For starters there are 3 debug options:
dlerror - enables logging of all dlerrors
dlopen - traces dlopen calls

To enable system-wide logging (works only for userdebug/eng builds)
use debug.ld.all property.

To enable logging for particular app use debug.ld.app.<appname> property.

Example: Running "adb shell setprop debug.ld.all dlerror,dlopen" will log all
dlerror message as well as trace all calls to dlopen.

Bug: http://b/29458203
Change-Id: I2392c80a795509e16fe5689d0500d18b99772a64
1a5fd9c155be65d49d51cd511097541897f4bb37 10-Jun-2016 Chih-Hung Hsieh <chh@google.com> Fix misc-macro-parentheses warnings in bionic.

Add parentheses around macro arguments used beside operators,
or use constexpr for simple constants.
Bug: 28705665

Change-Id: I378c8aad92d3ec8e8c4b0440b5c2c99dfe01ce79
49cfc899a3708fae9175e44c0c02cd479fda8b36 13-May-2016 Dimitry Ivanov <dimitry@google.com> linker: Allow caller to specify parent namespace

This change enables apps to share libraries opened
with RTLD_GLOBAL between different classloader namespaces.

The new parameter to create_namespace allows native_loader
to instruct the linker to share libraries belonging to
global group from a specified namespace instead of
using the caller_ns.

Bug: http://b/28560538
Bug: https://code.google.com/p/android/issues/detail?id=208458
Change-Id: I5d0c62730bbed19cdeb16c7559c74aa262a2475f
(cherry picked from commit fc2da53440383fe1026e0eb287d643b577c2707d)
fc2da53440383fe1026e0eb287d643b577c2707d 13-May-2016 Dimitry Ivanov <dimitry@google.com> linker: Allow caller to specify parent namespace

This change enables apps to share libraries opened
with RTLD_GLOBAL between different classloader namespaces.

The new parameter to create_namespace allows native_loader
to instruct the linker to share libraries belonging to
global group from a specified namespace instead of
using the caller_ns.

Bug: http://b/28560538
Bug: https://code.google.com/p/android/issues/detail?id=208458
Change-Id: I5d0c62730bbed19cdeb16c7559c74aa262a2475f
ae74e8750b9dae51b24a22fdb4b0e0a2d84f37b9 24-Mar-2016 Dimitry Ivanov <dimitry@google.com> linker: hide the pointer to soinfo

Handle no longer is a pointer to soinfo of
a corresponding library. This is done to
prevent access to linker internal fields.

Bug: http://b/25593965
Change-Id: I62bff0d0e5b2dc842e6bf0babb30fcc4c000be24
(cherry picked from commit d88e1f350111b3dfd71c6492321f0503cb5540db)
d88e1f350111b3dfd71c6492321f0503cb5540db 24-Mar-2016 Dimitry Ivanov <dimitry@google.com> linker: hide the pointer to soinfo

Handle no longer is a pointer to soinfo of
a corresponding library. This is done to
prevent access to linker internal fields.

Bug: http://b/25593965
Change-Id: I62bff0d0e5b2dc842e6bf0babb30fcc4c000be24
6be6ef563e15cec05ea758f76b493b63c760923c 02-Mar-2016 Dimitry Ivanov <dimitry@google.com> Modify android_dlwarning function to use a callback

The previous implementation of android_dlwarning was not thread-safe
and could return a pointer soon to become invalid in some situations.
This change fixed the problem. I have also removed android_dlwarning
from the dlext.h header file in case we decide to keep
android_dlwarning in the final release.

Bug: http://b/27453994
Change-Id: If6c896a80a17c4be0e18795e617712ad36a106fe
df91dc2c192aa2789320c500037d28c919daa820 26-Feb-2016 Dimitry Ivanov <dimitry@google.com> Add android_dlwarning() method

This is temporary method intended to use
for a toast message on preview and beta
releases. Will be removed before the
production release.

Bug: http://b/27365747
Change-Id: I39cc716bb82863ae761b6821bcec77cce6db3781
7331fe18d7ffd550996e07b534bc7a6cf625afa5 14-Dec-2015 Dimitry Ivanov <dimitry@google.com> linker: implement shared namespaces

Shared namespaces clone the list of loaded native
libraries from the caller namespace. This allows
classloaders for bundled apps to share already loaded
libraries with default namespace.

Bug: http://b/22548808
Bug: http://b/26165097
Change-Id: I8949d45937fdb38e1f586ff0679003adac0d9dad
(cherry picked from commit e78deef364d952dd1141a2f3067a12060aaf11e6)
e78deef364d952dd1141a2f3067a12060aaf11e6 14-Dec-2015 Dimitry Ivanov <dimitry@google.com> linker: implement shared namespaces

Shared namespaces clone the list of loaded native
libraries from the caller namespace. This allows
classloaders for bundled apps to share already loaded
libraries with default namespace.

Bug: http://b/22548808
Bug: http://b/26165097
Change-Id: I8949d45937fdb38e1f586ff0679003adac0d9dad
9cf99cbad89c8495828788ce693a99ced434f66f 11-Dec-2015 Dimitry Ivanov <dimitry@google.com> linker: add dlvsym(3)

This changes implements dlvsym - dlsym for versioned symbols.

Bug: http://b/22865643
Change-Id: Ic90a60d512104261a1416c43f9100f0d88e3b46f
4a2c5aa30ceea2aaf8dcaee2feb4879978af4fce 11-Dec-2015 Dimitry Ivanov <dimitry@google.com> Move dlsym and dladdr implementation to linker.cpp

Bug: http://b/25716705
Bug: http://b/22865643
Change-Id: If22fc1eda219f676b5fcc06490f7901d21d1749c
284ae3559ed909613b189b98bdc3efab94373a30 08-Dec-2015 Dimitry Ivanov <dimitry@google.com> Add permitted_when_isolated_path to linker namespaces

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
1ffec1cc4d0e283bb1ff6f49843769a3493b8d73 23-Nov-2015 Dmitriy Ivanov <dimitry@google.com> Introduce anonymous namespace

The anonymous namespace is introduced to
handle cases when linker can not find the
caller. This usually happens when caller
code was not loaded by dynamic linker;
for example mono-generated code.

Bug: http://b/25844435
Bug: http://b/22548808
Change-Id: I9e5b1d23c1c75bc78548d68e79216a6a943a33cf
42d5fcb9f494eb45de3b6bf759f4a18076e84728 30-Oct-2015 Dmitriy Ivanov <dimitry@google.com> Introducing linker namespaces

Bug: http://b/22548808
Change-Id: Ia3af3c0a167f1d16447a3d83bb045d143319b1e1
747d30ebf368be8c4ec0455324bdac53204eb179 20-Oct-2015 Mike Frysinger <vapier@google.com> dlfcn: update ifdef around old_name_

Commit 9185e04f72c16d2a66d92ac89b38ee926d7f706b changed the ifdef around
old_name_ from __arm__ to __work_around_b_###__, but missed one place in
dlfcn.cpp. So if you do a build w/out that workaround for arm, you end
up with a build failure:
bionic/linker/dlfcn.cpp:275:27: error: no member named 'old_name_' in 'soinfo'
strlcpy(__libdl_info->old_name_, __libdl_info->soname_, sizeof(__libdl_info->old_name_));
~~~~~~~~~~~~ ^
bionic/linker/dlfcn.cpp:275:82: error: no member named 'old_name_' in 'soinfo'
strlcpy(__libdl_info->old_name_, __libdl_info->soname_, sizeof(__libdl_info->old_name_));
~~~~~~~~~~~~ ^

Bug: 24425865
Change-Id: Idbe1cc1c28083afeee6d90203c221f30f661c69c
e5cfafe3446a33b0c77416061d598bf76d580ee0 17-Jul-2015 Dmitriy Ivanov <dimitry@google.com> Fix potential race condition on dlopen

Call to find_containing_library should be guarded.

Change-Id: I985a903da48b83bcd35e957a979158eb9b80e70b
0cdef7e7f3c6837b56a969120d9098463d1df8d8 07-Jul-2015 Evgenii Stepanov <eugenis@google.com> Respect caller DT_RUNPATH in dlopen().

When dlopen-ing a library, add the caller's DT_RUNPATH to the directory search
list. This fixes dlfcn.dt_runpath in bionic-unit-tests-glibc(32|64).

Bug: 21899363
Change-Id: Ife6a7e192939292cf4dc291b7e6b95945761cde3
7271caf93db6897cdbcfca169441045bb52de61b 29-Jun-2015 Dmitriy Ivanov <dimitry@google.com> Lock on dl_interate_phdr

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
(cherry picked from commit f7d5bf334dc4bc5b7399d4c8268e1b0bf676548f)
f7d5bf334dc4bc5b7399d4c8268e1b0bf676548f 29-Jun-2015 Dmitriy Ivanov <dimitry@google.com> Lock on dl_interate_phdr

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
1913352c6b3501893dfb45189754970f9dc6e7bb 03-Jun-2015 Dmitriy Ivanov <dimitry@google.com> Backward compatibility for dlsym(RTLD_DEFAULT, ...)

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
(cherry picked from commit 04f7e3e955ba7de5f449c995e667659319dc1cce)
04f7e3e955ba7de5f449c995e667659319dc1cce 03-Jun-2015 Dmitriy Ivanov <dimitry@google.com> Backward compatibility for dlsym(RTLD_DEFAULT, ...)

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
4a7c3af054fdb525c8e458434f57f20696f43e31 28-May-2015 Dmitriy Ivanov <dimitry@google.com> Work around incorrect dt_needed entries

This applies for apps targeting sdk<=22 and
only for lp32 platforms.

Bug: http://b/21364029
Change-Id: I903e81c9ccda2a8beaba1d132d68c77d30a4cdb2
(cherry picked from commit d974e8804689058714dc4fe9adcb57ee9a6996a8)
d974e8804689058714dc4fe9adcb57ee9a6996a8 28-May-2015 Dmitriy Ivanov <dimitry@google.com> Work around incorrect dt_needed entries

This applies for apps targeting sdk<=22 and
only for lp32 platforms.

Bug: http://b/21364029
Change-Id: I903e81c9ccda2a8beaba1d132d68c77d30a4cdb2
d8ead18145cba98fdc7256f9a0e69b8c1c90cd1c 22-May-2015 Dmitriy Ivanov <dimitry@google.com> Add functions to provide target sdk version

Bug: http://b/21364029
Change-Id: I8648d1bff6c8fd6e7cd12da7f128e048b9f2829a
(cherry picked from commit 79fd668bb4ddb22432eeda2ebd8d10359013d9a8)
79fd668bb4ddb22432eeda2ebd8d10359013d9a8 22-May-2015 Dmitriy Ivanov <dimitry@google.com> Add functions to provide target sdk version

Bug: http://b/21364029
Change-Id: I8648d1bff6c8fd6e7cd12da7f128e048b9f2829a
2a815361448d01b0f4e575f507ce31913214c536 09-Apr-2015 Dmitriy Ivanov <dimitry@google.com> Support symbol versioning

Bug: http://b/20139821
Change-Id: I64122a0fb0960c20b2ce614161b7ab048456b681
aae859cc3ca127d890e853cbf12b731e05624a22 31-Mar-2015 Dmitriy Ivanov <dimitry@google.com> Add realpath for soinfo

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
76ac1acdacc045cf1e56504e011dca68137dcd61 01-Apr-2015 Dmitriy Ivanov <dimitry@google.com> Look into local group on dlsym with RTLD_DEFAULT

Fix dlsym to look into local group when called with
RTLD_DEFAULT and RTLD_NEXT.

Bug: 17512583
Change-Id: I541354e89539c712af2ea4ec751e546913027084
618f1a36f8635fa0f2d60c621fbf79ead2c3f3de 18-Mar-2015 Dmitriy Ivanov <dimitry@google.com> Implement lookup by DT_SONAME

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
05fc1d7050d5451aea08dc5f504d2670287b2d43 29-Jan-2015 Elliott Hughes <enh@google.com> Add missing includes.

Change-Id: Ibf549266a19a67eb9158d341a69dddfb654be669
ab972b9adf8789a9e1b03129cd7f0c22e6bba117 29-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Count references for groups instead of instances

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
212e0e38248860b151b28877225629a988d95b58 02-Dec-2014 Elliott Hughes <enh@google.com> Build our benchmarks against glibc too.

Bug: 18556607
Change-Id: I455ac8b93c0835836180e549486bc52d393ee6a6
047b5934b5f1c62502fc9262ce634529c6cc1420 13-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Rename soinfo methods and fields

Change-Id: If68fbe287d3ad954238b1688f71013371f3f7fae
ec18ce06f2d007be40ad6f043058f5a4c7236573 10-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Add support for hash-style=gnu

Change-Id: I171434a587420895feac8a9b1ad2342087197568
68a555b57e2bed1292bf28609be693a95b5fdc6b 04-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Revert "Fix dlsym() to take into account RTLD_GLOBAL/LOCAL""

This reverts commit 9d3382d97a2cdc8c8f78c7825ece16f09292fc36.
9d3382d97a2cdc8c8f78c7825ece16f09292fc36 04-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Fix dlsym() to take into account RTLD_GLOBAL/LOCAL"

This reverts commit c85e82dde5c4b2accc50a9e17740b9005dfbae6a.

Bug: 18222321
Bug: 18211780
Change-Id: I32f4048bd5ea85dc8a3dfccce8cf141b241ab692
0f47d9c1ce3e75709f9d6ecb6b540bb518ee323a 30-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Fix unused DT entry warnings.

DT_STRSZ Implement strtab boundary checks
DT_FLAGS_1 Warn if flags other than DF_1_NOW|DF_1_GLOBAL are set

Bug: 17552334
Bug: 18186310

(cherry picked from commit 6cdeb5234d7f4523fe9d83974f265d80f10512a6)

Change-Id: I7ffc7bc600798308a77ad949a644949b64250ae2
b364d9538073716a256b37a790ff7bf3ddbb4f1b 16-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Remove has_DT_SYMBOLIC flag

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."

Bug: 18186310

(cherry picked from commit 8f61d991831f0ea515fa50a5c38dbbcfbab0dd28)

Change-Id: I37024799ac8d1837993c8ae78780a448bedd6539
c85e82dde5c4b2accc50a9e17740b9005dfbae6a 16-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Fix dlsym() to take into account RTLD_GLOBAL/LOCAL

Symbols from libraries opened with RTLD_LOCAL (default)
should not be visible via dlsym(RLTD_DEFAULT/RTLD_NEXT, .)

Bug: 17512583
Bug: 18186310

(cherry picked from commit e8ba50fe0d51fbefee1a8f5bb62bf51d841512c8)

Change-Id: Idf6bbe2233fb2bfc0c88677e7d1fc518fb3f7a8b
de01780f46e4e4540c7a1ea7d0302f460c880e9d 04-Oct-2014 Dmitriy Ivanov <dimitry@google.com> Add file_offset parameter to android_extinfo

Bug: 17762003

(cherry picked from commit 07e5bc152d8a3ad4c50808bb86f3c0f2c5e2f514)

Change-Id: I72d527831384ff5dde013a4c8dfe639fbec165f5
07e5bc152d8a3ad4c50808bb86f3c0f2c5e2f514 04-Oct-2014 Dmitriy Ivanov <dimitry@google.com> Add file_offset parameter to android_extinfo

Bug: 17762003
Change-Id: I8fb267a3155acef3dba534038cf5d1ef00d7154b
f4cb6313645ef65cc0eea0a439e51b6788cd3439 12-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Add IFUNC support for arm64 and IRELATIVE reloc

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

(cherry picked from commit 9aea164457c269c475592da36b4655d45f55c7bc)

Change-Id: Ie19d900fc203beb93faf8943b0d06d534a6de4ad
ae69a9584baf8dd6a28065538ca09d1924ebd9e4 06-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Load libraries in breadth-first order

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
Attempt: 2

(cherry picked from commit 14669a939d113214a4a20b9318fca0992d5453f0)

Change-Id: Id87540c96a2242220967b6fa5d84ddcd829e2b97
c0133a73b6f37b88afc8dafb6f63af03cbb708f6 05-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Load libraries in breadth-first order"

This reverts commit a3ad450a2e3fb6b3fe359683b247eba20896f646.

(cherry picked from commit 498eb18b82a425f9f30132e4832f327b2ee0e545)

Change-Id: Iec7eab83d0c0ed1604e1e8ea3f9e9d0ce1d29680
59c12a652794273da22907a374222f4fa7d975c6 29-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Load libraries in breadth-first order

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

(cherry picked from commit a3ad450a2e3fb6b3fe359683b247eba20896f646)

Change-Id: I1125de10272c84e4f075cbc72859c1f6b3e89943
cfad7ae9346af5c665a1bc239e1bbe4f679750c6 29-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Replace NULL with nullptr

(cherry picked from commit 851135bf9941b3813adb9b4f43d76e040c4ba157)

Change-Id: Ic4997907680db7472ef38ffb0f0ca66fff37b797
3bbd218ef1a70e59662e704c59af6dff1f9d1253 22-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Bump soinfo version

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)

(cherry picked from commit 0d15094287fe0f288d9c258953143fc1998b6b5a)

Change-Id: Idf135fdd3d4826b5653f32add2adc6db5d4a4f95
6cdeb5234d7f4523fe9d83974f265d80f10512a6 30-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Fix unused DT entry warnings.

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
8f61d991831f0ea515fa50a5c38dbbcfbab0dd28 16-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Remove has_DT_SYMBOLIC flag

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
e8ba50fe0d51fbefee1a8f5bb62bf51d841512c8 16-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Fix dlsym() to take into account RTLD_GLOBAL/LOCAL

Symbols from libraries opened with RTLD_LOCAL (default)
should not be visible via dlsym(RLTD_DEFAULT/RTLD_NEXT, .)

Bug: 17512583
Change-Id: I1758943081a67cf3d49ba5808e061b8251a91964
9aea164457c269c475592da36b4655d45f55c7bc 12-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Add IFUNC support for arm64 and IRELATIVE reloc

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
14669a939d113214a4a20b9318fca0992d5453f0 06-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Load libraries in breadth-first order

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
498eb18b82a425f9f30132e4832f327b2ee0e545 05-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Load libraries in breadth-first order"

This reverts commit a3ad450a2e3fb6b3fe359683b247eba20896f646.

Change-Id: Ia2b838ad2159c643b80c514849582f4b4f4f40e5
a3ad450a2e3fb6b3fe359683b247eba20896f646 29-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Load libraries in breadth-first order

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
851135bf9941b3813adb9b4f43d76e040c4ba157 29-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Replace NULL with nullptr

Change-Id: Iad50be617d318ca98883b843229c960ad5b9afa9
0d15094287fe0f288d9c258953143fc1998b6b5a 22-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Bump soinfo version

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
02aa70589d22fa9b65da43de705d6de2715870c6 19-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Add support for protected local symbol lookup."

This reverts commit d97e9f546ea195686a78e539315b273393609b9e.

Bug: 17107521
(cherry picked from commit 9419420919ea846bbad5510850c7aaec95021648)

Change-Id: I1a6df946ac8075699e77d68ffa6ac4a21b88e4bf
9419420919ea846bbad5510850c7aaec95021648 19-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Add support for protected local symbol lookup."

This reverts commit d97e9f546ea195686a78e539315b273393609b9e.

Bug: 17107521
Change-Id: I2b81ce2b5a4a2d166133a2626e49d81b6aef3672
db7a17d4ff56a05af01ee2fee1f3c55245bfc630 05-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Revert "Fix dlsym(3) to do breadth first search.""

This reverts commit 1b1966d9448e979d1503a3d8843708bfa8880dc6.

Change-Id: I05d6d3481aaf8f3e260d2e5e950248519a1d347f
1b1966d9448e979d1503a3d8843708bfa8880dc6 04-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Fix dlsym(3) to do breadth first search."

This reverts commit 422106a24d620af4be58e8d92a2e9b7b6167b72d.

Change-Id: I9e26a6933d10eb30438b521450f2010997ca5aee
422106a24d620af4be58e8d92a2e9b7b6167b72d 29-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Fix dlsym(3) to do breadth first search.

dlsym(3) with handle != RTLD_DEFAULT|RTLD_NEXT performs
breadth first search through the dependency tree.

Bug: 16653281

(cherry picked from commit aa0f2bdbc22d4b7aec5d3f8f5f01eaeaa13414c2)

Change-Id: I0ba8c2034ab341f8a279cdb4e2e7e47f1aef7897
aa0f2bdbc22d4b7aec5d3f8f5f01eaeaa13414c2 29-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Fix dlsym(3) to do breadth first search.

dlsym(3) with handle != RTLD_DEFAULT|RTLD_NEXT performs
breadth first search through the dependency tree.

Bug: 16653281
Change-Id: I017a6975d1a62abb0218a7eb59ae4deba458e324
d97e9f546ea195686a78e539315b273393609b9e 29-Jun-2014 Dmitriy Ivanov <dimitry@google.com> Add support for protected local symbol lookup.

Bug: http://code.google.com/p/android/issues/detail?id=66048
Change-Id: Ib334223df27adad9477fb241ab099c5e26df4a7d
ce44166c737b6737c3a0820bef10b074a5e36cf8 18-Jun-2014 Dmitriy Ivanov <dimitry@google.com> Fix weak function lookups

* Linker now correctly resolves function defined
with __attribute__((weak)).

Bug: https://code.google.com/p/android/issues/detail?id=70206
Change-Id: I82efb905676c25fefb1b11a13f5fecb0f1384657
acfc63760eef50cd451b80df8860d17bbab1ca33 17-Jun-2014 Colin Cross <ccross@android.com> Revert "HACK: linker: check for handle==0xffffffff on LP64"

This reverts commit 346fea0805b8c2a20171c9b4ab1aac5f66ede5de.

Change-Id: Id3fd79451e4218e68e39ce22f21408cbf93255ee
1a586293400d0e1d73e6eb82f7dfe9d2d9ed3c4b 04-Jun-2014 Elliott Hughes <enh@google.com> Remove an unused parameter from the dlopen implementation.

Change-Id: I9297913a743bb570b48ebbe594ff711a481e89e0
ca1c80220e9b16fde7a761ca1c2c63dbe8071e0f 22-May-2014 Dmitriy Ivanov <dimitry@google.com> Removed dlsym handle != NULL check for lp64

* 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
346fea0805b8c2a20171c9b4ab1aac5f66ede5de 21-May-2014 Colin Cross <ccross@android.com> HACK: linker: check for handle==0xffffffff on LP64

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
ddc7f830ce56197e5915276d597bc8a017104532 21-May-2014 Colin Cross <ccross@android.com> HACK: linker: check for handle==0xffffffff on LP64

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
b648a8a57ee42533a5bf127225a252f73ca2cbbc 20-May-2014 Dmitriy Ivanov <dimitry@google.com> Add RTLD_NOLOAD support and some related changes.

* 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
d59e50063ad708509f3ad83350be33f5612c4f54 09-May-2014 Dmitriy Ivanov <dimitry@google.com> Improve detection of already loaded libraries

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
1728b2396591853345507a063ed6075dfd251706 14-May-2014 Elliott Hughes <enh@google.com> Switch to g_ for globals.

That's what the Google style guide recommends, and we're starting
to get a mix.

Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
012cb4583a5f8564059142bb1900ea3a31e7cfa9 06-Feb-2014 Torne (Richard Coles) <torne@google.com> Add android_dlopen_ext() interface to linker.

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
faf05bacd45719291b371f24b1b89543881b37f6 12-Feb-2014 Elliott Hughes <enh@google.com> Clean up all the lint cpplint can find in the dynamic linker.

Change-Id: Ic9ee7153817c22a252cc4b309283e355b623cab9
9918665a45095ad135576f005c0e5307feb366a1 07-Feb-2014 Chris Dearman <chris.dearman@imgtec.com> [MIPS64] Dynamic linker

Change-Id: I937c7c776cae3d66e214798d5217a922cd106bfc
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
Signed-off-by: Duane Sand <duane.sand@imgtec.com>
0266ae5f884d72da58f33a072e865ba131234a5e 11-Feb-2014 Elliott Hughes <enh@google.com> Switch <elf.h> over to linux uapi under the covers.

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
d1973ca51325393f304e82a4d79874f33e54ac16 22-Jan-2014 Colin Cross <ccross@android.com> bionic: rename aarch64 target to arm64

Rename aarch64 build targets to arm64. The gcc toolchain is still
aarch64.

Change-Id: Ia92d8a50824e5329cf00fd6f4f92eae112b7f3a3
a4aafd156068ee174012f28cd894dbecf0e4ab90 14-Jan-2014 Elliott Hughes <enh@google.com> Make it possible for code to query the dynamic linker's default search path.

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
e365f9d6543bc6607864ef61257505239dde15d1 10-Oct-2013 Marcus Oakland <marcus.oakland@arm.com> AArch64: Linker64 support for AArch64

Addition of support for AArch64 in the linker64 target.

Change-Id: I8dfd9711278f6706063e91f626b6007ea7a3dd6e
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
e4d792adb8d6f9228b9ac9dc1ad7f43b271f085f 28-Oct-2013 Elliott Hughes <enh@google.com> Don't allow text relocations on 64-bit.

I've also updated our <sys/exec_elf.h> to match upstream.

Change-Id: I52f9fce3167541811208d273ff23ceaa112f7135
4eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5a 26-Oct-2013 Elliott Hughes <enh@google.com> Clean up linker architecture macros.

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
eb847bc8666842a3cfc9c06e8458ad1abebebaf0 10-Oct-2013 Elliott Hughes <enh@google.com> Fix x86_64 build, clean up intermediate libraries.

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
2a0b873065edb304fa2d1c54f8de663ea638b8ab 09-Oct-2013 Elliott Hughes <enh@google.com> Fix __errno for LP64 and clean up __get_tls.

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
afac15d686460267ff20ce4786b9a7c5796a1ea8 08-Oct-2013 Elliott Hughes <enh@google.com> Use C99 structure initializer designator style.

clang warns about using the GCC style of designator.

Change-Id: I86ec79f06c8774618082859f48d7d1f576520e32
c00f2cb587630d5e954c7f548749f1e3170b3cb1 05-Oct-2013 Elliott Hughes <enh@google.com> x86_64 linker.

Based on I8dc3e2cb596f75dc58ae82e4dc58f8c177dd3323 by
Pavel Chupin <pavel.v.chupin@intel.com>.

Change-Id: Icd582d277cbe273477b450f2848343d72c86ec9f
c620059479c47a78d57086d73726c9adc2f337ad 01-Oct-2013 Elliott Hughes <enh@google.com> Remove 32-bit assumptions from the ELF code.

Change-Id: I2c1f3d34c33685799aade8866eec44479ff9f963
24053a461e7a20f34002262c1bb122023134989d 20-Aug-2013 Christopher Ferris <cferris@google.com> Add the dl_iterate_phdr function to libdl for arm.

Bug: 8410085

Merge from internal master.

(cherry-picked from cb491bc66dc0abc145930b09086eb9189a30f6c2)

Change-Id: I94ed51bc5d4c626df7552c0e85c31ccee2d6568f
cb491bc66dc0abc145930b09086eb9189a30f6c2 20-Aug-2013 Christopher Ferris <cferris@google.com> Add the dl_iterate_phdr function to libdl for arm.

Bug: 8410085
Change-Id: I94ed51bc5d4c626df7552c0e85c31ccee2d6568f
ca0c11bd823f37f03cc8067cb182876827d5275a 12-Mar-2013 Elliott Hughes <enh@google.com> Use more types than just 'unsigned' in the linker.

Still chipping away at the situation where every variable in the
linker was of type 'unsigned'. This patch switches counts over to
being size_t and adds an explicit type for init/fini function pointers
and arrays of function pointers.

Also improve logging from CallArray.

Also remove trailing "\n"s from log messages.

Change-Id: Ie036d2622caac50f4d29f0570888bb527661d77e
650be4e584eeab3591b9e273bfd6d169eea60853 06-Mar-2013 Elliott Hughes <enh@google.com> More linker cleanup.

Change-Id: I9fb3c7c0d4b4ffef0eeaf092d4e30ffe63a08671
d4ee82dfa3ba01baa10e3ca48fcb31a27b8a4e81 01-Mar-2013 Brian Carlstrom <bdc@google.com> Minor linker cleanup, primarily to use Elf32_Dyn

Change-Id: Ifa9408e9859c6f79444715bed4808b7c13fdced5
cade4c36e7c9c62db3f476a0f9cfc329bac9acb7 20-Dec-2012 Elliott Hughes <enh@google.com> Support System.loadLibrary for libraries with transitive dependencies.

Also fix the FLAG_ERROR annoyance --- it's not helpful to cache failures.

Bug: 7896159
Bug: http://code.google.com/p/android/issues/detail?id=34416
Bug: http://code.google.com/p/android/issues/detail?id=22143
Change-Id: I60f235edb4ea4756e1f7ce56f7739f18e8a50789
e66190d2a97a713ae4b4786e60ca3d67ab8aa192 19-Dec-2012 Elliott Hughes <enh@google.com> Check for unknown flags passed to dlopen(3).

Change-Id: I56f4aab0e5a1487bc32d2c4d231e8bd15c4ac8da
d23736e4f228e46304b7cbc674a1d0094d73e0f5 01-Nov-2012 Elliott Hughes <enh@google.com> Keep the dynamic linker's soinfo pools mostly read-only.

We'll need a lot more refactoring of this code before we can reduce
the granularity, but this is a step forward.

Change-Id: I07061720e734b571a8399c1d5b4f2f35cd681307
5ae44f302b7d1d19f25c4c6f125e32dc369961d9 30-Aug-2012 Ard Biesheuvel <ard.biesheuvel@gmail.com> linker: handle R_ARM_COPY relocations in a proper way

If an executable contain copy relocations, other references
to the symbol it points to should be preempted and made to
point to the copy instead.

Also, the linker should make sure the target area has
sufficient space to contain the copy. It also checks
whether the library that supplies the symbol is built
with -Bsymbolic, and errors out if this is the case.

Change-Id: If135c83590092741cfd8f82f54816f363a4a4a3b
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
20aa6c0f4cbe6fdaba8938536a7b80270cfe7203 24-Oct-2012 Pavel Chupin <pavel.v.chupin@intel.com> Workaround g++ 4.7 compfail

error: C99 designator 'name' outside aggregate initializer

G++ 4.7+ can't handle some of C99 designated initializers.
Most likely it's just not implemented yet. Other possible workarounds is
to compile this as C not C++ or define name as char* instead of char[SIZE].

Appeared after this change https://android-review.googlesource.com/#/c/44470

Change-Id: Ib28157848ce759b8bb5dbb2ac0d9a768fa4e5107
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
5419b9474753d25dff947c7740532f86d130c0be 17-Oct-2012 Elliott Hughes <enh@google.com> Make dlerror(3) thread-safe.

I gave up trying to use the usual thread-local buffer idiom; calls to
calloc(3) and free(3) from any of the "dl" functions -- which live in
the dynamic linker -- end up resolving to the dynamic linker's stubs.
I tried to work around that, but was just making things more complicated.
This alternative costs us a well-known TLS slot (instead of the
dynamically-allocated TLS slot we'd have used otherwise, so no difference
there), plus an extra buffer inside every pthread_internal_t.

Bug: 5404023
Change-Id: Ie9614edd05b6d1eeaf7bf9172792d616c6361767
22d629211d72adaf46f3fc48f59540f8e5798b1e 12-Oct-2012 Elliott Hughes <enh@google.com> Make the dlfcn mutex static.

More style fixes too, and removal of yet another lingering SH reference!

Change-Id: Iebc34a46475dd11845ad172b9108bb6ddd7585bb
3b297c40794b23d50cb5240f9b03f6ef25fd98db 12-Oct-2012 Elliott Hughes <enh@google.com> Fix dlerror(3).

Add unit tests for dlerror(3) in various situations. I think We're at least
as good as glibc now.

Also factor out the ScopedPthreadMutexLock and use it here too.

Bug: http://code.google.com/p/android/issues/detail?id=38398
Change-Id: I040938b4366ab836e3df46d1d8055b92f4ea6ed8