Commit graph

9331 commits

Author SHA1 Message Date
Haibo Huang
e4788d4c7e No ifunc for strcmp and strlen
This is a workaround to unbreak bank apps

Bug: 120254692
Test: Run broken apps
Change-Id: I47a655e9648a6d5f50856f712d8e1cf2be24b440
2018-12-12 04:28:29 +00:00
Ryan Prichard
b0a55fbf74 Merge "Reserve TLS_SLOT_SANITIZER with value 6." 2018-12-12 02:02:03 +00:00
Ryan Prichard
913f808c0f Merge "Move errno to a pthread_internal_t field." 2018-12-11 22:35:16 +00:00
Ryan Prichard
4825c6d814 Reserve TLS_SLOT_SANITIZER with value 6.
This slot will replace TLS_SLOT_TSAN, which needs to be removed for ELF
TLS compatibility. The platform has both slots reserved until compiler-rt
can be updated. See:
 - https://reviews.llvm.org/D53906
 - discussion on AOSP change Idf25d2ee457a5d26d0bdd6281cee72c345c8b755

Bug: http://b/78026329
Test: m
Change-Id: Ifd5aeb5711dc88266e7350cb022146dd87cfd7be
2018-12-11 13:02:56 -08:00
Ryan Prichard
37754cdef6 Move errno to a pthread_internal_t field.
This change is intended to allow native-bridge to use independent
TLS memory for host and guest environments, while still sharing a
thread-local errno between the two.

Bug: http://b/78026329
Test: bionic unit tests
Change-Id: I838cd321e159add60760bc12a8aa7e9ddc960c33
Merged-In: I838cd321e159add60760bc12a8aa7e9ddc960c33
(cherry picked from commit a9c7c55462)
2018-12-11 12:59:23 -08:00
Neil Fuller
24bddbe949 Merge "Revert "Track movement of ICU .dat file"" 2018-12-11 20:20:14 +00:00
Neil Fuller
b9e7b699a2 Revert "Track movement of ICU .dat file"
This reverts commit 68c6bd8b43.

Reason for revert: Broke ART test environments and emulator devices.

Bug: 119293618
Change-Id: I1b0531d13c6565ce83801d93c78813af592eec1a
2018-12-11 20:11:58 +00:00
Neil Fuller
681d8eb5ca Merge "Track movement of ICU .dat file" 2018-12-11 14:03:28 +00:00
Neil Fuller
2f1a8dbd10 Merge "Find tzdata in the runtime module before /system" 2018-12-10 17:37:33 +00:00
Neil Fuller
68c6bd8b43 Track movement of ICU .dat file
Track movement of ICU .dat file into the runtime module.

Bug: 119293618
Test: build / boot
Change-Id: I595c0c94ea7f693810fbe323d7966d9fdf4a07e6
2018-12-09 15:01:43 +00:00
Neil Fuller
4e33c4ff9b Merge "Track move of APEX module tz files under etc/tz" 2018-12-08 16:41:48 +00:00
Neil Fuller
a50e51ac96 Find tzdata in the runtime module before /system
Look for the tzdata file in the runtime module before looking
in /system. It is still an open question how the removal of
tzdata will be handled, if at all. Until it is worked out it
will be duplicated.

Bug: 119293618
Bug: 119390260
Test: build / boot
Change-Id: I7e14ef41d0ec226caa595c56be61df5ecf50c382
2018-12-07 09:14:03 +00:00
Ryan Prichard
8b475e598d Merge "Move dlerror out of a TLS slot and into a pthread_internal_t member." 2018-12-06 22:18:56 +00:00
Roland Levillain
42635c98a1 Merge "Add Android Runtime APEX bin directory to Bionic default shell search path." 2018-12-06 17:13:06 +00:00
Roland Levillain
fe21bbacfc Add Android Runtime APEX bin directory to Bionic default shell search path.
Insert `/apex/com.android.runtime/bin` before `/system/bin` in the
default shell search path (`_PATH_DEFPATH`).

Test: Device boot test with Android Runtime APEX.
Test: Device boot test without Android Runtime APEX.
Test: cts-tradefed run cts --m vm-tests-tf
Test: cts-tradefed run cts --m CtsSimpleperfTestCases
Test: adb root && cts-tradefed run cts --m CtsBionicTestCases
Bug: 113373927
Bug: 119949783
Change-Id: I45fd6ccb939c7e99eb6bda740a7187774c1e930d
2018-12-06 17:03:47 +00:00
Dimitry Ivanov
5c92d9e858 Merge "Introduce filegroups for libc sources" 2018-12-06 14:39:30 +00:00
Neil Fuller
9268977f2d Track move of APEX module tz files under etc/tz
The same prebuilts will be used in both runtime and time zone
modules. Having the rules put the files in etc/tz/ will make
them more appropriate for the runtime module.

Bug: 119026403
Test: build /boot only
Change-Id: Ia1370457e9d1547b35ed56bb385213d3727c8b9a
2018-12-06 14:33:12 +00:00
Elliott Hughes
34583c1089 Move dlerror out of a TLS slot and into a pthread_internal_t member.
Bug: N/A
Test: boots, tests pass.
Change-Id: Idf25d2ee457a5d26d0bdd6281cee72c345c8b755
2018-12-06 05:19:57 +00:00
Treehugger Robot
31105c8dd8 Merge "Remove cruft." 2018-12-06 02:43:58 +00:00
Ryan Prichard
a6bc0e3c28 Merge changes I96c7b02c,I461feeae,I6fcd8d75
* changes:
  Replace TLS_SLOT_BIONIC_PREINIT w/ shared globals
  Use shared globals so getauxval works earlier
  Split main thread init into early+late functions
2018-12-05 20:46:15 +00:00
Elliott Hughes
9131b4abfd Remove cruft.
Test: builds
Change-Id: I432d97ca9c94d96eba74687338d27c0f41b71f0c
2018-12-05 10:00:25 -08:00
dimitry
c0c0ef6da6 Introduce filegroups for libc sources
Add filegroups for libc sources not included in component static
libraries.

Bug: http://b/120406045
Bug: http://b/114470065
Test: make
Change-Id: I2045f14d6636e0da4eb741bfd2de3312475e20e3
2018-12-05 16:37:13 +01:00
Haibo Huang
4af19611e2 Bionic: Support kryo385 CPU
Bug: 119564566
Test: build
Change-Id: I557fb6a860b777b7cdb6b97d6946847800a8cec6
2018-12-05 04:39:15 +00:00
Ryan Prichard
07440a8773 Replace TLS_SLOT_BIONIC_PREINIT w/ shared globals
Instead of passing the address of a KernelArgumentBlock to libc.so for
initialization, use __loader_shared_globals() to initialize globals.

Most of the work happened in the previous CLs. This CL switches a few
KernelArgumentBlock::getauxval calls to [__bionic_]getauxval and stops
routing the KernelArgumentBlock address through the libc init functions.

Bug: none
Test: bionic unit tests
Change-Id: I96c7b02c21d55c454558b7a5a9243c682782f2dd
Merged-In: I96c7b02c21d55c454558b7a5a9243c682782f2dd
(cherry picked from commit 746ad15912)
2018-12-04 13:51:56 -08:00
Ryan Prichard
5a66490e3b Use shared globals so getauxval works earlier
Make getauxval() work in .preinit_array. It still won't be usable for
ifuncs unless we can guarantee that the __loader_shared_globals relocation
is resolved before the ifunc calls [__bionic_]getauxval.

Define __bionic_getauxval for use in replacing calls to
KernelArgumentBlock::getauxval, which doesn't (and sometimes isn't allowed
to) access TLS variables like errno.

Bug: http://b/25751302
Test: bionic unit tests
Change-Id: I461feeaed7f43cfa2a2b6c34147194f0df82b516
Merged-In: I461feeaed7f43cfa2a2b6c34147194f0df82b516
(cherry picked from commit bdab4a2b97)
2018-12-04 13:51:46 -08:00
Ryan Prichard
9cfca866ce Split main thread init into early+late functions
Split __libc_init_main_thread into __libc_init_main_thread_early and
__libc_init_main_thread_late. The early function is called very early in
the startup of the dynamic linker and static executables. It initializes
the global auxv pointer and enough TLS memory to do system calls, access
errno, and run -fstack-protector code (but with a zero cookie because the
code for generating a cookie is complex).

After the linker is relocated, __libc_init_main_thread_late finishes
thread initialization.

Bug: none
Test: bionic unit tests
Change-Id: I6fcd8d7587a380f8bd649c817b40a3a6cc1d2ee0
Merged-In: I6fcd8d7587a380f8bd649c817b40a3a6cc1d2ee0
(cherry picked from commit 39bc44bb0e)
2018-12-04 13:51:36 -08:00
Haibo Huang
949269828e Merge "Remove denver from bionic" 2018-12-04 20:49:10 +00:00
Treehugger Robot
b7cee4ebad Merge "Make __libc_init_malloc weak-for-native-bridge" 2018-12-04 20:02:45 +00:00
dimitry
5332af69b6 Make __libc_init_malloc weak-for-native-bridge
Bug: http://b/120406045
Test: make

Change-Id: Ieee30beca3f3bb8525030643b0245041cd4a6167
2018-12-04 14:06:44 +01:00
Haibo Huang
01bfd8934e Remove denver from bionic
Test: bionic unit tests
Bug: 73545680
Change-Id: Ib142bf289ac73a3512ad1f29789ef82027160d78
2018-12-04 06:38:08 +00:00
Dan Willemsen
c69218d47e Merge "Prevent dependency cycle due to system_shared_libs expansion" 2018-12-04 06:19:08 +00:00
Dan Willemsen
6b3be172d6 Prevent dependency cycle due to system_shared_libs expansion
It was discovered that we were building some objects inconsistently due
to an optimization in cc_library to only build objects once and use them
for both the static and shared libraries. But static libraries didn't
get system_shared_libs set automatically, and we didn't notice that we
would have built the objects differently.

So static libraries now get the default system_shared_libs, we allow
adjusting that for static vs shared in a cc_library, and we disable the
optimization if the linked libraries are configured differently between
static and shared in a single cc_library.

This triggers dependency cycles for static libraries that libc/libdl
use, so fix those cycles here.

Test: treehugger
Change-Id: I3cf7fda161a05ec32e0c1e871999720d12a4d38e
2018-12-03 15:41:56 -08:00
Elliott Hughes
eebf5fddf3 Reduce strerror(3)'s impact on .data.rel.ro.
Test: tests pass
Change-Id: I60b15dfac6ca7dce45f4858ad10b8255e2f1b66d
2018-12-03 08:46:21 -08:00
Haibo Huang
3927db1d5b Remove denver64 from libc
Test: compile
Change-Id: Ifcbe15c1682b4e1e18835e38915b2421196882f7
2018-11-30 22:28:39 +00:00
Florian Mayer
9f1fddca26 Merge "Use cmdline instead for enabling heapprofd." 2018-11-30 21:56:00 +00:00
Florian Mayer
4e28ea13c7 Use cmdline instead for enabling heapprofd.
Because we also want to profile Java applications, which have longer
names, the character limit of comm is a problem. To avoid complexity, it
is preferable to apply the same logic for finding running processes
(which includes Java apps), and determining whether to profile a process
from startup.

Test: m
Test: flash sailfish
Test: setprop heapprofd.enable 1
      setprop heapprofd.enable.ls 1
      ls
      /system/bin/ls
      /system/bin/ls /

Bug: 120175590

Change-Id: Id0859d4a333efcb05883e611ea6a31a51468f82c
2018-11-30 11:14:43 +00:00
Haibo Huang
73ad790ebe [ifunc] Use c implementation to compare cpu variant names
Did this for fun but turns out it generates better assembly code.

With a C implementation, compiler can expand both the comparison
loop and cpu_variant_names array. Results in a decision tree like
structure. For example the "cortex-a" prefix common in many variants
will only be compared once.

Test: run bionic unit tests.
Test: use debugger to check which variant is used.
Change-Id: Id70e5536f968161f20b18f35d46430457c338f0f
2018-11-30 07:56:22 +00:00
Ryan Prichard
6b70fda682 Merge changes I376d7695,Ied443375,I614d25e7
* changes:
  Use shared globals to init __progname + environ
  Move the abort message to libc_shared_globals
  Expose libc_shared_globals to libc.so with symbol
2018-11-30 02:06:52 +00:00
Haibo Huang
7260329093 Merge "Use ifunc for ARM32 fortify functions" 2018-11-29 00:47:35 +00:00
Ryan Prichard
48b1159bb8 Use shared globals to init __progname + environ
Initialize the __progname and environ global variables using
libc_shared_globals rather than KernelArgumentBlock.

Also: suppose the linker is invoked on an executable:

    linker prog [args...]

The first argument passed to main() and constructor functions is "prog"
rather than "linker". For consistency, this CL changes the BSD
__progname global from "linker" to "prog".

Bug: none
Test: bionic unit tests
Change-Id: I376d76953c9436706dbc53911ef6585c1acc1c31
2018-11-28 14:26:14 -08:00
Ryan Prichard
7752bcb234 Move the abort message to libc_shared_globals
__libc_shared_globals() is available in dynamic modules as soon as
relocation has finished (i.e. after ifuncs run). Before ifuncs have run,
the android_set_abort_message() function already doesn't work because it
calls public APIs via the PLT. (If this matters, we can use a static
bool variable to enable android_set_abort_message after libc
initialization).

__libc_shared_globals() is hidden, so it's available in the linker
immediately (i.e. before relocation). TLS memory (e.g. errno) currently
isn't accessible until after relocation, but a later patch fixes that.

Bug: none
Test: bionic unit tests
Change-Id: Ied4433758ed2da9ee404c6158e319cf502d05a53
2018-11-28 14:26:14 -08:00
Ryan Prichard
abf736a780 Expose libc_shared_globals to libc.so with symbol
Previously, the address of the global variable was communicated from the
dynamic linker to libc.so using a field of KernelArgumentBlock, which is
communicated using the TLS_SLOT_BIONIC_PREINIT slot.

As long as this function isn't called during relocations (i.e. while
executing an ifunc), it always return a non-NULL value. If it's called
before its PLT entry is relocated, I expect a crash.

I removed the __libc_init_shared_globals function. It's currently empty,
and I don't think there's one point in libc's initialization where
shared globals should be initialized.

Bug: http://b/25751302
Test: bionic unit tests
Change-Id: I614d25e7ef5e0d2ccc40d5c821dee10f1ec61c2e
2018-11-28 14:26:14 -08:00
Elliott Hughes
12ed389ca5 Merge "Remove _sys_signal_strings." 2018-11-28 22:01:47 +00:00
Haibo Huang
f1c8d1a6f9 Use ifunc for ARM32 fortify functions
Test: compile and run bionic unit tests
Test: make PRODUCT-sdk_phone_arm64-sdk
Change-Id: I614f495ad6053d507446a6a896b9199825325188
2018-11-28 10:56:21 -08:00
Luke Huang
f47e89f29b Merge "Replace android_open_proxy with dns_open_proxy" 2018-11-28 12:21:33 +00:00
Elliott Hughes
f8294fd8dc Remove _sys_signal_strings.
We already have sys_siglist as public API.

Test: tests pass
Change-Id: I45bf72955f41b34d91fac19dbfb2946bb9995ef4
2018-11-27 14:43:38 -08:00
Ryan Prichard
0ff8df5f6a Merge "Cleanup: __libc_init_AT_SECURE, auxv, sysinfo" 2018-11-27 21:23:21 +00:00
Treehugger Robot
aa5c0e261a Merge "Fix minor bug in dispatch table initialization order." 2018-11-27 20:51:00 +00:00
Florian Mayer
e965bcdbe3 Fix minor bug in dispatch table initialization order.
Other minor changes:
 * document assignment that relies on _Atomic assignments to use
   atomic_store.
 * consistently use atomic_store when assigning to atomics.
 * remove incorrect comment.

Test: m
Test: flash & boot sailfish

Change-Id: I4789c08f7ac28a2de8d6925d03af354514bfd9d7
2018-11-27 17:38:18 +00:00
Ivan Lozano
f17fd1d68a Disable XOM in linker, libc, and libm.
These modules have issues running with execute-only memory. Disable it
in them until we can resolve the issues.

Bug: 77958880
Test: No more XOM-related crashes in these binaries

Change-Id: Ie6c957731155566c2bbe7dbb7a91b9583d9aff93
2018-11-27 07:56:17 -08:00