History log of /bionic/tests/dlfcn_test.cpp
Revision Date Author Comments
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)
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)
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