Commit graph

16 commits

Author SHA1 Message Date
Evgenii Stepanov
acd6f4f9f5 Disable a few bionic tests under HWASan.
* HWASan report invalid use of the allocator api (like alignment not
being power of two, or allocation size too large) in a way tests do not
expect.
* Code in .preinit_array runs before HWASan shadow is initialized and
needs to be excluded from instrumentation.
* It looks that mm system calls (mmap/mprotect/etc) will not allow
tagged pointers. In fact, the use of mprotect on malloc()ed memory is
doubtful - one can imagine some kind of speculative load from such
memory, as compiler knows that it is addressable.

Bug: 114279110
Test: bionic-unit-tests with hwasan

Change-Id: I6ba4b46a0d554de77c923ad134cf156ce4ddba1b
2018-11-06 16:59:25 -08:00
Ryan Prichard
8f639a4096 Allow invoking the linker on an executable.
The executable can be inside a zip file using the same syntax used for
shared objects: path.zip!/libentry.so.

The linker currently requires an absolute path. This restriction could be
loosened, but it didn't seem important? If it allowed non-absolute paths,
we'd need to decide how to handle:
 - foo/bar      (relative to CWD?)
 - foo          (search PATH / LD_LIBRARY_PATH, or also relative to CWD?)
 - foo.zip!/bar (normalize_path() requires an absolute path)

The linker adjusts the argc/argv passed to main() and to constructor
functions to hide the initial linker argument, but doesn't adjust the auxv
vector or files like /proc/self/{exe,cmdline,auxv,stat}. Those files will
report that the kernel loaded the linker as an executable.

I think the linker_logger.cpp change guarding against (g_argv == NULL)
isn't actually necessary, but it seemed like a good idea given that I'm
delaying initialization of g_argv until after C++ constructors have run.

Bug: http://b/112050209
Test: bionic unit tests
Change-Id: I846faf98b16fd34218946f6167e8b451897debe5
2018-10-10 14:31:06 -07:00
Christopher Ferris
6d2c0bdf6e Move isolated test runner out of bionic.
Use a global gtest isolation runner rather than the custom one in
bionic.

Test: Ran all unit tests and verified same behavior before and after.

Change-Id: I24a7cf17cf8e018d0f51969c64b53ce9059cc779
2018-09-27 22:22:17 -07:00
dimitry
1280cf5fd8 Unhardcode /system/lib
Default search path may be different for native bridged enviroments

Bug: http://b/73105445
Test: adb shell /data/nativetest/arm/bionic-unit-tests/bionic-unit-tests --gtest_filter=dl.exec_with_ld_config_file
Change-Id: I09d32dcb8a7a3f161ccc6d58c29252e79ea5fd3e
2018-05-09 14:37:47 +02:00
Ryan Prichard
0044cd188e Fix race in ld.config.txt tests
The tests can run in parallel, and if they do, one test can truncate
ld.config.txt while another test is reading it (via the loader). Fix the
issue by using a TemporaryFile as the LD_CONFIG_FILE.

Test: adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests  --gtest_filter=dl.exec_with_ld_config_file:dl.exec_with_ld_config_file_with_ld_preload:dl.disable_ld_config_file --gtest_repeat=1000
Bug: b/77555708
Change-Id: I9763caa076ece30d1a0eb9c8892a310ac51543b6
(cherry picked from commit 6c3f97d236)
2018-04-04 16:10:37 -07:00
Jiyong Park
9828386bd4 Fix: dl#disable_ld_config_file
linker now quits with exit(1) instead of abort().
This is a leftover of
https://android-review.googlesource.com/c/platform/bionic/+/497893

Bug: 69635156
Test: run dl#disable_ld_config_file in a user build
Change-Id: If65c50805ffe89a601f4a9bfc1c6f0bb8dc16b77
2017-11-28 13:37:03 +09:00
dimitry
59d3062f51 Use ro.debuggable property instead of checking build type
Test: make
Change-Id: I094663c20721f345cd6684e06fcef38f300790be
2017-10-18 13:23:08 +02:00
Jiyong Park
41704cdf61 Don't run exec_with_ld_config_file* tests on non-production devices
The tests that use LD_CONFIG_FILE environment variable shouldn't be run
on non-production devices because LD_CONFIG_FILE is only for debuggable
builds. We have used the build-time flag USE_LD_CONFIG_FILE, which is
set for the debuggable builds, to conditionally include or exclude the
tests. However, this can be a problem when 1) the device is not
debuggable but 2) the CTS itself is built with debuggable target. So,
instead of relying on the build-time flag USE_LD_CONFIG_FILE, the tests
now check the debuggability of the device and skip the tests when it
isn't debuggable.

Bug: 65842135
Test: 1) flash user build image to a 2017 pixel device.
2) build cts with 'userdebug' build target
3) CtsBionicTestCases pass on the device

(cherrypick of 5e3d44100be32fd5efffd0c309bd90c04cc9620c.)

Change-Id: Ib88e3b26d093e5479d52cd87db47dee5e108cac2
2017-10-03 15:03:44 -07:00
dimitry
04f7a798cf Replace abort with exit(1) in __linker_cannot_link
Bug: http://b/67038409
Test: bionic-unit-tests
Change-Id: I7d39b44f2da8c5111ac8a9faf3416f19d5a35c05
2017-09-29 19:48:46 +02:00
Jiyong Park
4945d8f121 Don't run disable_ld_config_file test on non-production devices
The test always fails when run on non-production devices. Silence the
expected failure.

Bug: 64908138
Test: run CtsBionicTestCases on userdebug device. disable_ld_config_file
test does not fail.

Merged-In: Icd24a356dfbc62f540e3263070434a4fd065bfbc
Change-Id: Icd24a356dfbc62f540e3263070434a4fd065bfbc
(cherry picked from commit 157655dc67)
2017-08-31 01:42:55 +09:00
Jiyong Park
02586a2a34 linker: the global group is added to all built-in namespaces
With ld.config.txt, we now have multiple built-in namespaces other than
the default namespace. Libs (and their dependents) listed in LD_PRELOAD
must be visible to those additional namespaces as well.

This also adds a debugging only feature: path to the linker config file
can be customized via LD_CONFIG_FILE environment variable. This works
only for debuggable builds.

Bug: 38114603
Bug: 62815515
Test: 1. ./external/compiler-rt/lib/asan/scripts/asan_device_setup --lib
prebuilts/clang/host/linux-x86/clang-stable/lib64/clang/5.0/lib/linux
2. enable talkback shortcut
3. in the home screen, hold vol-up/down together
4. device does not reboots and talkback shortcut is toggled
Test: bionic-unit-tests and linker-unit-tests successful

Change-Id: I9a03591053f4a9caea82f0dcb23e7a3d324bb9bd
2017-08-03 01:02:07 +09:00
Elliott Hughes
eb04ed506f Fix x86 system calls made from ELF preinit.
Used by CFI, so broke cfi_test#early_init@x86, but I've added a specific
test for this (and a similar test for getauxval from preinit, which this
patch does not fix).

Bug: http://b/35885875
Test: ran tests
Change-Id: I43885bedfb88c0a26b4474bd3c27a87dec7bbc97
2017-03-29 13:48:02 -07:00
Dimitry Ivanov
2a6955e040 loader: set PT_INTERP to itself
Some versions of kernel set AT_BASE to 0
if dynamic loader does not have PT_INTERP
set.

Bug: http://b/30739481
Test: run /system/bin/linker64 and /system/bin/linker
Change-Id: I1b67777166fe917d3ee1a97277045ca6f5db0084
2017-02-24 16:56:38 -08:00
Dmitriy Ivanov
0416d88f9c Revert "Revert "Fix symbol lookup order during relocation""
This reverts commit f947be2889.
2014-11-04 09:38:18 -08:00
Dmitriy Ivanov
f947be2889 Revert "Fix symbol lookup order during relocation"
This reverts commit 976402cca1.

Bug: 18222321
Bug: 18211780
Change-Id: Iafdd3d843db7b1cf288be9a0232022816622c944
2014-11-03 22:15:08 -08:00
Dmitriy Ivanov
976402cca1 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 d225a5e652)

Change-Id: I4e889cdf2dfbf8230b0790053d311ee6b0d0ee2d
2014-10-31 17:10:30 -07:00