Commit graph

32918 commits

Author SHA1 Message Date
Yi Kong
15a05a77b4 No global ThinLTO for bionic
There are multiple build breakages with bionic when we enable ThinLTO
globally. Opt bionic out of ThinLTO for now.

#global-thinlto-opt-out

Test: TreeHugger
Bug: 169004486
Change-Id: I546a8074f9c3e0ddbd01d3b7cd730e215e3c0c49
2020-09-29 17:24:04 +00:00
Victor Khimenko
07c85f1688 Merge "Make __clone_for_fork pure native bridge mode abstraction" 2020-09-28 20:46:50 +00:00
Victor Khimenko
d510f22732 Merge "Stop marking symbols weak in native bionic build" 2020-09-28 20:46:38 +00:00
Christopher Ferris
5aedb68499 Merge "alloc_debug: get load_bias error" 2020-09-28 19:06:33 +00:00
Victor Khimenko
6427f39ba9 Make __clone_for_fork pure native bridge mode abstraction
In native build of libc it would be inlined and in native bridge mode
it's noinline, extern "C" and thus could be easily intercepted.

Test: m (without weak symbols in native bridge mode x86+arm build would be broken)

Change-Id: I67759858a5bc2174dce1db9732fdbd89ba7689cc
2020-09-28 20:36:39 +02:00
Victor Khimenko
b967e793a5 Stop marking symbols weak in native bionic build
Now, when we can detect native bridge mode is sources we can do that.

Test: m (without weak symbols in native bridge mode x86+arm build would be broken)

Change-Id: I360e7df8211d03636bbe716dc14655ee8d765493
2020-09-28 20:25:32 +02:00
Weiwei.Zhang
8d01fac300 alloc_debug: get load_bias error
malloc_debug can use libunwind and libunwindstck to unwind backtrace,
if libc.debug.malloc.options contains the string of "backtrace_full",
malloc_debug will use libunwindstck, and if libc.debug.malloc.options
contains the string of "backtrace=*", malloc_debug will use libunwind.

The result of libunwindstck is normal, but the result of libuniwnd
is abnormal, there is a offset between the rel_cp and the correct value,
so addr2line can't decode the right line number.

Libunwind and libunbiwndpack calculate load_bias is different, so malloc_debug
get load_bias alignment with libunwindstack.

Bug: 169539402
Change-Id: I640fb5db39af622a0bb52abf2c107984065a89d5
2020-09-28 07:15:32 +00:00
Elliott Hughes
73ed0c4525 Merge changes from topic "arm64_branch-protection"
* changes:
  libc: Add Armv8.3-A PAuth and Armv8.5-A BTI compatibility to *.S
  Update crtbegin.c and crt*.S to support Armv8.5-A BTI
  libm: Add Armv8.3-A PAuth and Armv8.5-A BTI support to assembly files
  libc: Prepare support for Armv8.3-A PAuth and Armv8.5-A BTI in *.S
2020-09-25 16:08:14 +00:00
Elliott Hughes
7241ac6c07 Merge "Enable BTI in bionic linker" 2020-09-25 16:08:14 +00:00
Treehugger Robot
5cd0172b52 Merge "Work around issues with aligned_alloc() and -O2." 2020-09-25 03:56:22 +00:00
Stephen Hines
1c33c4a263 Work around issues with aligned_alloc() and -O2.
The latest LLVM update to r399163 has exposed an issue with optimization
of `aligned_alloc()` at -O2. Invalid inputs are treated as valid, which
results in assertions being hit. This WAR is to make sure that the test
keeps running while we fix the issue upstream.

Bug: http://b/169206016
Bug: http://b/155835175
Test: atest malloc_hooks_system_tests:malloc_hooks_system_tests.MallocHooksTest#aligned_alloc_hook_error -- --abi x86
Change-Id: I74b290b73826481c62db3a99ac1a690c8a8a8db3
2020-09-24 17:17:57 -07:00
Dan Albert
bda85584d1 Merge "Avoid explicit use of "10000" in build files." 2020-09-24 21:02:12 +00:00
Peter Collingbourne
155901898d Merge "Copy the M_THREAD_DISABLE_MEM_INIT constant value into malloc.h." 2020-09-24 21:02:09 +00:00
Peter Collingbourne
978eb16cd4 Copy the M_THREAD_DISABLE_MEM_INIT constant value into malloc.h.
This will allow platform and application developers to use it.

Bug: 163630045
Change-Id: If9a361cb97aaf62d3fa124b60f64d51d609af48d
2020-09-24 17:01:54 +00:00
Tamas Petz
8d55d1872a Enable BTI in bionic linker
This patch adds support to load BTI-enabled objects.

According to the ABI, BTI is recorded in the .note.gnu.property section.
The new parser evaluates the property section, if exists.
It searches for .note section with NT_GNU_PROPERTY_TYPE_0.
Once found it tries to find GNU_PROPERTY_AARCH64_FEATURE_1_AND.
The results are cached.

The main change in linker is when protection of loaded ranges gets
applied. When BTI is requested and the platform also supports it
the prot flags have to be amended with PROT_BTI for executable ranges.
Failing to add PROT_BTI flag would disable BTI protection.
Moreover, adding the new PROT flag for shared objects without BTI
compatibility would break applications.

Kernel does not add PROT_BTI to a loaded ELF which has interpreter.
Linker handles this case too.

Test: 1. Flame boots
      2. Tested on FVP with BTI enabled

Change-Id: Iafdf223b74c6e75d9f17ca90500e6fe42c4c1218
2020-09-23 17:53:28 -07:00
Stephen Hines
47250aca16 Merge "Adapt for update to clang-r399163." 2020-09-23 05:28:48 +00:00
Stephen Hines
760647791f Adapt for update to clang-r399163.
This is really just a case of including the proper header for a
function.

Bug: http://b/155835175
Test: OUT_DIR=out prebuilts/clang-tools/build-prebuilts.sh
Change-Id: I0523d3ccd8cb502e8c2b8f72f137db4b60fb1dac
2020-09-22 13:37:42 -07:00
Treehugger Robot
0a12075ca4 Merge "Add arm64 source to linker_wrapper" 2020-09-22 04:23:45 +00:00
Jiyong Park
3b47d603fa Add arm64 source to linker_wrapper
As we enable arm64-based Bionic host target (linux_bionic_arm64),
linker_wrapper is added with the corresponding source.

Bug: 159685774
Test: HOST_CROSS_OS=linux_bionic HOST_CROSS_ARCH=arm64 m
Test: copy out/soong/host/linux_bionic_arm64/ to an ARM64 emulator
running Linux and execute the binaries

Change-Id: I4f367a349f7e0015318352cb7f2870fc856eab05
2020-09-22 11:28:22 +09:00
Tom Cherry
6c19d67a73 Merge "Explicitly add the include path for android_filesystem_config.h" 2020-09-21 20:35:31 +00:00
Tom Cherry
379ed1ef62 Explicitly add the include path for android_filesystem_config.h
android_filesystem_config.h is found since system/core/include is on
the include path for all projects and contains a symlink to the real
android_filesystem_config.h.  This is fragile and the below bug seeks
to remove this symlink and have users correctly depend on
libcutils_headers.

In bionic, libcutils_headers header library cannot be used due to
cyclic dependencies, so it gets the actual include path instead, which
is less bad than depending on the build system injecting the for all
modules.

Bug: 165825252
Test: build
Change-Id: Id43bdea9553b1174ceb3efc2a3ed505888619c62
2020-09-21 10:09:25 -07:00
Lev Rumyantsev
bfb889002b Merge "Simplify native bridge skip check" 2020-09-19 01:58:08 +00:00
Lev Rumyantsev
37c5ed3e50 Simplify native bridge skip check
A follow-up to r.android.com/1430136.

Test: CtsBionicTestCases
Bug: None
Change-Id: I372bc0866b1d286637d3671f82be83cec1027bca
2020-09-18 15:09:01 -07:00
Peter Collingbourne
cf69abc0f4 Merge "Dump the per-thread TAGGED_ADDR_CTRL value if available." 2020-09-18 22:00:53 +00:00
Bill Yi
f15d33e2f9 Merge "Merge mainline-release 6664920 to master - DO NOT MERGE" 2020-09-18 18:47:54 +00:00
Bill Yi
e320c77e47 Merge mainline-release 6664920 to master - DO NOT MERGE
Merged-In: I91b84c489668ae1cac5a8143a9350e3ab625afdb
Change-Id: Id39b07cab134b03e42729cd0a7ca91990468d63e
2020-09-17 21:56:54 -07:00
Treehugger Robot
d7f153f9b9 Merge "Merge android11-tests-dev." 2020-09-18 01:15:30 +00:00
Treehugger Robot
60a39566f0 Merge "Make it clearer that math.h isn't fdlibm." 2020-09-18 00:50:31 +00:00
Elliott Hughes
fee514e714 Make it clearer that math.h isn't fdlibm.
It was originally based on fdlibm, but it's been through two different
projects since then, and `git blame` shows basically nothing remaining
from those days. Seems worth leaving something to explain the unusual
copyright header though!

Test: treehugger
Change-Id: I8e7252a755704b866e7f36c8e97adc021fa3cdad
2020-09-17 11:57:50 -07:00
Peter Collingbourne
98d79de51d Dump the per-thread TAGGED_ADDR_CTRL value if available.
This value indicates whether memory tagging is enabled on a thread,
the mode (sync or async) and the set of excluded tags. This information
can sometimes be important for understanding an MTE related crash,
so include it in the per-thread tombstone output.

Bug: 135772972
Change-Id: I25a16e10ac7fbb2b1ab2a961a5279f787039000b
2020-09-15 21:32:36 -07:00
Kiyoung Kim
66ae134614 Merge "Mark bionic APEX as visible" 2020-09-16 01:47:23 +00:00
Xin Li
6525d54985 Merge android11-tests-dev.
Bug: 168333982
Change-Id: If3eab22f2691623cbbbbf555587955a3a58a3b71
2020-09-14 17:17:34 -07:00
Elliott Hughes
1efa573832 Merge "Expose a function to reset the stack protector for the zygote." 2020-09-11 18:47:05 +00:00
Elliott Hughes
a1e3f2c502 Expose a function to reset the stack protector for the zygote.
This is already covered by the existing test by virtue of being used for
all threads.

Bug: http://b/168258494
Test: treehugger
Change-Id: I5c872fd7f30a4c79de1d70e7702f4b12d4e94cd3
2020-09-11 08:56:58 -07:00
Peter Collingbourne
bba9153c5c Merge "Implement a new mechanism to let Scudo access the TLS slot" 2020-09-10 23:02:03 +00:00
Peter Collingbourne
38d290a11d Implement a new mechanism to let Scudo access the TLS slot
An upcoming change to Scudo will change how we use the TLS slot
in tsd_shared.h, which will be a little easier to deal with if
we can remove the code path that calls pthread_getspecific and
pthread_setspecific. The only known user of this code path is Fuchsia.

We can't eliminate this code path by making Fuchsia use ELF TLS
because although Fuchsia supports ELF TLS, it is not supported within
libc itself. To address this, Roland McGrath on the Fuchsia team has
proposed that Scudo will optionally call a platform-provided function
to access a TLS slot reserved for Scudo. Android also has a reserved
TLS slot, but the code that accesses the TLS slot lives in Scudo.

We can eliminate some complexity and duplicated code by having Android
implement the same mechanism that was proposed for Fuchsia, which is
what this change does. A separate change to Scudo will make use of it.

Bug: 163630045
Change-Id: I4678105c9c47a23feb5a5e80a314416de4556d9c
2020-09-10 13:55:24 -07:00
Elliott Hughes
ba4b40602a Merge "NGREG != ELF_NGREG." am: a5a9992671
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1419433

Change-Id: I9447c49cd08bfac0f127229455529bffdfd23c56
2020-09-09 20:17:43 +00:00
Elliott Hughes
a5a9992671 Merge "NGREG != ELF_NGREG." 2020-09-09 19:54:46 +00:00
Kiyoung Kim
5a8189f141 Mark bionic APEX as visible
Linkerconfig is going to remove all hard-coded dependencies from APEX
modules and let APEX modules specify its own requirements. As part of
it, this change adds a new configuration file for linkerconfig and let
it aware that bionic APEX should be visible from all sections.

Bug: 167946001
Test: atest passed
Change-Id: If934d9a3e72b1466ee0d7bbb66d9383b90986a6b
2020-09-09 16:28:20 +09:00
Elliott Hughes
8e5fc5b037 NGREG != ELF_NGREG.
Except they are the same on arm32/arm64, so we hadn't really noticed. x86
and x86-64 are quite different though, presumably by historical accident.

Fix the definitions and add some static asserts.

Bug: https://github.com/android/ndk/issues/1347
Test: treehugger
Change-Id: Ic27b172066cf3443749463b9b73c912d204f9516
2020-09-08 09:27:02 -07:00
Tamas Petz
f5bdee7fdf libc: Add Armv8.3-A PAuth and Armv8.5-A BTI compatibility to *.S
The most notable change is in sigsetjmp/siglongjmp. The former
stores LR signed with the current SP into jmp_buf. Calling siglongjmp
reads a signed LR and the corresponding SP from jmp_buf. This way not
only the checksum provides some means of integrity protection but
Pointer Authentication too.

Test: Tested on FVP with BTI enabled.

Change-Id: I9d720239775f8d2829a677901f546c4b14b5cbe5
2020-09-04 11:29:12 +02:00
Tamas Petz
18621fb30c Update crtbegin.c and crt*.S to support Armv8.5-A BTI
These files are linked to all ELF files therefore they must support BTI.

Test: Tested on FVP with BTI enabled using a patched clang.

Co-authored-by: Gabor Kertesz <gabor.kertesz@arm.com>
Co-authored-by: Daniel Kiss   <daniel.kiss@arm.com>
Co-authored-by: Tamas Petz    <tamas.petz@arm.com>

Change-Id: If5df0722e649bcdb8c4afb0531831dff42103c9c
2020-09-04 11:28:59 +02:00
Tamas Petz
42b6530b1b libm: Add Armv8.3-A PAuth and Armv8.5-A BTI support to assembly files
This change adds both Armv8.3-A Pointer Authentication and Armv8.5-A BTI
support to *.S files.

Tests: Tested on FVP with BTI enabled

Change-Id: I82750afcbc950a91584463fbc979c2c35d41916a
2020-09-04 11:28:49 +02:00
Tamas Petz
19d66e6f2d libc: Prepare support for Armv8.3-A PAuth and Armv8.5-A BTI in *.S
The instruction "bti c" is added through ENTRY*() macro,
using __bionic_asm_custom_entry(f).

The .note.gnu.property section is added with the new macro
NOTE_GNU_PROPERTY(). BTI and PAuth features are automatically
selected based on the presence of __ARM_FEATURE_* macros.

Furthermore, gensyscalls.py got updated to append the new
macro to the generated syscalls-arm64.S.

Test: Tested on FVP with BTI enabled.

Change-Id: I40ffe294b8426421125fffd0a9758567d919a09d
2020-09-04 11:28:43 +02:00
Xin Li
86214f6d88 Merge "Skip RP1A.200720.011" into stage-aosp-master 2020-09-02 19:15:47 +00:00
Tom Cherry
4473d90316 Merge "Add benchmark for property mapping" am: 7e0816a0a4
Original change: https://android-review.googlesource.com/c/platform/bionic/+/1417669

Change-Id: I357733be71ebedf37dcf28d49f24c0dcdf149493
2020-09-02 19:05:58 +00:00
Xin Li
59cee9f405 Skip RP1A.200720.011
Bug: 167588565
Merged-In: I99d71533c73a721877bd43fa759912c7c5b60351
Change-Id: I55c193a9b35db7d2516296c79c33fa2837b3e54b
2020-09-02 12:01:10 -07:00
Xin Li
204da165b1 Mark RP1A.200720.001 as merged
Bug: 167588565
Merged-In: Ic00db40d010c75b2384796c19751226bec5519fd
Change-Id: If4e3cddf2e03fb529a2830a3988f97ce557222db
2020-09-02 11:44:47 -07:00
Tom Cherry
7e0816a0a4 Merge "Add benchmark for property mapping" 2020-09-02 18:25:16 +00:00
Tom Cherry
a5744e213f Add benchmark for property mapping
This benchmarks mapping property prefixes to property contexts with
two algorithms: the 'Legacy' method used before Android P and the
'Trie' used afterwards (the code in this directory).

It uses input mappings from both Oreo and the latest in AOSP ('S').
Note that there is nearly a 10x increase in the number of mappings in
S as there was in Oreo, which was predicted when the trie was
designed.

Results on cuttlefish:
-----------------------------------------------------------
Benchmark                 Time             CPU   Iterations
-----------------------------------------------------------
LegacyLookupOreo     683576 ns       673538 ns         1060
LegacyLookupS       5683109 ns      5596982 ns          124
TrieLookupOreo       299851 ns       295696 ns         2378
TrieLookupS          584831 ns       576801 ns         1204

The results show that the legacy look up uses 8.3x more CPU time to
handle the number of mappings added through S, whereas the Trie lookup
uses less than 2x more CPU time, showing that the trie scales better
with added mappings.

Test: run this benchmark
Change-Id: I35c3aa4429f049e327a891f9cbe1901d8855d7ba
2020-09-02 16:12:21 +00:00