History log of /bionic/tests/dlfcn_test.cpp
Revision Date Author Comments
9dac3e9efdf6b00766b992940c831ca3881b48d5 28-Mar-2018 Ryan Prichard <rprichard@google.com> Break libdl.so and ld-android.so's dependency on libc.so.

* 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
(cherry picked from commit 470b66644b912ac3025ea30141f2f327bb879445)
45a93c13bfa15e8621010570bb98aaee8c5803fc 24-Mar-2018 Elliott Hughes <enh@google.com> Reject .so files using ELF TLS.

Bug: http://b/74361956
Test: ran tests

(cherry picked from commit 9724e93c196d0dbaa0e60bf45c29971a22da50c9)

Change-Id: I287c926951c337aacd2246940a1e6474e4c661e1
9076b0c4e78e8680ce40ce48321e8ab81a87705b 28-Feb-2018 Elliott Hughes <enh@google.com> Be clearer about linker warnings.

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
153168c855962082d23b3124286005f90ccb39f8 20-Feb-2018 dimitry <dimitry@google.com> Fix RTLD_NEXT/DEFAULT lookup

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
da1bb113408030cebd1b7f2ce4b10b0e1852666d 16-Feb-2018 Elliott Hughes <enh@google.com> The VDSO soname varies by architecture.

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
e41eb5380d4447f35fa12bf913fe9a71b024e69f 19-Jan-2018 Ian Pedowitz <ijpedowitz@google.com> Fixing app compat issue b/72143978

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
(cherry picked from commit b6310c2aa704bd30990f4e3152e494b5290972b2)

Change-Id: I5b22776b4aa795ca5e76acde4d4fc1da4c2e8571
b6310c2aa704bd30990f4e3152e494b5290972b2 19-Jan-2018 Ian Pedowitz <ijpedowitz@google.com> Fixing app compat issue b/72143978

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
a4a485454a3a117eccdca1113681f770d765d865 13-Jan-2018 Elliott Hughes <enh@google.com> Remove a test for backwards compatibility we no longer support.

Bug: http://b/24465209
Test: ran tests
Change-Id: I80bb86379f108d88a6f4abb031450d13ac87c7b9
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
109040c868230d2f37c2f3964c6b62f63ff30c6c 03-Nov-2017 dimitry <dimitry@google.com> Add test checking library unload on dlclose

Bug: http://b/68262627
Test: Run bionic-unit-tests --gtest_filter=dl*:Dl*
Change-Id: Ied85bc4ab37524cfcdbc33fd6c6e69b8d87ee08a
527229cb72121dbd09e40369f67d2cf636d3bf03 02-Nov-2017 Raj Mamadgi <r.mamadgi@samsung.com> Fix for dlfcn.rtld_next_from_library.

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>
01162f24696aedd0f80fde006596bec7786ac684 16-Oct-2017 Jiyong Park <jiyong@google.com> Fix: linker segfault on dlopen of a DF_1_GLOBAL so

Added the missing null check routine.

Bug: 67755729
Test: dlfcn.dlopen_df_1_global added and it passes
Change-Id: Ibe8db18b0b5a481e2e9937041abef6d6b179dd87
b9555a9251467bc2d0b05a4e2f011531c1d3bd4a 11-Oct-2017 dimitry <dimitry@google.com> Fix dlopen_vdso test

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
c18de1bd47a558c9a24c6a4645df27df2c4738b4 26-Sep-2017 dimitry <dimitry@google.com> Link vdso before linking the main executable

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
db6ab3d5ecfe9934cb91a09bc4ccdbf2d15b49fc 27-Jun-2017 Dimitry Ivanov <dimitry@google.com> Enable dlfcn.dt_runpath_absolute_path in glibc tests

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
8ad40936597c94901b6acb0b21bfe0e2a0689224 16-Jun-2017 Elliott Hughes <enh@google.com> Add #defines for some key enums.

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
c42b4bb097c6a89bd9016bcbeed08a436d591d27 03-May-2017 Dimitry Ivanov <dimitry@google.com> Remove known failures from arm ifunc tests

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
21975b2861d859fb580ddfba50d323740486b7bc 03-May-2017 Dimitry Ivanov <dimitry@google.com> Add ifunc for variable test-case

Also move ifunc tests to clang and c++.

Test: bionic-unit-tests --gtest_filter=dlfcn.ifunc*
Change-Id: I008c4fc01470c8e4d314003c03a2b63ff9bf7fd8
98f016f4c1b9cbec76f80c802bd5594bec76263e 06-Apr-2017 Tom Cherry <tomcherry@google.com> Move scopeguard into android::base

Test: boot bullhead, bionic unit tests
Change-Id: I223249684867655ecb53713b10da41d3014f96ae
b8ab61804cec48e4ca585f4508fb1b7c6c5a04c5 06-Apr-2017 Tom Cherry <tomcherry@google.com> Move scopeguard into android::base

Test: boot bullhead, bionic unit tests
Change-Id: I223249684867655ecb53713b10da41d3014f96ae
fc32dcb128efe35442830e2dcfa378f1d50fef1c 24-Mar-2017 Dimitry Ivanov <dimitry@google.com> Disable compat_elf_hash_and_relocation_tables test for x86

Bug: http://b/36571076
Test: run bionic-unit-tests on fugu
Change-Id: I2f901bc99e55f15b06fe6a5b0d7a125d1b8241a8
35c8e3b1251af62897a9babd693e2b1be5676160 27-Feb-2017 Dimitry Ivanov <dimitry@google.com> Fix greylist exception to account for linked namespaces

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
ec90e24d33837e107b45e7c98b2f5fb4bc115a5e 10-Feb-2017 Dimitry Ivanov <dimitry@google.com> loader: fix d-tor call order

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
ea8f396c59f824993044d9474c2dc04423003c59 09-Feb-2017 Dimitry Ivanov <dimitry@google.com> Add test checking init/fini call order

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
14b9d7199c1b147ef6ce6e522ff14413930d2127 25-Jan-2017 Victor Khimenko <khim@google.com> Fix bionic-unit-tests in arch with binary translator

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
01c888c857f6f19837c5db581be83cc06f13fa1c 23-Jan-2017 Dimitry Ivanov <dimitry@google.com> Mark ifunc tests failing on arm as known failures

Bug: http://b/27930475
Test: run bionic-unit-tests on arm and arm64
Change-Id: I5084b6a5ef4b56ca9985da63a5e6896f771810f0
d5b578ac15330d7a872c198427628b723e0cc1cb 15-Dec-2016 Dimitry Ivanov <dimitry@google.com> Add test for empty symbol lookup

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
ac4bd2f79316e8ee79e9a69463e5d12d0f792aad 21-Nov-2016 Dimitry Ivanov <dimitry@google.com> Add test for elf-hash and packed relocations

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
d0b5c3ad65accd2c0298edbdfd527ede63e68ba1 25-Nov-2016 Dimitry Ivanov <dimitry@google.com> Fix bionic-unit-tests-glibc

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
c7365eb2fa996e72c5ea7f4e20222d6b48b9c6e0 17-Nov-2016 Dimitry Ivanov <dimitry@google.com> Improve dlerror_concurrent test

Add a test to check if result is thread-local, not only buffer.

Test: run bionic-unit-tests
Change-Id: Ia95f88c0d76aa86f7f439836393abd67a57dd396
816676e70da0e00761b0d23f512ea3571211b3ae 19-Oct-2016 Dimitry Ivanov <dimitry@google.com> Add test for libraries with textrels

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
927877c7d3173c1259732e51428f4ae38dc6bc4f 21-Sep-2016 Dimitry Ivanov <dimitry@google.com> bionic-unit-tests: remove dependency on ANDROID_DATA

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
708589f5e8244a17d690848eed5f0fbfcce48a26 19-Sep-2016 Dimitry Ivanov <dimitry@google.com> bionic-unit-tests: Create symlinks in runtime

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
a36e59bb9973aaae2e3487e0bfadd1f79814097e 01-Sep-2016 Dimitry Ivanov <dimitry@google.com> Move test libraries under /data/nativetests

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
44a654446e77549a0e988778ea0b738c4790e156 16-Aug-2016 Nikola Veljkovic <Nikola.Veljkovic@imgtec.com> [mips] Add missing linker shdr tests

Test: bionic-unit-tests for mips, mips64.
Change-Id: I8ed5f03df8d129e74fa04be2b203bd113a381888
559583469cd6425cdf3f63bcfc453d7d885ce131 15-Aug-2016 Dimitry Ivanov <dimitry@google.com> linker: add test for zeroed out shdr_table_

Bug: http://b/30795430
Change-Id: I86b658d01b64670d3e702ddb1d3f9db4f75d784f
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
46230445172d3cd72c38102d57f5a1b725c80367 15-Aug-2016 Dimitry Ivanov <dimitry@google.com> linker: add test for zero shdr offset

Bug: http://b/30795430
Change-Id: I03853257c4b632ad9daaf1e90f9620678397cff0
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
293d5132d0a48a699efa6b1675eb3e2f73dd04da 15-Aug-2016 Lazar Trsic <Lazar.Trsic@imgtec.com> [MIPS] Fix bionic test build

Group of libtest_invalid* libraries does not exists for mips architecture,
so disable relevant tests.

Change-Id: I3a4fef94933eb33654c4274aa249ea5d61d6cf9b
8bdf70e6e481d4ff0c1097f738d8e857a43c1b16 15-Aug-2016 Dimitry Ivanov <dimitry@google.com> linker: add test for empty shdr table

Bug: http://b/30795430
Change-Id: Id839c22f88276f31e0615bc2a67d75e27a9aa7c6
Test: run bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
c9a95613a95b1a275ff897594abb89786ae387ed 15-Aug-2016 Dimitry Ivanov <dimitry@google.com> linker: add test for zero shstrndx

Bug: http://b/30166532
Bug: http://b/30795430
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
Change-Id: I4cec73635cf403df9dd60b9a294d2298bb0abe3d
cb86c3128f5e59348d91f2edfa2de908d69cd384 13-Aug-2016 Dimitry Ivanov <dimitry@google.com> linker: add test for zero e_shentsize

Bug: http://b/30166532
Bug: http://b/30795430
Change-Id: I249c081563f0ca7bcc799d8445a53683616eaa4e
Test: run bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
972e3d0787cf177450cdc1b52e177c747b94caba 12-Aug-2016 Dimitry Ivanov <dimitry@google.com> Add test for misaligned section header

Make sure linker does not crash when dlopening
elf-file with odd section header offset.

Bug: http://b/30795430
Bug: http://b/30687964
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
Change-Id: If59cb6da85b8752a69dc5687de85f9a9b74c92b4
9700babc051f5839b4fc861587d63bf06bab6324 11-Aug-2016 Dimitry Ivanov <dimitry@google.com> linker: disallow W + E PT_LOAD segments

No mapped segment from the elf file can be writable and
executable at the same time. This commit adds a check
for malformed PT_LOAD segments in the elf-files.

Bug: http://b/30146890
Test: run bionic-unit-tests --gtest_filter=dlfcn.*
Change-Id: Ia23acbe5a48780b65d7e4a50bbe024cd528079f4
554374693408cd7c74d0cae596fca7349661edea 21-Jul-2016 Dimitry Ivanov <dimitry@google.com> Pass argc/argv/envp to dso constructors

The glibc implementation of the loader passes argc/argv/envp
to all elf constructors. This change makes bionic linker
behave in the same way.

Bug: http://b/30145768
Change-Id: I1c65c42aa5305a5b133c64b5748205bbde869e0e
Test: run bionic-unit-tests --gtest_filter=dl*:Dl*
dcaef3710df817db5652a1f3ab4646f43f5cd3ee 17-May-2016 Dimitry Ivanov <dimitry@google.com> Fix dlopen of main executable by absolute path

This CL adds initialization of inode for the main executable
which enables linker to resolve the correct soinfo when
application calls dlopen with absolute path to the
main executable.

Bug: http://b/28420266
Change-Id: I102e07bde454bd44c6e46075e3faeeb5092830d8
(cherry picked from commit 2ba1cf39ae6087249a839ec7b3793d4d4fa75438)
2ba1cf39ae6087249a839ec7b3793d4d4fa75438 17-May-2016 Dimitry Ivanov <dimitry@google.com> Fix dlopen of main executable by absolute path

This CL adds initialization of inode for the main executable
which enables linker to resolve the correct soinfo when
application calls dlopen with absolute path to the
main executable.

Bug: http://b/28420266
Change-Id: I102e07bde454bd44c6e46075e3faeeb5092830d8
ba35b2d1b91459568133c1f4729a6fff8359e3d9 08-Apr-2016 Dimitry Ivanov <dimitry@google.com> Add test for IRELATIVE resolution with RTLD_LAZY

Even though bionic linker does not support RTLD_LAZY - it
is good to know that its behavior matches glibc.

Bug: http://b/27930475
Change-Id: I1a47263aaa3dc44f9ac61fe77deb55a21e7f881a
0a2ab0203cc12c9b4b7647b18caf0343af8ca1a4 06-Apr-2016 Dimitry Ivanov <dimitry@google.com> Do not test ifunc on mips

This commit fixes mips build

Bug: http://b/28009632
Change-Id: I5c657b31947791aea4cc02a2fc4ede6d0ecde851
c967d892456ae8d578dfc75f241d9af04f31811f 31-Mar-2016 Dimitry Ivanov <dimitry@google.com> Enable ifunc test for arm

Bug: http://b/27930475
Change-Id: I1f9e7c5b9ffabfd77ae6ebd534938aef39ec7987
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
6f2d3104c82f81c1f0123a3cfb25ae670841d0ba 13-Oct-2015 Lazar Trsic <Lazar.Trsic@imgtec.com> Correctly resolve realpath for absolute paths

Introduced by: https://android-review.googlesource.com/174475

Change-Id: I44e00040b28be167d5141454f919340afec6084e
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
aff18fd60804e177c319d04dd4c12f3ee1c0cba8 23-Jun-2015 Dmitriy Ivanov <dimitry@google.com> Replace NULL with nullptr

Change-Id: If66d0c5ae1ea1ed371b44e067d4ae59ac54a8842
6865082ca6d887766c6651ed2d079dca56a99d32 10-Jun-2015 Evgenii Stepanov <eugenis@google.com> Support DT_RUNPATH in the linker.

Only $ORIGIN substitution is supported, but not linux-specific $LIB
or $PLATFORM.

Change-Id: I5814a016c7c91afba080230a547a863686e7c2b9
c4ebe60e1a2fc165ff11442765325628e27f2a05 30-May-2015 Dmitriy Ivanov <dimitry@google.com> Fix dlsym(handle_of_main_executable, ...)

According to man dlopen(3) and posix docs in the case when si is handle
of the main executable we need to search not only in the executable and its
dependencies but also in all libraries loaded with RTLD_GLOBAL.

see also: http://pubs.opengroup.org/onlinepubs/9699919799/functions/dlopen.html

Bug: http://b/21528224
Bug: http://b/17512583
Bug: https://code.google.com/p/android/issues/detail?id=173822
Change-Id: Ib2801367ba48b6f3704da89a6d9f5e6911430013
(cherry picked from commit f439b5a3186ca0fef1092f45770abc716da9d87a)
f439b5a3186ca0fef1092f45770abc716da9d87a 30-May-2015 Dmitriy Ivanov <dimitry@google.com> Fix dlsym(handle_of_main_executable, ...)

According to man dlopen(3) and posix docs in the case when si is handle
of the main executable we need to search not only in the executable and its
dependencies but also in all libraries loaded with RTLD_GLOBAL.

see also: http://pubs.opengroup.org/onlinepubs/9699919799/functions/dlopen.html

Bug: http://b/21528224
Bug: http://b/17512583
Bug: https://code.google.com/p/android/issues/detail?id=173822
Change-Id: Ib2801367ba48b6f3704da89a6d9f5e6911430013
4bac6ea463a8f20793f5c1425965729ded1419fe 12-May-2015 Dmitriy Ivanov <dimitry@google.com> Improved dlsym tests and fixes to linker

Answers the question: what if dependent library
was preloaded with RTLD_LOCAL flag.

Also add test for RTLD_NEXT within local_group.

Bug: http://b/17512583
Change-Id: I79e081e68b3a8c0ed8980d4275a06515fea94ec9
(cherry picked from commit 697bd9fd38ab078a117ad9a5777cf286c467b9b9)
697bd9fd38ab078a117ad9a5777cf286c467b9b9 12-May-2015 Dmitriy Ivanov <dimitry@google.com> Improved dlsym tests and fixes to linker

Answers the question: what if dependent library
was preloaded with RTLD_LOCAL flag.

Also add test for RTLD_NEXT within local_group.

Bug: http://b/17512583
Change-Id: I79e081e68b3a8c0ed8980d4275a06515fea94ec9
6612d7a34768484eb002c07a1c7df1bd85c0997a 25-Apr-2015 Dmitriy Ivanov <dimitry@google.com> Enable dlsym_df_1_global test for arm/arm64

Change-Id: I1fdebced93175cb14053e2239e79f97239fc2dc2
2a815361448d01b0f4e575f507ce31913214c536 09-Apr-2015 Dmitriy Ivanov <dimitry@google.com> Support symbol versioning

Bug: http://b/20139821
Change-Id: I64122a0fb0960c20b2ce614161b7ab048456b681
ef25592f14d23ce6294ea103e9edf894779d141d 08-Apr-2015 Dmitriy Ivanov <dimitry@google.com> Fix dl* tests to run-on-host

Bug: http://b/20121152
Change-Id: I1e1f41d885c75dbb26f91565a53a15d62ef72ce6
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
52393a56335435efc605aff66aca3145873e1e56 19-Mar-2015 Dmitriy Ivanov <dimitry@google.com> Move open from zip tests to dlext

To avoid building them for glibc.

Also replace snprintf with std::string

Change-Id: I12e1d2e4ab46ff5af6c05453da67842e0d838fc5
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
aef719510a57274e73ca02ab5ecdc5bf17d3985c 16-Jan-2015 Simon Baldwin <simonb@google.com> Support loading shared libraries from zip files

Add code to support loading shared libraries directly from within
APK files.

Extends the linker's handling of LD_LIBRARY_PATH, DT_RUNPATH, etc
to allow elements to be either directories as normal, or ZIP
format files. For ZIP, the ZIP subdirectory string is separated
from the path to file by '!'.

For example, if DT_NEEDED is libchrome.so and Chrome.apk is the
Android ARM APK then the path element

/system/app/Chrome.apk!lib/armeabi-v7a

would cause the linker to load lib/armeabi-v7a/libchrome.so
directly from inside Chrome.apk. For loading to succeed,
libchrome.so must be 'stored' and not compressed in Chrome.apk,
and must be page aligned within the file.

Motivation:
Chromium tracking issue:
https://code.google.com/p/chromium/issues/detail?id=390618

Bug: 8076853
Change-Id: Ic49046600b1417eae3ee8f37ee98c8ac1ecc19e7
cb0443c0fa07e4c049f426e3041894df522732df 16-Mar-2015 Dmitriy Ivanov <dimitry@google.com> Remove obsolete test_isolated wrapper function

We already run all of our tests in isolated mode.

Change-Id: I8236baa302b1026a9b4a1c33a4aa65e223771bc7
279a22f96e639e76c801bdb39aee5576f2280fe0 23-Jan-2015 Dmitriy Ivanov <dimitry@google.com> Minimize calls to mprotect

Implement refcounter based data protection guard
to avoid unnecessary calls to mprotect when dlopen/dlclose
is called from a constructor.

Bug: 19124318
Big: 7941716
Change-Id: Id221b84ce75443094f99756dc9950b0a1dc87222
bfa88bca5ca387d6b3560074050856527cfc7514 16-Dec-2014 Dmitriy Ivanov <dimitry@google.com> Add another test for weak-reference

This one covers undefined weak reference in .so
referenced via JUMP_SLOT relocation.

Bug: 17526061
Change-Id: Ib8764bd30c1f686c4818ebbc6683cf42dee908b2
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
7699d13a74769fe8063fcca95588c87c571226c0 19-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Yet another relocation test

This time we check if a -> b -> c function in 'a' relocates against
implementation in 'c'.

Change-Id: I528180c3efd346bd447ea0237e5a8a0ac3cc031f
b3356773c6b5fbbbb26d22b3d6c6e0e598840e44 14-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Add test for --hash-style=sysv

With build system switched to gnu-hash we need
a test for sysv-hashed library.

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

Change-Id: I171434a587420895feac8a9b1ad2342087197568
ca564e2a994df5976869ec655c7d4056deefcaa2 04-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Revert "Fix arm64 and arm builds.""

This reverts commit 494bee796aa60131981308493e0e295493537e12.
0416d88f9c90dcb1b97947a27a7c05f3627484c4 04-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Revert "Fix symbol lookup order during relocation""

This reverts commit f947be2889639defc6424b1813ccc779528b7598.
c343cac62bfd2933e36357b206fdd81da7610164 04-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Revert "Fix relocation to look for symbols in local group""

This reverts commit 00dce525530c5d26c20750863f3e9890b468787a.
7ca96a075b778f1fa2ad265350879238cbcb4d09 04-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Revert "Add RTLD_NODELETE flag support""

This reverts commit 69c5d108a5cb44167a04d42ffdad6a39648ed235.
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
69c5d108a5cb44167a04d42ffdad6a39648ed235 04-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Add RTLD_NODELETE flag support"

This reverts commit c87f65d2cd0690d81665f8b241c1d763f72b6f80.

Bug: 18222321
Bug: 18211780
Change-Id: I00252e26a28a41ab9f1e2dd3b32f0f80d86297f1
00dce525530c5d26c20750863f3e9890b468787a 04-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Fix relocation to look for symbols in local group"

This reverts commit fd2747bb585fc51b5ad56db09c0e9b66c7091a92.

Bug: 18222321
Bug: 18211780
Change-Id: I2d4ebab1e73b7277161af76b99f8249825b22d65
f947be2889639defc6424b1813ccc779528b7598 04-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Fix symbol lookup order during relocation"

This reverts commit 976402cca13a1f4f3aa988fd301575e134ef5f2c.

Bug: 18222321
Bug: 18211780
Change-Id: Iafdd3d843db7b1cf288be9a0232022816622c944
494bee796aa60131981308493e0e295493537e12 04-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Fix arm64 and arm builds."

This reverts commit 445111a1c977e94a4233efd54f3690defa4a7582.

Bug: 18222321
Bug: 18211780
Change-Id: I4fa9e1b63ec9b528f8bfed73c2ec15046c43a2fe
445111a1c977e94a4233efd54f3690defa4a7582 01-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Fix arm64 and arm builds.

Bug: 18186310

(cherry picked from commit 4e446b19d8710cd2004785db4a00f18f249fe73f)

Change-Id: Ibc77a9ade36dc6b9bf5a316b5ab9ae5f0a70e826
4e446b19d8710cd2004785db4a00f18f249fe73f 01-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Fix arm64 and arm builds.

Change-Id: I2c8c41626768e792f27a2616f2cd5ae66606319d
976402cca13a1f4f3aa988fd301575e134ef5f2c 28-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Fix symbol lookup order during relocation

Relocate symbol against DF_1_GLOBAL shared libraries
loaded before this shared library. This includes
main executable, ld_preloads and other libraries
that have DF_1_GLOBAL flag set.

Bug: 2643900
Bug: 15432753
Bug: 18186310

(cherry picked from commit d225a5e65223b375a63548c4b780f04d8f3d7b60)

Change-Id: I4e889cdf2dfbf8230b0790053d311ee6b0d0ee2d
fd2747bb585fc51b5ad56db09c0e9b66c7091a92 21-Oct-2014 Dmitriy Ivanov <dimitry@google.com> Fix relocation to look for symbols in local group

The local group is a sequence of libraries in default (breadth-first)
order. It allows RTLD_LOCALLY loaded library to correctly relocate
symbols within its group (see test-cases).

Local group lookup is performed after main executable and ld_preloads.

Bug: 2643900
Bug: 15432753
Bug: 18186310

(cherry picked from commit cfa97f172dc1b10d650fefbb6ccffd88ce72a5fb)

Change-Id: I5fa8c673f929e4652c738912c7ae078d7ec286d2
382e06ce8eab506276aaad39da3fbd533ef898d2 31-Oct-2014 Dmitriy Ivanov <dimitry@google.com> Add dlfcn_test to glibc test suite.

Bug: 18186310

(cherry picked from commit eb27bbae8f0edc6b62ca2db73256c7fb53b9e9bf)

Change-Id: I1d608dfa12dbafbdcdb8bc6d818c5872404c19e0
c87f65d2cd0690d81665f8b241c1d763f72b6f80 20-May-2014 Dmitriy Ivanov <dimitry@google.com> Add RTLD_NODELETE flag support

Bug: 18186310
Bug: https://code.google.com/p/android/issues/detail?id=64069

(cherry picked from commit 1b20dafdbe65e43b9f4c95057e8482380833ea91)

Change-Id: Ic02eec22a7c322ece65eb40730a3404f611526b1
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
d225a5e65223b375a63548c4b780f04d8f3d7b60 28-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Fix symbol lookup order during relocation

Relocate symbol against DF_1_GLOBAL shared libraries
loaded before this shared library. This includes
main executable, ld_preloads and other libraries
that have DF_1_GLOBAL flag set.

Bug: 2643900
Bug: 15432753
Change-Id: Ia788748be59b739d1c7e62b978e7e255f9e65c7b
cfa97f172dc1b10d650fefbb6ccffd88ce72a5fb 21-Oct-2014 Dmitriy Ivanov <dimitry@google.com> Fix relocation to look for symbols in local group

The local group is a sequence of libraries in default (breadth-first)
order. It allows RTLD_LOCALLY loaded library to correctly relocate
symbols within its group (see test-cases).

Local group lookup is performed after main executable and ld_preloads.

Bug: 2643900
Bug: 15432753
Change-Id: I9bb013b46d17dbb5cbdfb8fef26f552748385541
145372b1bced73595d51405bcbda73cd092e2425 02-Oct-2014 Dmitriy Ivanov <dimitry@google.com> Revert "L-MR1 specific fixes"

This reverts commit 1cd0c6777f35b531c9ce78397d0915aa521b3e87.
1cd0c6777f35b531c9ce78397d0915aa521b3e87 02-Oct-2014 Dmitriy Ivanov <dimitry@google.com> L-MR1 specific fixes

Reset soinfo version to 0.
Disable ifunc test for arm64 because of old toolchain
in lmp-mr1-dev branch

Note: this commit should be reverted in -plus-aosp branch.

Change-Id: I2d6d996d43bc35d5d4975c745779f43a988b31e6
7d971ec14b80cac442aeea8d88e9eb2e3ab6f214 09-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Fix unload of recursively linked library

Expanded test for recursive libs. Fixed bug with unnecessary
soinfo_free of already loaded library.

(cherry picked from commit a6ac54a215d6b64f5cc5a59b66c1dbfbb41ea9f5)

Change-Id: I6907c723d9fbdf6b2777f3f236b1e29b0843edd6
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
ef1306d77718cc74a8df5673a15649dea317571d 09-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Refactoring: C++11 style DISABLE_ bionic marcos

Enable the -std=gnu++11 flag for libstdc++ static and
dynamic libs.

ScopeGuard uses DISABLE_ macros instead of '= delete';

(cherry picked from commit d9ff7226613014056c9edd79a68dc5af939107a0)

Change-Id: If2573d080770e18b36b56106f2369f7bb682cd3c
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
8de1ddece0d0b85eafeb86c06cf3a734dadf2b55 05-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Fix order of soinfo links (repairs libcxx tests).

(cherry picked from commit b2a30ee8d209154efc367db11b4167a5d6db605f)

Change-Id: I59c5333bc050cbbea14051cea9220be2f64ee383
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
bd321c1106ed30a71d55d5c365335dfe552b0883 21-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Run constructors before resolving ifunc functions

Bug: 17177284

(cherry picked from commit 9598b8c415e2fa9f240508185fe8c964b83f538d)

Change-Id: I2c9631ee1cd77f8cf95ec0216a35b605c8786454
31b88da8431096a6df276705046ca7a012fa3530 23-Jul-2014 Brigid Smith <brigidsmith@google.com> Added test for ifunc support in dynamic linker.

ifuncs now work in i386 and x86_64 when called in the same library as
well as in a different library.

Bug:6657325
(cherry picked from commit c5a13efa9bc4264be0a9a9e37c00633af01584ed)

Change-Id: I321d780bc2f9bd1baa749e1acacd2683aefe827b
1b20dafdbe65e43b9f4c95057e8482380833ea91 20-May-2014 Dmitriy Ivanov <dimitry@google.com> Add RTLD_NODELETE flag support

Bug: https://code.google.com/p/android/issues/detail?id=64069
Change-Id: Ie5f90482feae86391172be4b32d6cb7d76f446fb
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
eb27bbae8f0edc6b62ca2db73256c7fb53b9e9bf 15-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Add dlfcn_test to glibc test suite.

Change-Id: I955e4f7dfcc23ea5c767f967b3532dc31663b876
a6ac54a215d6b64f5cc5a59b66c1dbfbb41ea9f5 09-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Fix unload of recursively linked library

Expanded test for recursive libs. Fixed bug with unnecessary
soinfo_free of already loaded library.

Change-Id: I2cc19f2650c8b12a35feeac127ef608ebba44d88
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
d9ff7226613014056c9edd79a68dc5af939107a0 09-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Refactoring: C++11 style DISABLE_ bionic marcos

Enable the -std=gnu++11 flag for libstdc++ static and
dynamic libs.

ScopeGuard uses DISABLE_ macros instead of '= delete';

Change-Id: I07e21b306f95fffd49345f7fa136cfdac61e0225
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
b2a30ee8d209154efc367db11b4167a5d6db605f 05-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Fix order of soinfo links (repairs libcxx tests).

Change-Id: Iee9de09657351cd6a7512784ca797e4b84cdd98b
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
319356e39cc91b4eb94b1974756f1cfc0a137351 03-Sep-2014 Dmitriy Ivanov <dimitry@google.com> Add some missing dlclose(.)

Bug: 17358010
Change-Id: I9e427b7681f1a8fe890b0b47812d9e65ab95c792
642182341018b282148280a7bdb771493e15bd7d 26-Aug-2014 Elliott Hughes <enh@google.com> Fix pthread_getattr_np for the main thread.

On most architectures the kernel subtracts a random offset to the stack
pointer in create_elf_tables by calling arch_align_stack before writing
the auxval table and so on. On all but x86 this doesn't cause a problem
because the random offset is less than a page, but on x86 it's up to two
pages. This means that our old technique of rounding the stack pointer
doesn't work. (Our old implementation of that technique was wrong too.)

It's also incorrect to assume that the main thread's stack base and size
are constant. Likewise to assume that the main thread has a guard page.
The main thread is not like other threads.

This patch switches to reading /proc/self/maps (and checking RLIMIT_STACK)
whenever we're asked.

Bug: 17111575
Signed-off-by: Fengwei Yin <fengwei.yin@intel.com>

(cherry picked from commit 57b7a6110e7e8b446fc23cce4765ff625ee0a105)

Change-Id: I87e679ee1c0db8092f2d1221c8e7c1461545c5a4
57b7a6110e7e8b446fc23cce4765ff625ee0a105 26-Aug-2014 Elliott Hughes <enh@google.com> Fix pthread_getattr_np for the main thread.

On most architectures the kernel subtracts a random offset to the stack
pointer in create_elf_tables by calling arch_align_stack before writing
the auxval table and so on. On all but x86 this doesn't cause a problem
because the random offset is less than a page, but on x86 it's up to two
pages. This means that our old technique of rounding the stack pointer
doesn't work. (Our old implementation of that technique was wrong too.)

It's also incorrect to assume that the main thread's stack base and size
are constant. Likewise to assume that the main thread has a guard page.
The main thread is not like other threads.

This patch switches to reading /proc/self/maps (and checking RLIMIT_STACK)
whenever we're asked.

Bug: 17111575
Signed-off-by: Fengwei Yin <fengwei.yin@intel.com>
Change-Id: I1d4dbffe7bc7bda1d353c3a295dbf68d29f63158
9598b8c415e2fa9f240508185fe8c964b83f538d 21-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Run constructors before resolving ifunc functions

Bug: 17177284
Change-Id: I5714b9bc2d1ca8f8711806bfb68da3d524213e99
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
c5a13efa9bc4264be0a9a9e37c00633af01584ed 23-Jul-2014 Brigid Smith <brigidsmith@google.com> Added test for ifunc support in dynamic linker.

ifuncs now work in i386 and x86_64 when called in the same library as
well as in a different library.

Bug:6657325
Change-Id: Ic0c48b1b0a76cb90f36c20c79f68294cc3fd44a1
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
f8846a45878faa9eb51fab3a2b347e9a36ecd250 09-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Add test for constructor function.

Change-Id: I0ad26d617f00cdd6c2241d613be39a1d16918612
d06ee1d6db6165126161044fb662301bf9f04b3a 02-Jul-2014 Elliott Hughes <enh@google.com> Build all bionic test files -Werror and fix our one warning.

Change-Id: I62bb0528fd1bcb9aa4c61e44c78158a592690fc7
ce0ba3c70634d5fe64b9a298d8a305d85bd1e6ac 02-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Disable local/protected symbol test for lp64

* Static linker optimizes protected local symbol
out of existence, which leads to test failure.
Disabling it for now.

Change-Id: I8de327e5073f98b64639f7a0bba3a273aa419884
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
44adf93b8eddb3a7965a3e9abc189408a1f5a7ea 22-May-2014 Dmitriy Ivanov <dimitry@google.com> Fix dlsym_failure NULL handle test

* RTLD_DEFAULT != (void*)0 only for bionic32

Change-Id: I3b3758835cf4085b0f899e2b62861591411aec13
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
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
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
063525c61d24776094d76971f33920e2a2079530 13-May-2014 Elliott Hughes <enh@google.com> Consistently use #if defined(__BIONIC__) in tests.

I've also switched some tests to be positive rather than negative,
because !defined is slightly harder to reason about and there are
only two cases: bionic and glibc.

Change-Id: I8d3ac40420ca5aead3e88c69cf293f267273c8ef
7db180919c335287b201e859faa8ee0dbe281cde 08-May-2014 Dmitriy Ivanov <dimitry@google.com> Test dlopen with symlinked .so files

Bug: 9741592
Change-Id: I68c59d6f4e690136395c3dc3de13f99ce38de528
2ed710976cb0ace31aab565c95a42d4e75623894 12-Nov-2013 Elliott Hughes <enh@google.com> Add extra regression tests for an already-fixed dynamic linker bug.

Bug: https://code.google.com/p/android/issues/detail?id=61799
Change-Id: I84af68f8430a06e999297c2e57e06ecb45adf81e
ebd506c69e12b6dcaf5be94cc8ed1b53af299f9f 31-Oct-2013 Sergey Melnikov <sergey.melnikov@intel.com> Fix linker crashes during unknown symbol lookup

Integration of kernel VDSO into internal bionic data structures using
common functions.
Fix for dl_iterate_phdr function: the function provides incorrect
address of object in case of nonzero virtual and base addresses.
Location in address space of a particular program header should be
calculated using the formula: addr = base_addr + virtual_addr.

Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com>
Change-Id: Ie2ab4257fd456242aab8afed0bd5bd6b29e81d6d
a43e906221a3e9c70a66118a8692cd46f77e144e 07-Jan-2013 Elliott Hughes <enh@google.com> Don't test GNU-style ELF hashes on MIPS.

The MIPS toolchain can't generate them because they're incompatible
with the MIPS ABI (which requires .dynsym match the GOT, while GNU-style
requires .dynsym to be sorted by hash code), so there's nothing to test.

Change-Id: I2220f452fe6fe595ec1312544cc741dd390a36a5
e66190d2a97a713ae4b4786e60ca3d67ab8aa192 19-Dec-2012 Elliott Hughes <enh@google.com> Check for unknown flags passed to dlopen(3).

Change-Id: I56f4aab0e5a1487bc32d2c4d231e8bd15c4ac8da