Commit graph

30575 commits

Author SHA1 Message Date
Dan Willemsen
4bcfe3c330 Convert more bionic tests to Android.bp
Bug: 122332847
Bug: 130734182
Test: mmm bionic/tests; same files installed before & after
Test: m cts; same files in cts before & after
Test: `objdump -x <files> | grep NEEDED` is identical
Test: `objdump -x <files> | grep RUNPATH` difference make sense
      (additional lib64 entries from soong, minimal reorder)
Test: treehugger
Change-Id: I6eea4c3f9c0040efeba64e2b47c7b573767cd386
2020-01-16 10:12:46 -08:00
Ryan Prichard
ac951d785e Merge "Add a linker relocation benchmark" 2020-01-16 00:57:07 +00:00
Christopher Ferris
5ad528917b Merge "Enable the scudo native allocator." 2020-01-15 19:50:35 +00:00
Steven Moreland
fee43f6e89 Merge "stack_protector_DeathTest: work w/ local reorder" 2020-01-15 16:49:05 +00:00
Jing Ji
be64282b8c Merge "libc: Add pidfd_open to common seccomp allowed list" 2020-01-15 06:25:34 +00:00
Christopher Ferris
b198958412 Enable the scudo native allocator.
This is attempt number two, all known failures and issues have
been fixed.

Bug: 137795072

Test: Built both svelte and non-svelte versions. Ran enormous numbers
Test: of performance testing.
Test: Ran scudo unit tests.
Test: Ran bionic unit tests.
Test: Ran libmemunreachable tests.
Test: Ran atest CtsRsBlasTestCases on cuttlefish instance.
Change-Id: Ib0c6ef38b63b7a1f39f4431ed8414afe3a92f9b5
2020-01-14 17:25:10 -08:00
Jing Ji
e986722e65 libc: Add pidfd_open to common seccomp allowed list
Apps could use this API to monitor the death of processes

Bug: 118991081
Test: manual
Change-Id: If38e0b6c57713a069706b59128b22a94f23a497c
2020-01-14 14:35:34 -08:00
Steven Moreland
06f39d36a4 stack_protector_DeathTest: work w/ local reorder
Before, the helper method for this test had two local variables:
    char buf[128];
    volatile char* p;

Then the test wrote zeros into the buffer and one past the buffer end.
This relied on the fact that the compiler constructed the stack frame
with 'p' first and then the buffer (and also optimized away the 'size'
variable).

However, some compiler options (namely -ftrivial-auto-var-init=pattern)
result in the stack frame being reordered so that 'p' is actually after
buf, and the test cannot pass.

Fixes: 132780819
Test: bionic-unit-tests-static (w/ w/o flag)
Change-Id: Icc87c02add211c2afb7c96ae22701ec27990364c
2020-01-14 14:11:16 -08:00
Ryan Prichard
41f19708c8 Add a linker relocation benchmark
The benchmark creates a set of DSOs that mimic the work involved in
loading the current version of libandroid_servers.so. The synthetic
benchmark has roughly the same number of libraries with roughly the same
relocations.

Currently, on a local aosp_walleye build that includes recent performance
improvements (including the Neon-based CL
I3983bca1dddc9241bb70290ad3651d895f046660), using the "performance"
governor, the benchmark reports these scores:

$ adb shell taskset 10 \
  /data/benchmarktest64/linker-reloc-bench/linker-reloc-bench \
  --benchmark_repetitions=20 --benchmark_display_aggregates_only=true
...
--------------------------------------------------------------------------------
Benchmark                                      Time             CPU   Iterations
--------------------------------------------------------------------------------
BM_linker_relocation/real_time_mean        70048 us          465 us           20
BM_linker_relocation/real_time_median      70091 us          466 us           20
BM_linker_relocation/real_time_stddev        329 us         8.29 us           20

$ adb shell taskset 10 \
  /data/benchmarktest/linker-reloc-bench/linker-reloc-bench \
  --benchmark_repetitions=20 --benchmark_display_aggregates_only=true
...
--------------------------------------------------------------------------------
Benchmark                                      Time             CPU   Iterations
--------------------------------------------------------------------------------
BM_linker_relocation/real_time_mean        83051 us          462 us           20
BM_linker_relocation/real_time_median      83069 us          464 us           20
BM_linker_relocation/real_time_stddev        184 us         8.91 us           20

Test: manual
Bug: none
Change-Id: I6dac66978f8666f95c76387093bda6be0151bfce
2020-01-14 13:12:56 -08:00
Ryan Prichard
7909f4c667 Merge "Optimize GNU hash linking for large inputs" 2020-01-14 19:11:59 +00:00
Elliott Hughes
26f583f046 Merge "Consistent <termios.h> behavior on all API levels." 2020-01-14 19:08:41 +00:00
Robert Sesek
2f21482f14 Merge "Revert "Move pipe, open, and getdents from the APP to COMMON seccomp whitelist."" 2020-01-14 16:59:18 +00:00
Peter Collingbourne
c7a9d88816 Merge "Let libmemunreachable use bionic_libc_platform_headers." 2020-01-14 00:37:44 +00:00
Ryan Prichard
339ecef22d Optimize GNU hash linking for large inputs
Symbol lookup is O(L) where L is the number of libraries to search (e.g.
in the global and local lookup groups). Factor out the per-DSO work into
soinfo_do_lookup_impl, and optimize for the situation where all the DSOs
are using DT_GNU_HASH (rather than SysV hashes).

To load a set of libraries, the loader first constructs an auxiliary list
of libraries (SymbolLookupList, containing SymbolLookupLib objects). The
SymbolLookupList is reused for each DSO in a load group. (-Bsymbolic is
accommodated by modifying the SymbolLookupLib at the front of the list.)
To search for a symbol, soinfo_do_lookup_impl has a small loop that first
scans a vector of GNU bloom filters looking for a possible match.

There was a slight improvement from templatizing soinfo_do_lookup_impl
and skipping the does-this-DSO-lack-GNU-hash check.

Rewrite the relocation processing loop to be faster. There are specialized
functions that handle the expected relocation types in normal relocation
sections and in PLT relocation sections.

This CL can reduce the initial link time of large programs by around
40-50% (e.g. audioserver, cameraserver, etc). On the linker relocation
benchmark (64-bit walleye), it reduces the time from 131.6ms to 71.9ms.

Bug: http://b/143577578 (incidentally fixed by this CL)
Test: bionic-unit-tests
Change-Id: If40a42fb6ff566570f7280b71d58f7fa290b9343
2020-01-13 13:29:25 -08:00
Robert Sesek
866387dc32 Revert "Move pipe, open, and getdents from the APP to COMMON seccomp whitelist."
This reverts commit 74cdb253ba.

Chromium (and thus WebView) no longer uses Breakpad for crash reporting,
so the old compat syscalls that were whitelisted for Breakpad can be
moved back to the APP list.

Test: `am start com.android.settings/.SettingsLicenseActivity`
Test: Get the pid of the sandboxed_process0 for the license viewer.
Test: Send the process SIGABRT and check logcat for Crashpad log
      messages.

Bug: 115557900
Change-Id: I877ebe6bfabec544e58723b2e9a2f84c9cbf0a57
2020-01-13 14:20:59 -05:00
Peter Collingbourne
6a363f7f41 Let libmemunreachable use bionic_libc_platform_headers.
Bug: 135772972
Change-Id: I2702abce849a46292dc467f9083f3b6816bfc5e6
2020-01-13 10:40:08 -08:00
Ryan Prichard
a04764bd28 Merge changes I578d36a1,Id17508ab,I385f312b
* changes:
  Create linker_log[_va_list] functions
  Validate defined versions in prelink_image
  Prelink each library only once
2020-01-10 22:21:15 +00:00
Tom Cherry
9c5c87ed05 Merge "Add liblog as a dependency where libbase is used." 2020-01-10 16:59:02 +00:00
Peter Collingbourne
6dfde988e3 Merge "Add an android_mallopt for controlling the heap tagging level." 2020-01-10 15:22:24 +00:00
Elliott Hughes
f39b0856fe Consistent <termios.h> behavior on all API levels.
Bug: https://issuetracker.google.com/146886722 (where the difference was noticed)
Bug: http://b/69816452 (most recent fixes)
Test: treehugger
Change-Id: I487399c44f63ba276ccde74bf0c4a01e4cd4f4bf
2020-01-09 16:42:15 -08:00
Peter Collingbourne
1e110fb717 Add an android_mallopt for controlling the heap tagging level.
This doesn't add any functionality for now, but there are
a couple of changes in flight that will want to add enumerators
to the mallopt, so let's give them a place to add them.

Bug: 135772972
Bug: 135754954
Change-Id: I6e810020f66070e844500c6fa99b703963365659
2020-01-09 16:39:10 -08:00
Tom Cherry
2f95d19a69 Add liblog as a dependency where libbase is used.
(Also fix issues found from bpfmt)

Bug: 119867234
Test: build
Change-Id: I16e93ad7c26dadfb625acbe514abe0c0084f84b6
2020-01-09 10:07:12 -08:00
Treehugger Robot
3779d6da40 Merge "Add /system_ext/bin to shell search path" 2020-01-08 03:43:18 +00:00
Logan Chien
932a83399a Merge changes from topic "update-clang-tools-6114689"
* changes:
  versioner: Add __VERSIONER_FORTIFY_INLINE
  versioner: Only enable annotation while running versioner
2020-01-08 02:32:17 +00:00
Elliott Hughes
d63a8c67fb Merge "Track library name change." 2020-01-08 00:51:20 +00:00
Elliott Hughes
4540db6fae Track library name change.
Test: treehugger
Change-Id: Ief93c2a18144ee2da134a4800e1965b91be7f32c
2020-01-07 13:48:44 -08:00
Elliott Hughes
55f681f0b3 Merge "Explicitly test printf %s with nullptr." 2020-01-07 21:11:20 +00:00
Ryan Prichard
cec75e3303 Merge "Do not add duplicate soinfos to g_default_namespace" 2020-01-07 20:18:14 +00:00
Elliott Hughes
094b33fbf0 Merge "Fix a few incorrect types in SYSCALLS.TXT." 2020-01-07 17:37:15 +00:00
Elliott Hughes
5dc31300ff Explicitly test printf %s with nullptr.
I haven't found a bug, but tests are good.

Bug: https://github.com/landley/toybox/issues/163
Change-Id: I57149800099abc699cc841b69a5a72aeac7c2bcc
2020-01-07 08:48:10 -08:00
Justin Yun
580d17d2ad Add /system_ext/bin to shell search path
/system_ext/bin has executable binaries. They must be in the shell
search path.

Bug: 134909174
Bug: 134359158
Test: check PATH in the adb shell
Change-Id: I997a2347fa85c444f2e335bede0d63b7703ba001
2020-01-07 20:39:52 +09:00
Logan Chien
d2b8149dda Merge "versioner: Add versioner_fortify_inline annotation" 2020-01-07 01:38:25 +00:00
Ryan Prichard
551565e87c Create linker_log[_va_list] functions
A later linker CL defines a function that needs to forward a printf format
and argument list to TRACE(), but there is no version of the TRACE macro
that works with a va_list. The CL also needs to check the verbosity level,
using a slow path if tracing is enabled, so define LINKER_VERBOSITY_xxx
macros.

Bug: none
Test: bionic unit tests
Change-Id: I578d36a12dc40f9a651956b4b09adc1a7c644e24
2020-01-06 16:06:37 -08:00
Ryan Prichard
0e12ccedd4 Validate defined versions in prelink_image
Validate the list of defined versions explicitly, during library
prelinking, rather than implicitly as part of constructing the
VersionTracker in soinfo::link_image.

Doing the validation upfront allows removing the symbol lookup failure
code paths, which only happen on a library with invalid version
information.

Helps on the walleye 64-bit linker relocation benchmark (146.2ms ->
131.6ms)

Bug: none
Test: bionic unit tests
Change-Id: Id17508aba3af2863909f0526897c4277419322b7
2020-01-06 16:06:37 -08:00
Elliott Hughes
51d158f38d Fix a few incorrect types in SYSCALLS.TXT.
Nothing that actually affected the generated code.

Test: treehugger
Change-Id: I14b3a5f4608d9f446beb1d039bc434a214632a6b
2020-01-06 14:29:06 -08:00
Logan Chien
7bc71075ea Merge "versioner: Add a built-in macro for conditional compilation" 2020-01-06 19:52:20 +00:00
Logan Chien
171cf7a66e Merge "versioner: Fix fortified sendto" 2020-01-06 18:50:46 +00:00
Ryan Prichard
ae320cde07 Prelink each library only once
Previously, during a find_libraries call that loaded a library, a
library was prelinked once for each DT_NEEDED reference to the library.

This CL has a negligible effect on the linker relocation benchmark
(146.9ms -> 146.2ms).

Bug: none
Test: bionic unit tests
Change-Id: I385f312b8acf8d35aa0af9722131fe367b5edd9b
2020-01-02 17:40:32 -08:00
Josh Gao
84d00460df Merge changes from topic "bionic_signal_platform_headers"
* changes:
  Move sigrtmin.h into platform headers.
  Move bionic_macros.h from private to platform.
2020-01-02 23:40:53 +00:00
Josh Gao
5074e7d28f Move sigrtmin.h into platform headers.
Test: mma
Change-Id: Ibc97ef96fe9e32b948c245b06039b95fe4342f39
2020-01-02 14:14:15 -08:00
Josh Gao
4956c372cf Move bionic_macros.h from private to platform.
Test: treehugger
Change-Id: Ie473914f4c8924c7240b3ac22093a9daf42fc948
2020-01-02 14:09:50 -08:00
NIEJuhu
e2871bd0d8 Do not add duplicate soinfos to g_default_namespace
The soinfo instances of linker and vdso have been added to g_default_namespace
before init_default_namespace() is called. So init_default_namespace() don't
have to add them a second time.

Test: manual
Change-Id: I29b3da782b1e9445509f45a7698561fc3e19e9a1
2019-12-27 11:32:29 +08:00
Logan Chien
e592dacfa2 Merge "versioner: Update libc.map.txt to match annotations" 2019-12-23 17:21:26 +00:00
Logan Chien
5a750f3cf7 versioner: Add __VERSIONER_FORTIFY_INLINE
This commit adds `__VERSIONER_FORTIFY_INLINE` to fortify overload
functions.  Fortified functions are always overloaded and are likely to
be different from `libc.map.txt`.

Bug: 118991081
Test: source development/vndk/tools/header-checker/android/envsetup.sh && \
      source build/envsetup.sh && \
      lunch aosp_arm64-userdebug && \
      m versioner && \
      ./bionic/tools/versioner/run_tests.py
Change-Id: I28903d0f039d74a07eb2833c754ff017335bac95
2019-12-23 07:22:48 -08:00
Logan Chien
c88331b062 versioner: Add versioner_fortify_inline annotation
This commit adds versioner_fortify_inline annotation.  This annotation
indicates that the annotated function is an overloaded inline function
for _FORTIFY_SOURCE implementation.  They are usually enabled/disabled
by the enable_if attribute, thus the versioner don't have to check
whether they have conflicting definitions.

Bug: 118991081
Test: source development/vndk/tools/header-checker/android/envsetup.sh && \
      source build/envsetup.sh && \
      lunch aosp_arm64-userdebug && \
      m versioner && \
      ./bionic/tools/versioner/run_tests.py
Change-Id: If5c739fc0c8a218907855939c1fe5338134da7f7
2019-12-23 07:22:48 -08:00
Logan Chien
d7d9ebca37 versioner: Only enable annotation while running versioner
Bug: 118991081
Test: source development/vndk/tools/header-checker/android/envsetup.sh && \
      source build/envsetup.sh && \
      lunch aosp_arm64-userdebug && \
      m versioner && \
      ./bionic/tools/versioner/run_tests.py
Change-Id: Id6cc776f8ea27bf7230c7a63dd75445a99e5ba58
2019-12-23 07:22:48 -08:00
Logan Chien
a6bf7f2ee3 versioner: Add a built-in macro for conditional compilation
This commit adds a built-in macro for conditional compilation because
__attribute__((annotate(...))) may pull unused static inline functions
into object files.

We must not generate those functions in object files because it can
result in undefined references to __strchr_chk on linux_glibc.

Bug: 118991081
Test: source development/vndk/tools/header-checker/android/envsetup.sh && \
      source build/envsetup.sh && \
      lunch aosp_arm64-userdebug && \
      m versioner && \
      ./bionic/tools/versioner/run_tests.py
Change-Id: I0c9d967413ec8e8655e91316973a79b81e2129b1
2019-12-23 07:14:05 -08:00
Logan Chien
d98dac41df versioner: Fix fortified sendto
This commit fixes an error in fortified `sendto` function.  Since
`__sendto_chk` is only introduced in API 26, the usage should be guarded
with `__ANDROID__API__ >= 26` instead of
`__ANDROID_API__ >= __ANDROID_API_N_MR1__` (25).

Bug: 118991081
Test: source development/vndk/tools/header-checker/android/envsetup.sh && \
      source build/envsetup.sh && \
      lunch aosp_arm64-userdebug && \
      m versioner && \
      ./bionic/tools/versioner/run_tests.py
Change-Id: Ibc08244645c3fe76a72d0107138f67ffd56f5caa
2019-12-23 07:14:05 -08:00
Logan Chien
aaffa3c6d4 versioner: Update libc.map.txt to match annotations
This commit removes several symbol versions (API 14 and 15) from
`libc.map.txt` because we no longer support NDK with those API levels.
This also matches the versioner annotations in the header files.

This commit also annotates twalk() with __INTRODUCED_IN(21).  It was
accidentally removed in aosp/1157510.

Test: source development/vndk/tools/header-checker/android/envsetup.sh && \
      source build/envsetup.sh && \
      lunch aosp_arm64-userdebug && \
      m versioner && \
      ./bionic/tools/versioner/run_tests.py
Change-Id: I211fe5b7b1b66793d5e76a8676f9d18825f96b5e
2019-12-23 07:13:33 -08:00
Elliott Hughes
5e2ac29165 Merge "Stop using the __ANDROID_API_x__ constants." 2019-12-23 03:26:37 +00:00