Commit graph

139 commits

Author SHA1 Message Date
Dimitry Ivanov
ea8f396c59 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
2017-02-09 14:07:05 -08:00
Victor Khimenko
14b9d7199c 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
2017-01-25 20:57:48 +01:00
Dimitry Ivanov
01c888c857 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
2017-01-23 14:52:07 -08:00
Dimitry Ivanov
59dd61573f Merge "Add test for elf-hash and packed relocations" 2016-12-15 18:27:22 +00:00
Dimitry Ivanov
d5b578ac15 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
2016-12-14 15:16:56 -08:00
Dimitry Ivanov
ac4bd2f793 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
2016-12-14 11:16:21 -08:00
Dimitry Ivanov
d0b5c3ad65 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
2016-11-28 13:09:19 -08:00
Dimitry Ivanov
c7365eb2fa 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
2016-11-17 14:23:24 -08:00
Dimitry Ivanov
816676e70d 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
2016-10-19 14:21:42 -07:00
Dimitry Ivanov
927877c7d3 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
2016-10-10 13:56:20 -07:00
Dimitry Ivanov
708589f5e8 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
2016-10-10 04:41:56 -07:00
Dimitry Ivanov
a36e59bb99 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
2016-09-02 14:27:47 -07:00
Nikola Veljkovic
44a654446e [mips] Add missing linker shdr tests
Test: bionic-unit-tests for mips, mips64.
Change-Id: I8ed5f03df8d129e74fa04be2b203bd113a381888
2016-08-16 18:52:06 +00:00
Treehugger Robot
3b2d331e77 Merge "linker: add test for zeroed out shdr_table_" 2016-08-15 23:23:26 +00:00
Treehugger Robot
4154b77285 Merge "linker: add test for zero shdr offset" 2016-08-15 22:01:30 +00:00
Dimitry Ivanov
559583469c linker: add test for zeroed out shdr_table_
Bug: http://b/30795430
Change-Id: I86b658d01b64670d3e702ddb1d3f9db4f75d784f
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
2016-08-15 14:06:04 -07:00
Treehugger Robot
63ccb1bdac Merge "[MIPS] Fix bionic test build" 2016-08-15 21:00:47 +00:00
Dimitry Ivanov
4623044517 linker: add test for zero shdr offset
Bug: http://b/30795430
Change-Id: I03853257c4b632ad9daaf1e90f9620678397cff0
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
2016-08-15 13:42:47 -07:00
Lazar Trsic
293d5132d0 [MIPS] Fix bionic test build
Group of libtest_invalid* libraries does not exists for mips architecture,
so disable relevant tests.

Change-Id: I3a4fef94933eb33654c4274aa249ea5d61d6cf9b
2016-08-15 12:48:20 -07:00
Dimitry Ivanov
8bdf70e6e4 linker: add test for empty shdr table
Bug: http://b/30795430
Change-Id: Id839c22f88276f31e0615bc2a67d75e27a9aa7c6
Test: run bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
2016-08-15 11:30:45 -07:00
Dimitry Ivanov
c9a95613a9 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
2016-08-15 10:29:50 -07:00
Dimitry Ivanov
cb86c3128f 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*
2016-08-12 15:28:42 -07:00
Dimitry Ivanov
972e3d0787 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
2016-08-12 14:48:15 -07:00
Dimitry Ivanov
9700babc05 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
2016-08-11 17:24:47 -07:00
Dimitry Ivanov
5543746934 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*
2016-07-20 16:10:19 -07:00
Dimitry Ivanov
2ba1cf39ae 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
2016-05-17 13:55:46 -07:00
Dimitry Ivanov
ba35b2d1b9 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
2016-04-08 11:50:42 -07:00
Dimitry Ivanov
0a2ab0203c Do not test ifunc on mips
This commit fixes mips build

Bug: http://b/28009632
Change-Id: I5c657b31947791aea4cc02a2fc4ede6d0ecde851
2016-04-05 17:37:45 -07:00
Dimitry Ivanov
c967d89245 Enable ifunc test for arm
Bug: http://b/27930475
Change-Id: I1f9e7c5b9ffabfd77ae6ebd534938aef39ec7987
2016-04-04 11:28:41 -07:00
Dimitry Ivanov
9cf99cbad8 linker: add dlvsym(3)
This changes implements dlvsym - dlsym for versioned symbols.

Bug: http://b/22865643
Change-Id: Ic90a60d512104261a1416c43f9100f0d88e3b46f
2015-12-16 15:24:13 -08:00
Dimitry Ivanov
4a2c5aa30c Move dlsym and dladdr implementation to linker.cpp
Bug: http://b/25716705
Bug: http://b/22865643
Change-Id: If22fc1eda219f676b5fcc06490f7901d21d1749c
2015-12-10 16:24:57 -08:00
Lazar Trsic
6f2d3104c8 Correctly resolve realpath for absolute paths
Introduced by: https://android-review.googlesource.com/174475

Change-Id: I44e00040b28be167d5141454f919340afec6084e
2015-10-13 10:57:41 -07:00
Evgenii Stepanov
0cdef7e7f3 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
2015-07-07 10:56:06 -07:00
Dmitriy Ivanov
aff18fd608 Replace NULL with nullptr
Change-Id: If66d0c5ae1ea1ed371b44e067d4ae59ac54a8842
2015-06-23 13:58:22 -07:00
Evgenii Stepanov
6865082ca6 Support DT_RUNPATH in the linker.
Only $ORIGIN substitution is supported, but not linux-specific $LIB
or $PLATFORM.

Change-Id: I5814a016c7c91afba080230a547a863686e7c2b9
2015-06-10 16:44:22 -07:00
Dmitriy Ivanov
f439b5a318 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
2015-06-01 14:33:43 -07:00
Dmitriy Ivanov
697bd9fd38 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
2015-05-12 13:46:40 -07:00
Dmitriy Ivanov
6612d7a347 Enable dlsym_df_1_global test for arm/arm64
Change-Id: I1fdebced93175cb14053e2239e79f97239fc2dc2
2015-04-24 16:26:03 -07:00
Dmitriy Ivanov
2a81536144 Support symbol versioning
Bug: http://b/20139821
Change-Id: I64122a0fb0960c20b2ce614161b7ab048456b681
2015-04-16 17:57:30 -07:00
Dmitriy Ivanov
ef25592f14 Fix dl* tests to run-on-host
Bug: http://b/20121152
Change-Id: I1e1f41d885c75dbb26f91565a53a15d62ef72ce6
2015-04-09 14:56:26 -07:00
Dmitriy Ivanov
aae859cc3c 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
2015-04-06 21:15:43 +00:00
Dmitriy Ivanov
76ac1acdac 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
2015-04-02 14:12:45 -07:00
Dmitriy Ivanov
52393a5633 Move open from zip tests to dlext
To avoid building them for glibc.

 Also replace snprintf with std::string

Change-Id: I12e1d2e4ab46ff5af6c05453da67842e0d838fc5
2015-03-18 22:50:01 -07:00
Dmitriy Ivanov
618f1a36f8 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
2015-03-18 18:14:30 -07:00
Simon Baldwin
aef719510a 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
2015-03-16 17:50:50 -07:00
Dmitriy Ivanov
cb0443c0fa Remove obsolete test_isolated wrapper function
We already run all of our tests in isolated mode.

Change-Id: I8236baa302b1026a9b4a1c33a4aa65e223771bc7
2015-03-16 14:20:57 -07:00
Dmitriy Ivanov
279a22f96e 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
2015-01-23 16:30:34 -08:00
Dmitriy Ivanov
bfa88bca5c Add another test for weak-reference
This one covers undefined weak reference in .so
  referenced via JUMP_SLOT relocation.

Bug: 17526061
Change-Id: Ib8764bd30c1f686c4818ebbc6683cf42dee908b2
2014-12-16 19:46:45 +00:00
Dmitriy Ivanov
ab972b9adf 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
2014-12-02 10:54:26 -08:00
Dmitriy Ivanov
7699d13a74 Yet another relocation test
This time we check if a -> b -> c function in 'a' relocates against
 implementation in 'c'.

Change-Id: I528180c3efd346bd447ea0237e5a8a0ac3cc031f
2014-11-19 10:39:05 -08:00
Dmitriy Ivanov
b3356773c6 Add test for --hash-style=sysv
With build system switched to gnu-hash we need
 a test for sysv-hashed library.

Change-Id: I34adc216fa79199aa46066cf13fcc1c1f2581f0e
2014-11-14 11:19:22 -08:00
Dmitriy Ivanov
ec18ce06f2 Add support for hash-style=gnu
Change-Id: I171434a587420895feac8a9b1ad2342087197568
2014-11-12 16:38:12 -08:00
Dmitriy Ivanov
4e446b19d8 Fix arm64 and arm builds.
Change-Id: I2c8c41626768e792f27a2616f2cd5ae66606319d
2014-10-31 17:27:02 -07:00
Dmitriy Ivanov
d225a5e652 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
2014-10-31 11:39:51 -07:00
Dmitriy Ivanov
cfa97f172d 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
2014-10-23 12:13:54 -07:00
Dmitriy Ivanov
1b20dafdbe Add RTLD_NODELETE flag support
Bug: https://code.google.com/p/android/issues/detail?id=64069
Change-Id: Ie5f90482feae86391172be4b32d6cb7d76f446fb
2014-10-01 11:09:37 -07:00
Dmitriy Ivanov
e8ba50fe0d 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
2014-09-15 17:39:48 -07:00
Dmitriy Ivanov
eb27bbae8f Add dlfcn_test to glibc test suite.
Change-Id: I955e4f7dfcc23ea5c767f967b3532dc31663b876
2014-09-15 15:03:15 -07:00
Dmitriy Ivanov
d74aa58035 Merge "Fix unload of recursively linked library" 2014-09-12 16:55:42 +00:00
Dmitriy Ivanov
66bbf1595c Merge "Refactoring: C++11 style DISABLE_ bionic marcos" 2014-09-12 16:50:05 +00:00
Dmitriy Ivanov
a6ac54a215 Fix unload of recursively linked library
Expanded test for recursive libs. Fixed bug with unnecessary
  soinfo_free of already loaded library.

Change-Id: I2cc19f2650c8b12a35feeac127ef608ebba44d88
2014-09-11 22:40:48 -07:00
Dmitriy Ivanov
9aea164457 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
2014-09-11 16:30:45 -07:00
Dmitriy Ivanov
d9ff722661 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
2014-09-08 17:51:31 -07:00
Dmitriy Ivanov
14669a939d 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
2014-09-08 13:02:50 -07:00
Dmitriy Ivanov
498eb18b82 Revert "Load libraries in breadth-first order"
This reverts commit a3ad450a2e.

Change-Id: Ia2b838ad2159c643b80c514849582f4b4f4f40e5
2014-09-05 16:27:54 -07:00
Dmitriy Ivanov
b2a30ee8d2 Fix order of soinfo links (repairs libcxx tests).
Change-Id: Iee9de09657351cd6a7512784ca797e4b84cdd98b
2014-09-05 16:01:47 -07:00
Dmitriy Ivanov
1737b15937 Merge "Load libraries in breadth-first order" 2014-09-04 00:59:23 +00:00
Dmitriy Ivanov
a3ad450a2e 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
2014-09-03 15:06:14 -07:00
Dmitriy Ivanov
319356e39c Add some missing dlclose(.)
Bug: 17358010
Change-Id: I9e427b7681f1a8fe890b0b47812d9e65ab95c792
2014-09-02 17:31:44 -07:00
Elliott Hughes
57b7a6110e 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
2014-08-26 10:36:38 -07:00
Dmitriy Ivanov
9598b8c415 Run constructors before resolving ifunc functions
Bug: 17177284
Change-Id: I5714b9bc2d1ca8f8711806bfb68da3d524213e99
2014-08-21 14:24:13 -07:00
Dmitriy Ivanov
02aa70589d Revert "Add support for protected local symbol lookup."
This reverts commit d97e9f546e.

Bug: 17107521
(cherry picked from commit 9419420919)

Change-Id: I1a6df946ac8075699e77d68ffa6ac4a21b88e4bf
2014-08-19 05:19:53 -07:00
Brigid Smith
c5a13efa9b 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
2014-08-08 11:29:35 -07:00
Dmitriy Ivanov
aa0f2bdbc2 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
2014-07-29 14:35:13 -07:00
Dmitriy Ivanov
f8846a4587 Add test for constructor function.
Change-Id: I0ad26d617f00cdd6c2241d613be39a1d16918612
2014-07-08 21:21:34 -07:00
Dmitriy Ivanov
ce0ba3c706 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
2014-07-01 19:13:01 -07:00
Elliott Hughes
d06ee1d6db Build all bionic test files -Werror and fix our one warning.
Change-Id: I62bb0528fd1bcb9aa4c61e44c78158a592690fc7
2014-07-01 17:17:46 -07:00
Dmitriy Ivanov
d97e9f546e Add support for protected local symbol lookup.
Bug: http://code.google.com/p/android/issues/detail?id=66048
Change-Id: Ib334223df27adad9477fb241ab099c5e26df4a7d
2014-07-01 10:25:54 -07:00
Dmitriy Ivanov
ce44166c73 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
2014-06-17 16:18:18 -07:00
Dmitriy Ivanov
44adf93b8e Fix dlsym_failure NULL handle test
* RTLD_DEFAULT != (void*)0 only for bionic32

Change-Id: I3b3758835cf4085b0f899e2b62861591411aec13
2014-05-22 10:06:32 -07:00
Dmitriy Ivanov
ca1c80220e 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
2014-05-21 22:42:24 -07:00
Dmitriy Ivanov
b648a8a57e 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
2014-05-20 12:02:24 -07:00
Elliott Hughes
1728b23965 Switch to g_ for globals.
That's what the Google style guide recommends, and we're starting
to get a mix.

Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
2014-05-14 10:02:03 -07:00
Elliott Hughes
063525c61d 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
2014-05-13 11:19:57 -07:00
Dmitriy Ivanov
7db180919c Test dlopen with symlinked .so files
Bug: 9741592
Change-Id: I68c59d6f4e690136395c3dc3de13f99ce38de528
2014-05-08 14:28:34 -07:00
Elliott Hughes
2ed710976c 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
2013-11-11 15:48:06 -08:00
Sergey Melnikov
ebd506c69e 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
2013-10-31 15:06:20 -07:00
Elliott Hughes
a43e906221 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
2013-01-07 14:44:36 -08:00
Elliott Hughes
e66190d2a9 Check for unknown flags passed to dlopen(3).
Change-Id: I56f4aab0e5a1487bc32d2c4d231e8bd15c4ac8da
2012-12-18 15:57:55 -08:00
Renamed from tests/dlopen_test.cpp (Browse further)