Commit graph

9555 commits

Author SHA1 Message Date
Neil Fuller
ca305a39e5 Merge "Track movement of ICU .dat file" 2019-01-13 16:22:59 +00:00
Ryan Prichard
45d1349c63 Reorganize static TLS memory for ELF TLS
For ELF TLS "local-exec" accesses, the static linker assumes that an
executable's TLS segment is located at a statically-known offset from the
thread pointer (i.e. "variant 1" for ARM and "variant 2" for x86).
Because these layouts are incompatible, Bionic generally needs to allocate
its TLS slots differently between different architectures.

To allow per-architecture TLS slots:
 - Replace the TLS_SLOT_xxx enumerators with macros. New ARM slots are
   generally negative, while new x86 slots are generally positive.
 - Define a bionic_tcb struct that provides two things:
    - a void* raw_slots_storage[BIONIC_TLS_SLOTS] field
    - an inline accessor function: void*& tls_slot(size_t tpindex);

For ELF TLS, it's necessary to allocate a temporary TCB (i.e. TLS slots),
because the runtime linker doesn't know how large the static TLS area is
until after it has loaded all of the initial solibs.

To accommodate Golang, it's necessary to allocate the pthread keys at a
fixed, small, positive offset from the thread pointer.

This CL moves the pthread keys into bionic_tls, then allocates a single
mapping per thread that looks like so:
 - stack guard
 - stack [omitted for main thread and with pthread_attr_setstack]
 - static TLS:
    - bionic_tcb [exec TLS will either precede or succeed the TCB]
    - bionic_tls [prefixed by the pthread keys]
    - [solib TLS segments will be placed here]
 - guard page

As before, if the new mapping includes a stack, the pthread_internal_t
is allocated on it.

At startup, Bionic allocates a temporary bionic_tcb object on the stack,
then allocates a temporary bionic_tls object using mmap. This mmap is
delayed because the linker can't currently call async_safe_fatal() before
relocating itself.

Later, Bionic allocates a stack-less thread mapping for the main thread,
and copies slots from the temporary TCB to the new TCB.
(See *::copy_from_bootstrap methods.)

Bug: http://b/78026329
Test: bionic unit tests
Test: verify that a Golang app still works
Test: verify that a Golang app crashes if bionic_{tls,tcb} are swapped
Merged-In: I6543063752f4ec8ef6dc9c7f2a06ce2a18fc5af3
Change-Id: I6543063752f4ec8ef6dc9c7f2a06ce2a18fc5af3
(cherry picked from commit 1e660b70da)
2019-01-11 15:34:22 -08:00
Ryan Prichard
27d59338b9 pthread_key.cpp: factor out get_thread_key_data
This change makes it easier to move the location of the pthread keys
(e.g. into the bionic_tls struct).

Bug: http://b/78026329
Test: bionic unit tests
Test: disassembly of libc.so doesn't change
Merged-In: Ib75d9dab8726de96856af91ec3daa2c5cdbc2178
Change-Id: Ib75d9dab8726de96856af91ec3daa2c5cdbc2178
(cherry picked from commit ecad24fad9)
2019-01-11 15:33:57 -08:00
Treehugger Robot
98564b8c74 Merge changes from topic "move_bionic_to_apex"
* changes:
  Expose more symbols temporarily
  Add stubs variants for bionic libs
2019-01-11 16:59:15 +00:00
Christopher Ferris
48fe0aef16 Update kernel headers with new parser.
Test: Builds.
Change-Id: I3f0714d53ac893ccc3e66f7a92d0ea7a6737f1c3
2019-01-10 17:33:56 -08:00
Christopher Ferris
4282833dfc Fix notice file.
The only 2019 android copyright is coming from a test file, which is
not included in our normal notice.

Test: Can upload.
Change-Id: Ie22332f927b99c28eb71c1daf5615adfef8c5d11
2019-01-10 16:07:44 -08:00
Christopher Ferris
9dd7d2e640 Merge "Rewrite removeVarsAndFuncs." 2019-01-10 23:48:36 +00:00
Christopher Ferris
658b16fd90 Rewrite removeVarsAndFuncs.
The current version has these bugs:
- Adding a semicolon after a function results in the removal of structures
  following the function.
- Function like macros get removed on accident rather than on purpose.
- It removes extern "C" { completely, which might not be a bug, but doesn't
  seem right.

I couldn't easily fix any of these problems because the code depends heavily
on the header being correct.

New unit tests added for the function to cover all of these cases.

A follow-on CL will include the updated headers.

Bug: 112290385

Test: Passes all new unit tests.
Test: When run on the current kernel headers, the generated headers are
Test: nearly the same, missing data is being added.
Change-Id: Ib22a5f2e78873544e8a9d54e385af1156b2a72bb
2019-01-10 15:15:15 -08:00
Neil Fuller
62d8d9fc8f Track movement of ICU .dat file
Track movement of ICU .dat file into the runtime module

This reverts commit b9e7b699a2.
This is a reapply of commit 68c6bd8b43

Bug: 120853401
Bug: 119293618
Test: build / boot
Change-Id: I69e0dde2756da64ac0b17f1726145dccacf5961f
2019-01-09 15:27:02 +00:00
Tim Murray
43889f5e2c Merge "Remove some PR_SET_VMAs during pthread_create" 2019-01-09 03:20:43 +00:00
Tim Murray
466e0ecb88 Remove some PR_SET_VMAs during pthread_create
PR_SET_VMA takes mmap_sem, which can cause contention and reduce
performance any time many threads are created at the same time,
like app startup.

Test: camera launch performance
Bug: 122471935
Change-Id: If7fa7ad99654c01d503f694976fd92bfd30d2afd
2019-01-08 13:27:41 -08:00
Ryan Prichard
c14d46f086 Merge "Add ARM EABI function __aeabi_read_tp" 2019-01-08 21:19:01 +00:00
Ryan Prichard
45024fefe7 Add ARM EABI function __aeabi_read_tp
By default, Clang uses this arm32 function to read the thread pointer,
either for ELF TLS or via __builtin_thread_pointer(). It's probably better
to inline the cp15 access using -mtp=cp15, but that's not the default yet.

See https://reviews.llvm.org/D34878?id=114573.

Bug: http://b/78026329
Test: bionic unit tests
Change-Id: I93b8926075f0b2cea8df9ef518d54f2820a8ff5b
2019-01-07 20:30:35 -08:00
Neil Fuller
2e967fcbab Update the "host" bionic code tzdata lookup logic
The "if defined(__ANDROID__)" else branch is there to support
bionic when running on host environments.

The code now checks the
${ANDROID_RUNTIME_ROOT}/etc/tz/tzdata path as well.

This is similar to the current on-device expectations.

Eventually, we may remove the /system / ANDROID_ROOT cases.

Bug: 119293618
Test: build only
Change-Id: I8310f7b5a1c14567a648673970c636c7c84ff818
2019-01-07 21:08:37 +00:00
Jiyong Park
220f51e566 Expose more symbols temporarily
Following additional symbols are temporarily exposed from the runtime APEX
to satisfy the dependencies from other non-AOSP modules. This will be
reverted when the modules are built with the boostrap bionic libraries.

Bug: 120266448
Test: m
Change-Id: I39ac40a40545723ea2aeb185b9cd293d511f802f
2019-01-04 22:29:36 +09:00
Jiyong Park
c45fe9f7bd Add stubs variants for bionic libs
Bionic libs are part of the runtime APEX (com.android.runtime). In order
to be able to update the runtime APEX independetly from the platform, we
have to prevent things outside of the APEX from using bionic symbols
that are not guaranteed to be stable. Otherwise, platform could break
when a symbol is removed from the libs via the APEX update.

To achive this goal, this change adds stubs variant to the bionic libs.
With this, things outside of the runtime APEX (i.e. other APEXes and the
platform) are built with the stubs variants that provide only the
symbols that are guaranteed to be stable.

The set of symbols are basically the same as the symbols available to
NDK clients. However, there are a few additional symbols that are not
available for NDK but should be made available for platform components.
They are marked with "# apex" tag. Symbols with that tag are not exposed
to apps (via NDK stubs) or vendors (via LLNDK stubs).

Note that the stubs is a build-time only artifact. It is used just to
break the build when private symbols are used outside of the runtime
APEX. At runtime, the real library in the APEX is used.

Bug: 120266448
Test: m
Test: m bionic-unit-tests
Change-Id: I7b8d75830c81d7d7d54e2fca21a85b3417531b47
2019-01-04 22:29:36 +09:00
Ryan Prichard
0b0ee0c634 libc_shared_globals: add a constexpr ctor
Having a constexpr constructor should guarantee that the static
`globals` variable in __libc_shared_globals is initialized statically
(as opposed to dynamically), which is important because
__libc_shared_globals is called very early (before the linker has
relocated itself). With the constructor, though, the fields can safely
have in-line default initializers.

Bug: none
Test: bionic unit tests
Change-Id: Icde821557369625734a4d85d7ff55428bad5c247
2019-01-03 17:11:27 -08:00
Treehugger Robot
d14d83032c Merge "Check return value of scandir in icu.cpp" 2019-01-03 00:55:06 +00:00
Alex Light
ecb95b8a15 Check return value of scandir in icu.cpp
We could cause illegal memory access due to not checking the scanddir
return value.

Test: run linux-bionic dex2oat to build boot.oat
Bug: 119332362
Change-Id: Ic5824e0373b9b99d8f892b4fcf22e742c6f792da
2019-01-02 15:30:50 -08:00
Chih-Hung Hsieh
770032ddfa Fix/suppress bionic google-explicit-constructor warnings
* Add explicit to conversion constructors/operators

Bug: 28341362
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor
Change-Id: Id1ad0327c1b8c6f094bcbb3ae599bc1f716b3f2f
2019-01-02 11:04:05 -08:00
Kyle Repinski
78da73adad libc: Optimize ARM memcmp by using NEON.
Because NEON_UNALIGNED_ACCESS has never been defined, it has gone unused.
This change enables NEON optimization if __ARM_NEON__ is defined.

Test: bionic-benchmarks-32 BM_string_memcmp

On Nextbit Robin (MSM8992), here are the results

Before:
                                       iterations      ns/op
BM_string_memcmp/8                            50M         28    0.277 GiB/s
BM_string_memcmp/64                           50M         54    1.169 GiB/s
BM_string_memcmp/512                           5M        444    1.151 GiB/s
BM_string_memcmp/1024                          2M        885    1.156 GiB/s
BM_string_memcmp/8Ki                         200k       7401    1.107 GiB/s
BM_string_memcmp/16Ki                        200k      14469    1.132 GiB/s
BM_string_memcmp/32Ki                        100k      28726    1.141 GiB/s
BM_string_memcmp/64Ki                         50k      57480    1.140 GiB/s

After:
                                       iterations      ns/op
BM_string_memcmp/8                            50M         22    0.351 GiB/s
BM_string_memcmp/64                         1000k         17    3.688 GiB/s
BM_string_memcmp/512                          20M        105    4.848 GiB/s
BM_string_memcmp/1024                         10M        190    5.367 GiB/s
BM_string_memcmp/8Ki                        1000k       1496    5.475 GiB/s
BM_string_memcmp/16Ki                       1000k       2746    5.966 GiB/s
BM_string_memcmp/32Ki                        500k       5481    5.978 GiB/s
BM_string_memcmp/64Ki                        200k      10971    5.973 GiB/s

Change-Id: I3c76ce7fa2796872e0171d5502b0ebd6e2893339
2018-12-22 01:04:27 +00:00
Florian Mayer
3a538a4861 Do not run heapprofd_initialize twice concurrently.
Change-Id: Ib3fd479ca690c90ca35d98386a1d3ec942715fa3
2018-12-20 11:31:02 +00:00
Christopher Ferris
b233fab925 Fix handling of libs with a ro map and a rx map.
When the linker was changed so that it put a read-only map and
read-execute map, this code incorrectly computed the relative pc and
offset. Modify to look for the actual start map in this case.

Also, change the load_base name to load_bias.

Bug: 120613266

Test: Dumped logcat while dumping backtraces.

Change-Id: I6628694c5222ea34d63217af3d138707d4900004
2018-12-18 17:45:46 -08:00
Elliott Hughes
d19b3c5274 Generate the per-arch .map files at build time.
We shouldn't be checking in these generated files...

Bug: N/A
Test: ran tests
Change-Id: Ib67c1ba839eacd7acebd713e1dcd4dd2c25d67f0
2018-12-17 12:26:42 -08:00
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
Ryan Prichard
701bd0cc88 Cleanup: __libc_init_AT_SECURE, auxv, sysinfo
__sanitize_environment_variables is only called when getauxval(AT_SECURE)
is true.

Instead of scanning __libc_auxv, reuse getauxval. If the entry is missing,
getauxval will set errno to ENOENT.

Reduce the number of times that __libc_sysinfo and __libc_auxv are
initialized. (Previously, __libc_sysinfo was initialized 3 times for the
linker's copy). The two variables are initialized in these places:
 - __libc_init_main_thread for libc.a (including the linker copy)
 - __libc_preinit_impl for libc.so
 - __linker_init: the linker's copy of __libc_sysinfo is still initialized
   twice, because __libc_init_main_thread runs after relocation. A later
   CL consolidates the linker's two initializations.

Bug: none
Test: bionic unit tests
Change-Id: I196f4c9011b0d803ee85c07afb415fcb146f4d65
2018-11-26 18:37:13 -08:00
Haibo Huang
ea9957a72a Arm32 dynamic function dispatch
Previous change was reverted in 9690b121e3.
This change added .arch directive to kryo/ to avoid invalid instruction error.

Test: Run bionic unit test.
Test: Use gdb to make sure the right function is selected.
Test: Build previously failed target: make PRODUCT-sdk_phone_arm64-sdk
Change-Id: I14de41851121fc1a0b38c98fda5eb844b6a9695c
2018-11-26 20:00:55 +00:00
Andreas Gampe
27beebf6e5 Revert "Add Android Runtime APEX directories to Bionic search paths."
This reverts commit d2dd379361.

Reason for revert: Breaks vm-tests.

Bug: 119949783
Bug: 113373927
Change-Id: I2b23285ba98422a23da653d7ea99d9034000f6d6
2018-11-26 18:57:32 +00:00
Roland Levillain
d2dd379361 Add Android Runtime APEX directories to Bionic search paths.
- Insert /apex/com.android.runtime/lib(64) before /system/lib(64)
  in the default library search paths (`kDefaultLdPaths`,
  `kAsanDefaultLdPaths`).
- 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.
Bug: 113373927
Change-Id: I9ae6bfe6939f63e7d76e7b3c9b21d8b698bd8fda
2018-11-20 19:12:40 +00:00
Florian Mayer
9e70e8100a Merge "System property for heapprofd at process startup." 2018-11-19 21:53:25 +00:00
Peter Collingbourne
8d849ffbad Merge "Allocate a small guard region around the shadow call stack." 2018-11-19 20:44:03 +00:00
Izabela Orlowska
9690b121e3 Revert "Arm32 dynamic function dispatch"
This reverts commit ce4ff9c44d.

Reason for revert: broke master in ab/5138164 target sdk_phone_armv7-sdk

Change-Id: Ia4b0c7e6117a37df694509078116963f41d7865e
2018-11-19 14:14:41 +00:00
Luke Huang
e3ed892faa Replace android_open_proxy with dns_open_proxy
remove android_open_proxy and use dns_open_proxy instead of it.
dns_open_proxy is in libnetd_client and
it does the same thing as android_open_proxy except return value.
It returns fd directly now.

Test: build, dns works fine
Change-Id: I984743fb50b23eeb9a7d24e9fc347832acfe2afe
2018-11-19 18:00:37 +08:00
Peter Collingbourne
734beec3d4 Allocate a small guard region around the shadow call stack.
This lets us do two things:

1) Make setjmp and longjmp compatible with shadow call stack.
   To avoid leaking the shadow call stack address into memory, only the
   lower log2(SCS_SIZE) bits of x18 are stored to jmp_buf. This requires
   allocating an additional guard page so that we're guaranteed to be
   able to allocate a sufficiently aligned SCS.

2) SCS overflow detection. Overflows now result in a SIGSEGV instead
   of corrupting the allocation that comes after it.

Change-Id: I04d6634f96162bf625684672a87fba8b402b7fd1
Test: bionic-unit-tests
2018-11-16 14:37:08 -08:00
Haibo Huang
ce4ff9c44d Arm32 dynamic function dispatch
Test: Run bionic unit test.
Test: Use gdb to make sure the right function is selected.

Change-Id: I34ccd83d472c13993f75672b1aac2b2eae65c499
2018-11-16 19:50:17 +00:00
Elliott Hughes
0f57d561fe Fix a comment in <android/api-level.h>.
Bug: N/A
Test: N/A
Change-Id: Id6ef27caf8fe095d2be7fbf18fed74cc1334f86b
2018-11-15 15:07:13 -08:00
Elliott Hughes
c0f4656452 Make android_get_application_target_sdk_version available to the NDK.
Also move this and android_get_device_api_level into <android/api-level.h>
so that they're always available.

This involves cleaning up <sys/cdefs.h> slightly.

Bug: N/A
Test: builds
Change-Id: I25435c55f3549cd0d827a7581bee75ea8228028b
2018-11-15 11:07:30 -08:00
Elliott Hughes
8359068064 Merge "Move API levels from uint32_t to int." 2018-11-14 19:50:59 +00:00
Elliott Hughes
ff1428a48e Move API levels from uint32_t to int.
(cherrypick of a6c71a09670ca636cca5cfea9d74b03a951e2b5e.)

Bug: N/A
Test: builds
Change-Id: I9c414e30e3c4fe2a4e16a2fe4ce18eae85fe4844
2018-11-13 21:25:07 -08:00
Haibo Huang
e141362aa1 Change memcpy ifunc to return memmove for x86
It is cleaner to do this with ifunc. This is a partial revert of:
https://android-review.googlesource.com/c/platform/bionic/+/693863

Test: run bionic unit test
Change-Id: I5fb5745fc98807805aedb94b683e959e2a76a25d
2018-11-13 14:23:19 -08:00
Haibo Huang
b9244ff551 Use ifunc to dynamically dispatch libc routines for x86
Test: run bionic unit test in aosp_cf_x86_phone emulator
Change-Id: Ib0c0de37cd38d24bfce2dfbe35b8fd8edff004af
2018-11-13 13:48:23 -08:00
Christopher Ferris
17c4bd9e59 Merge "Move to jemalloc5." 2018-11-13 20:48:07 +00:00
Christopher Ferris
d73a49e91e Move to jemalloc5.
Bug: 62621531

Test: Builds and boots. All unit tests pass.
Change-Id: I09d106cc3b658885b9155d6838f8df61498d3f85
2018-11-13 10:32:33 -08:00
Peter Collingbourne
da772e2113 bionic: Allocate a shadow call stack for each thread.
Instead of allocating the stack within a 16MB guard region as we
were doing before, just allocate the stack on its own. This isn't
as secure as with the guard region (since it means that an attacker
who can read the pthread_internal_t can determine the address of the
SCS), but it will at least allow us to discover more blockers until
a solution to b/118642754 is decided on.

Bug: 112907825
Bug: 118642754
Change-Id: Ibe5dffbad1b4700eaa0e24177eea792e7c329a61
2018-11-12 20:04:40 -08:00
Peter Collingbourne
5d427bcb08 bionic: Add shadow call stack guard region field to pthread_internal_t.
Landing this change separately to the change that implements SCS
because it needs to land at the same time as an internal change. This
will simplify the situation in case SCS needs to be reverted again.

Change-Id: Ibe18750829665b6dcf6e36628a5e5bbdd1a0dd4f
Merged-In: Ibe18750829665b6dcf6e36628a5e5bbdd1a0dd4f
2018-11-12 13:42:28 -08:00
Haibo Huang
f71edfad1c Separate libc_common to two targets
Adds libc_common_static and libc_common_shared targets. So that static
and shared objects can use different libraries.

In following changes I'll add dynamic dispatch code to
libc_common_shared.

Test: compile and run bionic unit test.
Change-Id: I056742fdf8af76ed7deb274c515951656b176fcb
2018-11-12 10:10:31 -08:00
Elliott Hughes
8251d4419f Add lp32 and lp64 shorthands to SYSCALLS.TXT.
Bug: N/A
Test: updating the generated stubs is a no-op
Change-Id: I7f6f9bcfd8c054f0a2d7e5f488eacb88cefb8d15
2018-11-09 13:57:34 -08:00
Florian Mayer
0dbe6d1aec System property for heapprofd at process startup.
Test: m
Test: flash sailfish
Test: setprop heapprofd.enable 1;
      setprop heapprofd.enable.ls 1;
      ls;

Bug: 117821125

Change-Id: I4a42e430e5e1e194a22f83683061751aa5dfe7ff
2018-11-09 12:00:24 +00:00
Ken Chen
b9de32f6f0 Merge "Free memory when it is no more used" 2018-11-09 03:28:44 +00:00
Ken Chen
f945716bf9 Free memory when it is no more used
Memory leak happen when Android data framework updates identical DNS
information to netd.

(cherrypick of c466fe95dc641d879683700aea4233ffd42bc762.)

Bug: 115595601
Test: netd_unit_test, netd_integration_test
Change-Id: Idcc0956729286563603f482258f488a1ccd75e6a
2018-11-08 13:29:13 -08:00
Josh Gao
8fd93e6ea5 Merge "Increase the size of the signal stack on 64-bit." 2018-11-08 21:24:51 +00:00
Josh Gao
f90687c4ec Increase the size of the signal stack on 64-bit.
The signal stack is sufficiently large for a single invocation of the
signal handler, but in cases where the signal handler needs to recurse,
(e.g. if our address space is limited by RLIMIT_AS), it's too small for
us to get to the part where we recognize that we've recursed and bail
out.

Bug: http://b/118772392
Test: /data/nativetest64/debuggerd_test/debuggerd_test64 --gtest_filter=CrasherTest.seccomp_crash_oom
Change-Id: Ic7a2cf8b01b3f7ea7f4a2318a3ec22a0c3649da6
2018-11-08 21:24:31 +00:00
Elliott Hughes
bf925b0580 Merge "Remove obsolete workaround." 2018-11-08 20:09:49 +00:00
Neil Fuller
10265a8cbe Merge "Finalize the name of the apex package" 2018-11-08 08:18:59 +00:00
Chih-hung Hsieh
b3fe0136d8 Merge "Revert "Disable lld, libc_malloc_debug failed to boot."" 2018-11-08 04:59:14 +00:00
Chih-hung Hsieh
56794421fc Revert "Disable lld, libc_malloc_debug failed to boot."
This reverts commit 0e87940961.

Reason for revert: This should have been fixed.
Bug: 78118944

Change-Id: I796ff2420ec3682dd54a059175a8428868b75c23
2018-11-07 23:49:37 +00:00
Neil Fuller
fd522d0132 Finalize the name of the apex package
The package name in the manifest.json is changing to
remove apex so the hardcoded path must change.

Bug: 119026403
Test: build
Change-Id: I906b595a1325b40f8af8c37d7d08cd543c988cc8
2018-11-07 15:42:43 +00:00
Elliott Hughes
eadf50601b Remove obsolete workaround.
Bug: b/37423073
Test: builds
Change-Id: Ib0ad58abc7303967a80bb933501cc1247bb36385
2018-11-06 11:17:34 -08:00
Elliott Hughes
8178c417f6 ART isn't using the ART-specific linker features any more.
Bug: N/A
Test: ran tests
Change-Id: Ide3c295035687019608a2c4716a4a21cb889d121
2018-11-06 11:15:17 -08:00
Logan Chien
0c39bd468d Merge "Add bionic/libc/include to exported_include_dirs" 2018-11-05 08:20:42 +00:00
Neil Fuller
6d1c5cab94 Merge "Changes to support loading tz data from APEX" 2018-11-02 22:34:50 +00:00
Logan Chien
833cbe4b1c Add bionic/libc/include to exported_include_dirs
This commit adds "include" (full path: "bionic/libc/include") to
exported_include_dirs for libc.  Without this change,
header-abi-checker will strip all functions from ABI dumps.

Bug: 117963950
Test: libc.so.lsdump has a non-empty functions array
Change-Id: I192a4ec0251f1320ced56c6201818076ebd2a2da
2018-11-02 13:21:03 +08:00
nuccachen
8d65a81fb6 getnameinfo: Don't add flag NI_NUMERICHOST for well-known prefix address
Currently, getnameinfo() will never issue a reverse DNS lookup if the first
byte of the IPv6 address is 0x00. This means it is not possible to do a
reverse DNS lookup for a NAT64 address if the NAT64 prefix is the well-known
prefix. Make this possible by treating the well-known prefix specially. This
is not needed for unicast NAT64 prefixes because they do not start with 0x00.

Bug: 78545619
Test: netd_{unit,integration}_test pass
Test: bionic-unit-tests --gtest_filter='net*' pass
Change-Id: I176d30dcf411a5ffe1eec110db99cd73b48e956f
2018-11-01 16:40:34 +08:00
Josh Gao
6f3a56bb18 Merge "Revert "bionic: Allocate a shadow call stack for each thread."" 2018-11-01 01:32:00 +00:00
Treehugger Robot
d6ac79300d Merge "Reverse two pthread_internal_t fields" 2018-10-30 23:31:15 +00:00
Neil Fuller
7dfeaf896d Changes to support loading tz data from APEX
The changes needed to pick up time zone data files from
a mounted APEX directory. Code that looks for time zone
data now looks in a new location after checking for
data installed by the time zone updates via APK feature.

This hasn't been tested in combination with a real APEX but
it shouldn't do anything bad if the new path does not exist.

Bug: 115612964
Test: CTS: run cts-dev -m CtsBionicTests
Test: Build / boot without APEX support
Change-Id: I56ae50e26f2cbfa0e537029a0e6f679fa2394327
2018-10-30 20:19:35 +00:00
Ryan Prichard
25c34e0feb Reverse two pthread_internal_t fields
The golang runtime currently expects to find the pthread key data after
the tls slots.

Bug: http://b/78026329
Bug: http://b/118381796
Test: run a golang-based app, bionic unit tests
Change-Id: Idc777d809b803093e1c81d9a2ce4eafcc7d61f8d
Merged-In: Idc777d809b803093e1c81d9a2ce4eafcc7d61f8d
(cherry picked from commit a2c30723da)
2018-10-30 12:30:21 -07:00
Christopher Ferris
9ce28844db Update to v4.19 kernel headers.
Test: Builds and boots.
Change-Id: I99a9ed79666e143b47f02ca4e59eed94f69b7e4a
(cherry picked from commit a981e2e52e)
2018-10-30 09:21:16 -07:00
Florian Mayer
e898a17e8f Merge "Allow to re-initialize heapprofd." 2018-10-30 11:34:17 +00:00
Peter Collingbourne
7b13dd918e Revert "bionic: Allocate a shadow call stack for each thread."
This reverts commit da1bc79f93.

Reason for revert: Caused OOM in media process

Bug: 112907825
Bug: 118593766
Change-Id: I545663871d75889b209b9fd2131cdaa97166478f
2018-10-29 21:48:59 +00:00
Peter Collingbourne
f284a47544 Merge "bionic: Allocate a shadow call stack for each thread." 2018-10-29 21:05:25 +00:00
Peter Collingbourne
da1bc79f93 bionic: Allocate a shadow call stack for each thread.
Bug: 112907825
Change-Id: I7c1479a0cd68696739bf6aa5e0700ba4f2a137ec
Merged-In: I7c1479a0cd68696739bf6aa5e0700ba4f2a137ec
2018-10-29 19:55:18 +00:00
Florian Mayer
176a47594e Allow to re-initialize heapprofd.
Without this change, any process can only be profiled by heapprofd
once.

Change-Id: I2d0f50eebcc3b219750354ccdc4ea22a2e39c4b6
2018-10-29 12:24:15 +00:00
Christopher Ferris
debcd02d18 Merge "Fix handling of #elif." 2018-10-27 04:42:02 +00:00
Christopher Ferris
f2484aaed7 Fix handling of #elif.
When a construct like:

if defined(something)
  blocks1
elif 1
  blocks2
else
  blocks3
endif

The parser would put the first clause but then simply omit the elif and
put all of blocks2 without a terminating #endif. The code also did
something similar when the #else was an #endif.

Also convert all of the unit tests to real unit tests and only run
them if you run cpp.py by itself. Added new unit tests to cover the
new cases.

Test: Ran cpp.py unit tests.
Test: Reran update_all.py and verified nothing changed, and that running
Test: it on the new kernel headers that exposed this problem.
Change-Id: Ie168511303c4e15afdb60c37baef75a966ca29a8
2018-10-26 22:42:26 +00:00
Logan Chien
90856af78b Merge changes I70ea4b23,Iedcfe36b,I3f21fc71,Ie99c0eef
* changes:
  libc: Match header annotations to version script
  versioner: Build SymbolDatabase from version scripts
  versioner: Add 28 to version list
  libc: Add default __STRING implementation
2018-10-26 01:33:06 +00:00
Treehugger Robot
2bfe37afc8 Merge "Move Bionic slots to the end of pthread_internal_t" 2018-10-26 00:49:21 +00:00
Ryan Prichard
29d6dbc906 Move Bionic slots to the end of pthread_internal_t
With ELF TLS, the static linker assumes that an executable's TLS segment
is at a known offset from the thread pointer (i.e. __get_tls()). The
segment can be located prior to the TP (variant 2, x86[_64], sparc) or
after it (variant 1, arm{32,64}, ppc, mips, ia64, riscv).

We can't make our pthread_internal_t exactly follow the ordinary arm64
ABI (at least) because TP[5] is used for clang's -fstack-protector on
Android. Instead, reserve extra space after the TP (up to 16 words), which
will be followed by the executable's TLS segment.

Bug: http://b/78026329
Test: boot device, bionic unit tests
Change-Id: I0f3b270b793f9872ba0effeac03f4dec364438d6
Merged-In: I0f3b270b793f9872ba0effeac03f4dec364438d6
(cherry picked from commit f397317e96)
2018-10-25 23:31:17 +00:00
Elliott Hughes
5e62b34c0d Clean up bionic_macros.h a bit.
Use <android-base/macros.h> instead where possible, and move the bionic
macros out of the way of the libbase ones. Yes, there are folks who manage
to end up with both included at once (thanks OpenGL!), and cleaning that
up doesn't seem nearly as practical as just making this change.

Bug: N/A
Test: builds
Change-Id: I23fc544f39d5addf81dc61471771a5438778895b
2018-10-25 11:00:00 -07:00
Logan Chien
25bcf59cb3 libc: Match header annotations to version script
According to `libc.map.txt`, `pselect64()` was introduced since API
level 28. This commit adds the annotations to `sys/select.h`.

Bug: 113263746
Test: ./bionic/tools/versioner/run_tests.py
Change-Id: I70ea4b23cef92857f1654cebb660e0219238fc95
2018-10-25 14:54:44 +08:00
Elliott Hughes
6032c38fb3 Merge "Add getloadavg(3)." 2018-10-24 16:31:21 +00:00
Christopher Ferris
8daea556e9 Comment the M_PURGE option.
Test: Compiles.
Change-Id: Ib9e6f9a3f4b57a930a1ec5c149d273663f97a443
2018-10-23 13:43:48 -07:00
Elliott Hughes
2d0b28bc0d Add getloadavg(3).
Lets us build ninja with bionic.

Bug: N/A
Test: ran tests
Change-Id: I97eef1247d794b58a2b9aee4851551632e5a4e48
2018-10-23 11:23:00 -07:00
Christopher Ferris
7562f1ab87 Merge "malloc: add M_PURGE mallopt flag" 2018-10-23 16:36:16 +00:00
Logan Chien
aede30d316 libc: Add default __STRING implementation
This commit defines a default `__STRING()` definition.  There should be
a default definition because the unit test cases of versioner will
include `android/versioning.h` directly.  We cannot include
`sys/cdefs.h` in `android/versioning.h` either because that will lead to
circular inclusion.

Bug: 113263746
Test: ./bionic/tools/versioner/run_tests.py
Change-Id: Ie99c0eef4414fd687347baf3a2d295468877464f
2018-10-23 21:47:34 +08:00
Dan Willemsen
d4e51a155a Change crtbrand for host bionic
Fixes a build error when PLATFORM_SDK_VERSION is not set.

Bug: 31559095
Test: attempt to build host bionic
Change-Id: I9cbdcea206ef1239c330a5adafbfa5cc797fef5e
2018-10-22 17:15:22 -07:00
Tim Murray
ac578f2587 malloc: add M_PURGE mallopt flag
Add a new mallopt flag that purges any pending decaying pages.

Test: boots and works
bug 117795621

Change-Id: Ib250ae2b705b6a368c1efb801d6a7be54e075acb
(cherry pciekd from commit 5083e833a6)
2018-10-22 16:25:28 -07:00
Florian Mayer
f7f71e3c7b Add RT signal to load heapprofd library.
Tests: Ran malloc_debug_unit_tests
Tests: Flashed to walleye, sent signal, observed
  "Unable to open shared library: heapprofd.so".

Change-Id: Ia8ce216837e29e3edbda8789ca28023d53fa1fda
2018-10-18 21:38:06 +01:00
Josh Gao
7ff7d03286 Merge "Properly fail with ESRCH when pthread_killing an exited thread." 2018-10-18 17:47:17 +00:00
Josh Gao
ddf757e35e Properly fail with ESRCH when pthread_killing an exited thread.
Previously, we were callign tgkill(pid, 0, signal) instead, which would
fail with EINVAL instead.

Test: bionic-unit-tests
Change-Id: I25b127dcf347e0223274502b0516a950b6c2093e
2018-10-17 17:35:56 -07:00
Elliott Hughes
eb61430374 Don't #define __ANDROID_NDK__ for the platform build!
Caused an ODR violation trying to build current ToT of toybox.

Bug: N/A
Test: can successfully build code with `#ifdef __ANDROID_NDK__`
Change-Id: Ia80b8889b267779ee01f6257744e1794db0ebc65
2018-10-17 14:27:36 -07:00
Treehugger Robot
ecf0c7515d Merge "strerror: add missing ERFKILL and EHWPOISON." 2018-10-15 23:56:22 +00:00
Treehugger Robot
daf746b155 Merge "fdsan: reset va_list between varargs traversals" 2018-10-15 21:05:44 +00:00
Elliott Hughes
92a9116100 strerror: add missing ERFKILL and EHWPOISON.
There's little value to having strings for these, but we may as well
for consistency. There's no ELASTERRNO constant we can use to check
whether we've fallen behind again, but these were added in 2009 and
2011 respectively, so we're not likely to have to deal with any more
new errno values any time soon...

Bug: http://b/117755069
Test: ran tests
Change-Id: I5b7155c22cad92c2fe03a0b4c7cae415c37fa186
2018-10-15 13:12:19 -07:00
Greg Hackmann
cc953e08f4 fdsan: reset va_list between varargs traversals
When error_level != ANDROID_FDSAN_ERROR_LEVEL_FATAL, fdsan_error()
traverses the varargs twice.  Each traversal needs its own
va_start()/va_end() pair.  Otherwise async_safe_format_buffer_va_list()
will start consuming arguments where async_safe_format_log_va_list()
stopped, ironically causing the sanitizer runtime to perform bad memory
accesses.

Test: debuggerd_test32
Test: debuggerd_test64

Change-Id: Ic85ca94501e55e9a435410fab89edb273c381a5a
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2018-10-15 10:41:34 -07:00
Haibo Huang
bc4f411138 Add support for A76 in bionic
A76 still uses A55 as little core. It should be ok to use the same
setting as A75 for now.

Bug: 117125298
Test: run bionic tests
Change-Id: Idfd15424c20ae60becb6539f6ae855f3e7c264cd
2018-10-12 23:55:06 +00:00
Treehugger Robot
391af2cefe Merge "Allow invoking the linker on an executable." 2018-10-11 01:04:57 +00: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
Josh Gao
069d5aef90 Merge "Block TIMER_SIGNAL in sigprocmask(SIG_SETMASK, ...)." 2018-10-10 20:38:46 +00:00
Elliott Hughes
d3aa44f7e9 Merge "Add _SC_UIO_MAXIOV as a synonym for _SC_IOV_MAX." 2018-10-10 16:40:46 +00:00
Josh Gao
baf20fc912 Block TIMER_SIGNAL in sigprocmask(SIG_SETMASK, ...).
Previously, we were zeroing out the reserved signals, when we actually
wanted to have TIMER_SIGNAL always be blocked, and the other signals
always be unblocked. This resulted in process termination when a
SIGEV_THREAD timer callback calls sigprocmask(SIG_SETMASK, ...) with
any signal mask value, and then subsequently fails to complete its
callback and reach the sigtimedwait in bionic before the next timer
iteration triggers.

Add a how argument to filter_reserved_signals to appropriately
block/unblock our reserved signals.

Bug: http://b/116783733
Test: bionic-unit-tests32/64
Change-Id: Ie5339682cdeb914711cd4089cd26ee395704d0df
2018-10-09 16:27:22 -07:00
Elliott Hughes
82ab481123 Add _SC_UIO_MAXIOV as a synonym for _SC_IOV_MAX.
glibc and musl both have these as synonyms for one another, so we may
as well do the same and get backwards compatibility on old OS releases.

Bug: N/A
Test: ran tests
Change-Id: I6bf38ea446560e1b11022ff539f07eb67c157049
2018-10-09 13:56:06 -07:00
Ryan Prichard
5de9a31c05 Add async_safe_format_fd_va_list
Bug: none
Test: bionic unit tests
Change-Id: I8c6b2d1d118f4182dd7bf1cbfba78f20b3cefc79
2018-10-08 13:27:16 -07:00
Elliott Hughes
00dda09c08 <sys/param.h>: pollute the namespace with <endian.h>.
glibc does, and autoconf relies on that for its AC_C_BIGENDIAN test.

Bug: N/A
Test: N/A
Change-Id: I3acaaf0d7a69e8ed4e64239e4fe7f21c7001e717
2018-10-05 14:54:48 -07:00
Elliott Hughes
9ebcb013b1 Merge "Another round of documentation." 2018-10-05 21:04:15 +00:00
Elliott Hughes
dd6763a6c6 Another round of documentation.
Bug: N/A
Test: N/A
Change-Id: I1b818fbb36ddd6d084dee56828290c2717a0c9b0
2018-10-04 16:35:13 -07:00
Christopher Ferris
6774cc5b99 Add new parameter for creation of MapInfo object.
Bug: 109657296

Test: Unit tests pass.
Change-Id: Ie33b50234fa9ba2c5107c3eb0da36a466bba1589
2018-10-04 08:41:10 -07:00
Elliott Hughes
8d63ae128f Merge "Make fclose/pclose distinct." 2018-10-02 16:57:11 +00:00
Elliott Hughes
22917f63ee Make fclose/pclose distinct.
I failed to convince the compiler/linker to just refrain (via factoring out,
attribute `noinline`, or meddling with `--icf=none`), but luckily I noticed
that we should have CHECK_FP in each function for a better error message,
and the distinct error messages keep the two functions apart.

(Also add a missing CHECK_FP to `clearerr_unlocked`.)

Bug: http://b/116969207
Test: manual with a modified `crasher`
Change-Id: Ic122e90e94f7e22f486be57d3dac7137a225d682
2018-10-01 16:17:37 -07:00
Treehugger Robot
ddf92a1ba5 Merge "Always return /vendor/bin/sh as shell for OEM ids in getpwnam() etc." 2018-09-27 23:23:34 +00:00
Colin Cross
6b755755bc Merge "Disable STL for crt objects" 2018-09-27 23:23:19 +00:00
Tom Cherry
fa5f61c8d9 Always return /vendor/bin/sh as shell for OEM ids in getpwnam() etc.
During the review of the script that generates /vendor/etc/passwd, it
was suggested that the shell be /vendor/bin/sh instead of the typical
/system/bin/sh.  This has subsequently caused bionic unit tests to
fail, since they always check that the shell is set to /system/bin/sh.

In the spirit of that review, libc is modified to return
/vendor/bin/sh for the OEM AID ranges and the test is updated to
expect this.

Test: bionic unit tests
Change-Id: Ie7c1c48fde8a71b3df1aa0ef112d42ab7bd3baec
2018-09-27 20:29:49 +00:00
Colin Cross
ab17944178 Disable STL for crt objects
cc_objects are getting support for STL headers, disable them for
crt objects to avoid a circular dependency through libc++.

Test: m checkbuild
Change-Id: I4e0f4a2193ce98ec4b8802492add9014ec0dba98
2018-09-27 11:03:22 -07:00
Elliott Hughes
b177085ce7 Add reallocarray(3).
Originally a BSD extension, now in glibc too. We've used it internally
for a while.

(cherry-pick of e4b13f7e3ca68edfcc5faedc5e7d4e13c4e8edb9.)

Bug: http://b/112163459
Test: ran tests
Change-Id: I813c3a62b13ddb91ba41e32a5a853d09207ea6bc
Merged-In: I813c3a62b13ddb91ba41e32a5a853d09207ea6bc
2018-09-26 14:24:18 -07:00
Treehugger Robot
8f5589faf2 Merge "Remove unused NetBSD compatibility cruft." 2018-09-21 01:06:32 +00:00
Evgenii Stepanov
8d11bea6c5 Merge "[hwasan] Tweak process and thread initialization." 2018-09-20 21:39:55 +00:00
Elliott Hughes
64f8e7b1cc Remove unused NetBSD compatibility cruft.
Bug: N/A
Test: builds
Change-Id: I5c472c7b5c570c739363b4a454251ebf0324d43c
2018-09-20 13:27:41 -07:00
Josh Gao
ce9d653b38 Merge changes from topics "fdsan_ziparchive_type", "fdsan_java_socket"
* changes:
  fdsan: improve documentation.
  fdsan: add type for libziparchive's ZipArchive.
  fdsan: add types for Java sockets.
2018-09-20 19:22:03 +00:00
Evgenii Stepanov
13e8dcbdc9 [hwasan] Tweak process and thread initialization.
Make sure that TLS_SLOT_TSAN is always available and correctly set up in
HWASan-instrumented functions by setting up the tls register and running hwasan
initialization (__hwasan_init in the main thread and __hwasan_thread_enter in
secondary) early enough.

This is needed to accomodate a change in HWASan: https://reviews.llvm.org/D52249

Bug: 112438058
Test: boot with SANITIZE_TARGET=hwaddress, run bionic-tests
Change-Id: Icd909a4ea0da6c6c1095522bcc28debef5f2c63d
2018-09-20 12:20:12 -07:00
Elliott Hughes
15711c1dd0 Remove dead code.
I stumbled across this because I was looking at the various locks in libc.

Bug: N/A
Test: ran tests
Change-Id: I77c9954f49aaae7519ea7f4917bbe6f138b841ad
2018-09-18 14:28:48 -07:00
Josh Gao
5fa9df8efc fdsan: add type for libziparchive's ZipArchive.
Test: debuggerd `pidof system_server` | grep " fd "
Change-Id: I6a9a4306ecffe3899e4cc7285a0eb33efaa62616
2018-09-18 13:23:31 -07:00
Josh Gao
d527cf1f99 fdsan: add types for Java sockets.
Test: art/tools/run-libcore-tests.sh
Change-Id: If61211bc4ae225c3f89db989a167f9dc4fce375a
2018-09-17 17:31:58 -07:00
Robert Sesek
74cdb253ba Move pipe, open, and getdents from the APP to COMMON seccomp whitelist.
These system calls are required by Breakpad for crash reporting.
WebViews are spawned from the webview_zygote, which itself is spawned
from the app_process zygote. The webview_zygote gets the SYSTEM seccomp
policy applied because it is not an app, and so the WebView sandboxed
processes inherit that policy.

In Ifd8a85b0de2eb6f2a76a6458570fc03b020a90ab, these system calls were
moved from COMMON to APP, which breaks Breakpad/crash reporting for
WebView sandboxed processes.

Bug: 112572914
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 "google-breakpad"
      error messages.

Change-Id: I1cf56ae85b1a67ec91e979bc7e0f941726a9cc0e
2018-09-11 19:20:34 -04:00
Bernie Innocenti
fb4eaa019e Improve netd detection
The alleged improvement consists in making the detection actually work
when netd is spawned by init, which of course uses the full path.
I had tested the previous logic by running netd from the shell, which
worked because argv[0] was just set to "netd". My bad -_-

Test: flash, boot and grep logcat for "Skipping libnetd_client init"
Change-Id: Ie5f11436dfa2a9347721147dc2b980144452404a
2018-09-07 10:29:18 -07:00
Elliott Hughes
431d2ff141 Merge "Add android_get_device_api_level." 2018-09-07 15:40:45 +00:00
Orion Hodson
dca7d3fae5 Merge "libc: Add membarrier to common seccomp allowed list" 2018-09-07 09:46:08 +00:00
Treehugger Robot
dc91d900ae Merge "bionic: Add magic to abort message" 2018-09-07 01:32:14 +00:00
Elliott Hughes
e15e93a247 Merge "Use strerror_r(3) for the printf family %m." 2018-09-06 23:45:18 +00:00
Luis Hector Chavez
6d93c60778 bionic: Add magic to abort message
This change adds a 128-bit magic value just before the abort message
(and its length). This allows Chrome OS crash collector (which cannot
reliably correlate a crash with its corresponding tombstone) to extract
the abort message from the core dump.

Bug: 62387553
Test: /data/nativetest{,64}/debuggerd_test/*
Test: /data/nativetest{,64}/bionic-unit-tests{,-static}/*

Change-Id: I69ff021d773b3a10081ab16ddf6f23233320fb02
2018-09-06 15:18:21 -07:00
Treehugger Robot
a2a114ba26 Merge "Annotate siglongjmp for HWASan." 2018-09-06 21:35:09 +00:00
Elliott Hughes
ce934e3d9b Add android_get_device_api_level.
Bug: http://b/113615412
Test: ran tests
Change-Id: I0a7ae336c96c9ed6543b6935cbc242d14d4a4a67
2018-09-06 14:19:46 -07:00
Elliott Hughes
f340a56d1c Use strerror_r(3) for the printf family %m.
There's TLS space used for unknown errno values, and a call to printf
shouldn't clobber that. No-one will ever hit this in real life, but
since it's easily fixed...

Bug: http://b/112776560
Test: ran tests
Change-Id: I8c2437f2e5214e652119791d4e162a197b049d5b
2018-09-06 10:42:40 -07:00
Orion Hodson
6ba6694ec2 libc: Add membarrier to common seccomp allowed list
Allows ART JIT use membarrier to invalidate instruction
pipelines.

Bug: 66095511
Test: bionic-unit-tests
Change-Id: I8cf83929f00baf5a3c440a899d2667a992bda8e2
2018-09-06 16:36:09 +01:00
Evgenii Stepanov
b16e9ce7b8 Annotate siglongjmp for HWASan.
HWASan needs to re-tag the newly unallocated stack space to match SP.

Bug: 112438058
Test: SANITIZE_TARGET=hwaddress

Change-Id: I4dddef542d802d63bdea59e32a03425a2c4f870b
2018-09-05 13:37:14 -07:00
Elliott Hughes
74934aaf10 Merge "Add the %m GNU extension to printf/wprintf." 2018-09-05 18:47:44 +00:00
Treehugger Robot
198fb7b6df Merge "Prevent netd from using the libnetd_client wrappers" 2018-09-05 15:22:59 +00:00
Bernie Innocenti
1b2ecee5da Prevent netd from using the libnetd_client wrappers
Netd looping connections to itself via the libnetd_client connect()
wrapper has always unintended, although it worked until now. Once we
move the resolver into netd, the frequency of connect() calls will
increase, which makes it less acceptable.

There are several ways to detect if the calling process is netd.
Checking both uid == 0 and the argv[0] == netd makes it hard for
non-system components to spoof as netd.

Test: flash a device and check that netd logs the "Skipping..." message
Test: atest netd_integration_test
Change-Id: I9506facb4aa3094b16a98a913a1e2394056ce91a
2018-09-05 17:43:42 +09:00
Treehugger Robot
c69757a2d5 Merge "Generalize abort's inline_tgkill, use it in fdsan." 2018-09-04 21:59:54 +00:00
Evgenii Stepanov
0425a2db07 Merge "(arm64) Extend branch range in __memcpy_chk." 2018-09-04 20:28:44 +00:00
Josh Gao
f5693c688d Generalize abort's inline_tgkill, use it in fdsan.
Convert abort's inline_tgkill to do the equivalent of
pthread_sigqueue(pthread_self(), ...), so that we can use it in fdsan
as well.

Test: bionic-unit-tests
Test: debuggerd_test32
Test: debuggerd_test64
Change-Id: I92a7b84e2f00ce021b4043ed8a3bd8683d77fe9c
2018-08-31 16:39:23 -07:00
Evgenii Stepanov
00d087c629 (arm64) Extend branch range in __memcpy_chk.
Conditional branch has limited range (1MB) and can not be extended by
the linker. The current distance (in walleye build) is 500KB, about
half of the maximum. HWASan pushes it over the limit.

Replace conditional branch with regular branch, which has longer
range (26 vs 19 bits offset) and can be extended in the linker if
needed.

Bug: 112437884
Bug: 12231437
Test: SANITIZE_TARGET=hwaddress

Change-Id: Idc083fb557ab3a859541beb009809992406a6703
2018-08-31 15:02:12 -07:00
Josh Gao
ab6a0802af fdsan: add type for ART's FdFile.
Bug: http://b/113558485
Test: none
Change-Id: I9bc874d8689cc54563f2a5878d324b27ad85060e
2018-08-30 17:37:52 -07:00
Elliott Hughes
654cd8331b Add the %m GNU extension to printf/wprintf.
And remove the local hack from syslog(3).

Bug: http://b/112776560
Test: ran tests
Change-Id: I5807e729a978df26187ea0ee255bba4ca74220c8
2018-08-30 16:00:42 -07:00
Elliott Hughes
222ce95c8a Remove ARM/MIPS fenv duplication.
Bug: http://b/32709207
Test: ran tests
Change-Id: I58d354e9f8b1e6023427ba271bf39e4e24b7f8ab
2018-08-30 09:26:43 -07:00
Treehugger Robot
003521af47 Merge "Document the set*id functions." 2018-08-28 22:52:31 +00:00
Treehugger Robot
6ef10547e9 Merge "Accept NULL for fds parameter in poll." 2018-08-28 22:41:25 +00:00
Chih-Hung Hsieh
4be542629a Accept NULL for fds parameter in poll.
* Some callers, e.g. external/curl/lib/select.c, do
  poll(NULL, 0, ...) and get clang-diagnostic-nonnull check error.

Test: build with WITH_TIDY=1
Bug: 111850071
Change-Id: I7ea433d185cb84011a954f05964181b5518febd4
2018-08-28 14:20:15 -07:00
Josh Gao
cd524ca71f Merge changes from topic "fdsan_abort_msg"
* changes:
  fdsan: provide abort message in warning tombstones.
  Implement pthread_sigqueue.
  Stringify api_level in <android/versioning.h>.
  Delete archaic pre-ANSI C support.
2018-08-28 20:20:21 +00:00
Treehugger Robot
ec247245de Merge changes from topic "bionic_fdsan_java"
* changes:
  fdsan: make the tag type values sequential.
  fdsan: expose functions to get and interpret tags.
2018-08-28 20:17:59 +00:00
Elliott Hughes
9c6017778b Document the set*id functions.
In particular, document the fact that they only affect the calling thread
on Android.

Bug: http://b/13134174
Test: ran tests
Change-Id: Ica6af451400d47e24358f59495ded63b2110eb8b
2018-08-28 12:17:20 -07:00
Treehugger Robot
24107698b4 Merge "Add fdsan owner type for sqlite." 2018-08-28 00:16:34 +00:00
Josh Gao
be66a06412 fdsan: provide abort message in warning tombstones.
Bug: http://b/112770187
Test: debuggerd_test
Test: bionic-unit-tests
Test: crasher fdsan_file
Change-Id: I55e18eafaee8b0c35bacd2795b7830bcb9d59291
2018-08-27 16:48:17 -07:00
Josh Gao
726b63f725 Implement pthread_sigqueue.
Bug: http://b/112770187
Test: bionic-unit-tests
Change-Id: I03382cd5df2490b2e87265dba9007e2cb1b14cd2
2018-08-27 16:48:17 -07:00
Josh Gao
f3aa3007e3 Stringify api_level in <android/versioning.h>.
Make it so that we can use __ANDROID_API_<letter>__ constants in
__INTRODUCED_IN macros.

Test: treehugger
Change-Id: I0929c01e23e58f51d12f73200e1daf5ef484ea5d
2018-08-27 16:48:17 -07:00
Josh Gao
1dc2503e1a Delete archaic pre-ANSI C support.
Test: treehugger
Change-Id: I02e7887a18d947e657f32760d57e58f8b3295fd8
2018-08-27 16:48:15 -07:00
Elliott Hughes
062eac88b5 <sys/socket.h>: add constant for kernel TLS.
Bug: N/A
Test: builds
Change-Id: I53e8dde1131fec781bee5371c03d4eb54cab9722
2018-08-27 11:27:06 -07:00
Elliott Hughes
4b9379c889 Merge "Start documenting libc." 2018-08-24 17:16:53 +00:00
Josh Gao
c1b4476808 fdsan: make the tag type values sequential.
In retrospect, allocating tag types from both ends will just make the
future creation of user-defined tags harder, because constants that are
introduced, and then used in previous versions might collide with
user-defined tags. Move all of the tag values to the front, so that we
can allocate from the end to minimize this.

Test: bionic_unit_tests
Change-Id: I5063adf8301b1063bd4931a6ce8b70dfe2411efd
2018-08-23 23:10:52 -07:00
Josh Gao
27cc4bc414 Add fdsan owner type for sqlite.
Test: none
Change-Id: Ib331d108e7e0431250eba3609f3557d8e4665aba
2018-08-23 23:10:52 -07:00
Josh Gao
b6b3a1d4f9 fdsan: expose functions to get and interpret tags.
Make it easier to write tests in users of fdsan by exposing functions
to allow users to get and interpret the tags.

Test: bionic_unit_tests
Change-Id: Iafa9bcaeb5e4db230f3dfec6f483274f34602694
2018-08-23 23:10:52 -07:00
Elliott Hughes
462e90cf4d Start documenting libc.
Bug: N/A
Test: N/A
Change-Id: I17345cb72a5ffc3af1688cf5874589cfb1e1fea0
2018-08-23 11:03:17 -07:00
Treehugger Robot
780cc6b189 Merge "Folks are starting to need a placeholder name for Q." 2018-08-22 20:11:19 +00:00
Elliott Hughes
cf97d7f121 Folks are starting to need a placeholder name for Q.
Better to just have one place to update...

Bug: N/A
Test: builds
Change-Id: If7135d26f498b0841f9ae505bf6ca3ed05767345
2018-08-22 10:50:29 -07:00
Elliott Hughes
99d54656bd Add PR_SET_VMA and PR_SET_VMA_ANON_NAME to <sys/prctl.h>.
We've copied & pasted these to too many places. And if we're going to
have another go at upstreaming these, that's probably yet another reason
to have the *values* in just one place. (Even if upstream wants different
names, we'll likely keep the legacy names around for a while for source
compatibility.)

Bug: http://b/111903542
Test: ran tests
Change-Id: I8ccc557453d69530e5b74f865cbe0b458c84e3ba
2018-08-22 10:36:23 -07:00
Adhemerval Zanella
65a6211f4d [AArch64] Improve strncmp for mutually misaligned inputs
This patch was originally written by Siddhesh Poyarekar and pushed on
cortex-strings [1]. The mutually misaligned inputs on aarch64 are
compared with a simple byte copy, which is not very efficient.
This patch enhances the comparison similar to strcmp by loading a
double-word at a time.

Comparison on the default bionic and proposed optimized routines
shows the following performance improvements on A54 (using the
new proposed memcmp input data from test_strncmp.xml):

  - No noticeable change on aligned inputs or with same alignment.

  - Large improvements on unaligned inputs from sizes larger than
    16 bytes.

Benchmark                               Time             CPU      Time Old      Time New       CPU Old       CPU New
--------------------------------------------------------------------------------------------------------------------
BM_string_strncmp/1/0/0              -0.0954         -0.0954            19            17            19            17
BM_string_strncmp/2/0/0              -0.0344         -0.0344            19            18            19            18
BM_string_strncmp/3/0/0              +0.1768         +0.1768            15            18            15            18
BM_string_strncmp/4/0/0              -0.0344         -0.0344            19            18            19            18
BM_string_strncmp/5/0/0              -0.0344         -0.0344            19            18            19            18
BM_string_strncmp/6/0/0              +0.1589         +0.1589            15            18            15            18
BM_string_strncmp/7/0/0              -0.0344         -0.0344            19            18            19            18
BM_string_strncmp/8/0/0              -0.0998         -0.0998            19            17            19            17
BM_string_strncmp/9/0/0              -0.0277         -0.0277            23            22            23            22
BM_string_strncmp/10/0/0             -0.0270         -0.0270            23            22            23            22
BM_string_strncmp/11/0/0             -0.0331         -0.0331            23            22            23            22
BM_string_strncmp/12/0/0             -0.0270         -0.0270            23            22            23            22
BM_string_strncmp/13/0/0             -0.0284         -0.0284            23            22            23            22
BM_string_strncmp/14/0/0             +0.1042         +0.1042            20            22            20            22
BM_string_strncmp/15/0/0             -0.0277         -0.0277            23            22            23            22
BM_string_strncmp/16/0/0             +0.0214         +0.0215            22            22            22            22
BM_string_strncmp/24/0/0             -0.1291         -0.1291            24            21            24            21
BM_string_strncmp/32/0/0             -0.0470         -0.0470            27            26            27            26
BM_string_strncmp/40/0/0             -0.0433         -0.0433            29            28            29            28
BM_string_strncmp/48/0/0             -0.0301         -0.0301            31            30            31            30
BM_string_strncmp/56/0/0             -0.0800         -0.0800            33            31            33            31
BM_string_strncmp/64/0/0             +0.0188         +0.0188            34            34            34            34
BM_string_strncmp/72/0/0             -0.0334         -0.0334            38            37            38            37
BM_string_strncmp/80/0/0             -0.0000         -0.0000            40            40            40            40
BM_string_strncmp/88/0/0             +0.0413         +0.0413            61            64            61            64
BM_string_strncmp/96/0/0             -0.0215         -0.0216            69            67            69            67
BM_string_strncmp/104/0/0            -0.0208         -0.0208            72            70            72            70
BM_string_strncmp/112/0/0            -0.0173         -0.0173            75            74            75            74
BM_string_strncmp/120/0/0            -0.0166         -0.0166            78            77            78            77
BM_string_strncmp/128/0/0            -0.0158         -0.0158            81            80            81            80
BM_string_strncmp/136/0/0            -0.0149         -0.0149            84            83            84            83
BM_string_strncmp/144/0/0            -0.0201         -0.0201            88            86            88            86
BM_string_strncmp/160/0/0            -0.0136         -0.0136            94            93            94            93
BM_string_strncmp/176/0/0            +0.0224         +0.0224            96            98            96            98
BM_string_strncmp/192/0/0            +0.0289         +0.0289           102           105           102           105
BM_string_strncmp/208/0/0            +0.0101         +0.0101           111           112           111           112
BM_string_strncmp/224/0/0            -0.0107         -0.0107           119           118           119           118
BM_string_strncmp/240/0/0            -0.0088         -0.0088           126           125           126           125
BM_string_strncmp/256/0/0            -0.0101         -0.0101           132           131           132           131
BM_string_strncmp/512/0/0            -0.0056         -0.0056           235           233           235           233
BM_string_strncmp/1024/0/0           -0.0030         -0.0030           439           437           439           437
BM_string_strncmp/8192/0/0           -0.0431         -0.0431          3799          3635          3799          3635
BM_string_strncmp/16384/0/0          -0.0069         -0.0069          6778          6732          6779          6732
BM_string_strncmp/32768/0/0          -0.0001         -0.0002         13405         13403         13405         13403
BM_string_strncmp/65536/0/0          +0.0005         +0.0005         26968         26981         26968         26981
BM_string_strncmp/131072/0/0         -0.0057         -0.0057         53959         53650         53958         53650
BM_string_strncmp/1/4/0              -0.1352         -0.1352            12            10            12            10
BM_string_strncmp/2/4/0              +0.0020         +0.0020            15            15            15            15
BM_string_strncmp/3/4/0              -0.1560         -0.1560            20            17            20            17
BM_string_strncmp/4/4/0              +0.0296         +0.0296            22            22            22            22
BM_string_strncmp/5/4/0              +0.0573         +0.0573            22            23            22            23
BM_string_strncmp/6/4/0              -0.0340         -0.0340            25            24            25            24
BM_string_strncmp/7/4/0              +0.0185         +0.0185            26            26            26            26
BM_string_strncmp/8/4/0              -0.0050         -0.0050            27            27            27            27
BM_string_strncmp/9/4/0              -0.1294         -0.1294            28            24            28            24
BM_string_strncmp/10/4/0             +0.0109         +0.0109            29            29            29            29
BM_string_strncmp/11/4/0             -0.0000         -0.0001            30            30            30            30
BM_string_strncmp/12/4/0             +0.0055         +0.0055            50            50            50            50
BM_string_strncmp/13/4/0             -0.0249         -0.0249            51            50            51            50
BM_string_strncmp/14/4/0             -0.0289         -0.0289            53            52            53            52
BM_string_strncmp/15/4/0             -0.0205         -0.0205            55            54            55            54
BM_string_strncmp/16/4/0             -0.4616         -0.4616            57            31            57            31
BM_string_strncmp/24/4/0             -0.4871         -0.4871            72            37            72            37
BM_string_strncmp/32/4/0             -0.5549         -0.5549            87            39            87            39
BM_string_strncmp/40/4/0             -0.5964         -0.5964           103            42           103            42
BM_string_strncmp/48/4/0             -0.6647         -0.6647           118            40           118            40
BM_string_strncmp/56/4/0             -0.6551         -0.6551           134            46           134            46
BM_string_strncmp/64/4/0             -0.6609         -0.6609           145            49           145            49
BM_string_strncmp/72/4/0             -0.5709         -0.5710           164            70           164            70
BM_string_strncmp/80/4/0             -0.5929         -0.5929           180            73           180            73
BM_string_strncmp/88/4/0             -0.6051         -0.6051           195            77           195            77
BM_string_strncmp/96/4/0             -0.6160         -0.6160           210            81           210            81
BM_string_strncmp/104/4/0            -0.6199         -0.6199           223            85           223            85
BM_string_strncmp/112/4/0            -0.6293         -0.6293           240            89           240            89
BM_string_strncmp/120/4/0            -0.6439         -0.6439           255            91           255            91
BM_string_strncmp/128/4/0            -0.6493         -0.6493           271            95           271            95
BM_string_strncmp/136/4/0            -0.6704         -0.6704           287            95           287            95
BM_string_strncmp/144/4/0            -0.6744         -0.6744           302            98           302            98
BM_string_strncmp/160/4/0            -0.6700         -0.6700           333           110           333           110
BM_string_strncmp/176/4/0            -0.6821         -0.6821           364           116           364           116
BM_string_strncmp/192/4/0            -0.6887         -0.6887           394           123           394           123
BM_string_strncmp/208/4/0            -0.6949         -0.6949           425           130           425           130
BM_string_strncmp/224/4/0            -0.7069         -0.7069           456           134           456           134
BM_string_strncmp/240/4/0            -0.7042         -0.7042           486           144           486           144
BM_string_strncmp/256/4/0            -0.7043         -0.7043           514           152           514           152
BM_string_strncmp/1/0/4              +0.0227         +0.0227            14            14            14            14
BM_string_strncmp/2/0/4              +0.0442         +0.0442            15            16            15            16
BM_string_strncmp/3/0/4              +0.5829         +0.5829            17            27            17            27
BM_string_strncmp/4/0/4              -0.1593         -0.1593            22            19            22            19
BM_string_strncmp/5/0/4              -0.0516         -0.0516            23            22            23            22
BM_string_strncmp/6/0/4              -0.1684         -0.1684            25            20            25            20
BM_string_strncmp/7/0/4              +0.0170         +0.0170            26            26            26            26
BM_string_strncmp/8/0/4              +0.0006         +0.0006            27            27            27            27
BM_string_strncmp/9/0/4              +0.1272         +0.1272            25            28            25            28
BM_string_strncmp/10/0/4             +0.0108         +0.0108            29            29            29            29
BM_string_strncmp/11/0/4             -0.0001         -0.0001            30            30            30            30
BM_string_strncmp/12/0/4             -0.3557         -0.3557            50            32            50            32
BM_string_strncmp/13/0/4             -0.3370         -0.3370            51            34            51            34
BM_string_strncmp/14/0/4             -0.3444         -0.3444            53            35            53            35
BM_string_strncmp/15/0/4             +0.0946         +0.0946            51            56            51            56
BM_string_strncmp/16/0/4             -0.5203         -0.5203            53            25            53            25
BM_string_strncmp/24/0/4             -0.6109         -0.6109            72            28            72            28
BM_string_strncmp/32/0/4             -0.6934         -0.6934            88            27            88            27
BM_string_strncmp/40/0/4             -0.6833         -0.6833           103            33           103            33
BM_string_strncmp/48/0/4             -0.6973         -0.6973           118            36           118            36
BM_string_strncmp/56/0/4             -0.7116         -0.7116           134            39           134            39
BM_string_strncmp/64/0/4             -0.6017         -0.6018           149            59           149            59
BM_string_strncmp/72/0/4             -0.6268         -0.6268           164            61           164            61
BM_string_strncmp/80/0/4             -0.6409         -0.6409           179            64           179            64
BM_string_strncmp/88/0/4             -0.6465         -0.6465           195            69           195            69
BM_string_strncmp/96/0/4             -0.6551         -0.6551           210            72           210            72
BM_string_strncmp/104/0/4            -0.6662         -0.6662           227            76           227            76
BM_string_strncmp/112/0/4            -0.6700         -0.6700           240            79           240            79
BM_string_strncmp/120/0/4            -0.6740         -0.6740           256            83           256            83
BM_string_strncmp/128/0/4            -0.6862         -0.6862           271            85           271            85
BM_string_strncmp/136/0/4            -0.6883         -0.6883           287            89           287            89
BM_string_strncmp/144/0/4            -0.7031         -0.7031           297            88           297            88
BM_string_strncmp/160/0/4            -0.6985         -0.6985           333           100           333           100
BM_string_strncmp/176/0/4            -0.7082         -0.7082           364           106           364           106
BM_string_strncmp/192/0/4            -0.7223         -0.7223           396           110           396           110
BM_string_strncmp/208/0/4            -0.7135         -0.7135           421           121           421           121
BM_string_strncmp/224/0/4            -0.7194         -0.7194           455           128           455           128
BM_string_strncmp/240/0/4            -0.7233         -0.7233           487           135           487           135
BM_string_strncmp/256/0/4            -0.7239         -0.7239           516           143           516           143
BM_string_strncmp/1/4/4              +0.0224         +0.0225            21            22            21            22
BM_string_strncmp/2/4/4              -0.0001         -0.0001            22            22            22            22
BM_string_strncmp/3/4/4              -0.0001         -0.0001            22            22            22            22
BM_string_strncmp/4/4/4              -0.0435         -0.0435            22            21            22            21
BM_string_strncmp/5/4/4              -0.0118         -0.0118            27            27            27            27
BM_string_strncmp/6/4/4              -0.0118         -0.0118            27            27            27            27
BM_string_strncmp/7/4/4              -0.0117         -0.0117            27            27            27            27
BM_string_strncmp/8/4/4              -0.0118         -0.0118            27            27            27            27
BM_string_strncmp/9/4/4              -0.0117         -0.0117            27            27            27            27
BM_string_strncmp/10/4/4             +0.1447         +0.1447            23            27            23            27
BM_string_strncmp/11/4/4             -0.0062         -0.0062            27            27            27            27
BM_string_strncmp/12/4/4             -0.0454         -0.0454            28            27            28            27
BM_string_strncmp/13/4/4             -0.1507         -0.1507            29            24            29            24
BM_string_strncmp/14/4/4             -0.0003         -0.0003            29            29            29            29
BM_string_strncmp/15/4/4             -0.0002         -0.0003            29            29            29            29
BM_string_strncmp/16/4/4             +0.0047         +0.0047            29            29            29            29
BM_string_strncmp/24/4/4             -0.0104         -0.0104            31            30            31            30
BM_string_strncmp/32/4/4             -0.0290         -0.0290            33            32            33            32
BM_string_strncmp/40/4/4             -0.0189         -0.0189            34            33            34            33
BM_string_strncmp/48/4/4             -0.0059         -0.0059            36            36            36            36
BM_string_strncmp/56/4/4             +0.0000         +0.0000            39            39            39            39
BM_string_strncmp/64/4/4             +0.0000         +0.0000            42            42            42            42
BM_string_strncmp/72/4/4             +0.0000         +0.0000            45            45            45            45
BM_string_strncmp/80/4/4             +0.0391         +0.0392            65            68            65            68
BM_string_strncmp/88/4/4             -0.0090         -0.0090            71            70            71            70
BM_string_strncmp/96/4/4             -0.0034         -0.0034            74            74            74            74
BM_string_strncmp/104/4/4            -0.0482         -0.0482            77            73            77            73
BM_string_strncmp/112/4/4            +0.0387         +0.0387            77            80            77            80
BM_string_strncmp/120/4/4            -0.0072         -0.0073            84            83            84            83
BM_string_strncmp/128/4/4            -0.0071         -0.0071            87            86            87            86
BM_string_strncmp/136/4/4            +0.0366         +0.0366            86            89            86            89
BM_string_strncmp/144/4/4            -0.0068         -0.0068            93            93            93            93
BM_string_strncmp/160/4/4            -0.0064         -0.0064           100            99           100            99
BM_string_strncmp/176/4/4            -0.0063         -0.0063           106           105           106           105
BM_string_strncmp/192/4/4            -0.0012         -0.0012           112           112           112           112
BM_string_strncmp/208/4/4            -0.0098         -0.0098           119           118           119           118
BM_string_strncmp/224/4/4            -0.0050         -0.0050           125           125           125           125
BM_string_strncmp/240/4/4            -0.0060         -0.0060           132           131           132           131
BM_string_strncmp/256/4/4            -0.0046         -0.0046           138           137           138           137

[1] Commit id: 26cc4faec37a55529e5d0a39949f7b6ec81008f9

Test: bionic tests and benchmarks on aarch64.
Change-Id: Ied579d2044b4092fc95fad486af6541d1eb71dc3
2018-08-21 19:50:09 +00:00
Treehugger Robot
2019f96247 Merge "HWASan support in bionic." 2018-08-21 19:42:36 +00:00
Adhemerval Zanella
b42ff1b5c3 [AArch64] Improve strcmp performance for misaligned strings
This patch was originally written by Siddhesh Poyarekar and pushed on
cortex-strings [1]. Replace the simple byte-wise compare in the
misaligned case with a dword compare with page boundary checks in
place. For simplicity its uses a 4K page boundary so that it does not
have to query the actual page size on the system.

Comparison on the default bionic and proposed optimized routines
shows the following performance improvements on A64 (using the
new proposed memcmp input data from test_strcmp.xml):

  - Small improvement for aligned arguments with sizes up to 56 bytes
    (from 10% to 20%).

  - Large improvements for unaligned arguments for small sizes (from
    3 to 256 bytes).

Benchmark                              Time             CPU      Time Old      Time New       CPU Old       CPU New
-------------------------------------------------------------------------------------------------------------------
BM_string_strcmp/1/0/0              +0.0034         +0.0034            11            11            11            11
BM_string_strcmp/2/0/0              +0.0000         +0.0000            11            11            11            11
BM_string_strcmp/3/0/0              -0.1726         -0.1726            11             9            11             9
BM_string_strcmp/4/0/0              -0.1726         -0.1726            11             9            11             9
BM_string_strcmp/5/0/0              -0.1726         -0.1726            11             9            11             9
BM_string_strcmp/6/0/0              -0.1719         -0.1719            11             9            11             9
BM_string_strcmp/7/0/0              -0.1724         -0.1724            11             9            11             9
BM_string_strcmp/8/0/0              -0.1718         -0.1718            11             9            11             9
BM_string_strcmp/9/0/0              -0.2008         -0.2008            16            13            16            13
BM_string_strcmp/10/0/0             -0.2008         -0.2008            16            13            16            13
BM_string_strcmp/11/0/0             -0.2040         -0.2040            16            13            16            13
BM_string_strcmp/12/0/0             -0.1991         -0.1991            16            13            16            13
BM_string_strcmp/13/0/0             -0.1997         -0.1997            16            13            16            13
BM_string_strcmp/14/0/0             -0.1988         -0.1989            16            13            16            13
BM_string_strcmp/15/0/0             -0.2006         -0.2006            16            13            16            13
BM_string_strcmp/16/0/0             -0.2043         -0.2043            16            13            16            13
BM_string_strcmp/24/0/0             -0.1927         -0.1927            18            15            18            15
BM_string_strcmp/32/0/0             -0.1743         -0.1743            20            17            20            17
BM_string_strcmp/40/0/0             -0.1427         -0.1427            22            19            22            19
BM_string_strcmp/48/0/0             -0.1053         -0.1053            24            22            24            22
BM_string_strcmp/56/0/0             -0.0805         -0.0805            26            24            26            24
BM_string_strcmp/64/0/0             -0.0454         -0.0454            28            27            28            27
BM_string_strcmp/72/0/0             -0.0303         -0.0303            30            29            30            29
BM_string_strcmp/80/0/0             -0.0111         -0.0111            32            32            32            32
BM_string_strcmp/88/0/0             -0.0004         -0.0004            34            34            34            34
BM_string_strcmp/96/0/0             -0.0058         -0.0058            37            37            37            37
BM_string_strcmp/104/0/0            +0.0000         +0.0000            40            40            40            40
BM_string_strcmp/112/0/0            -0.0457         -0.0457            61            58            61            58
BM_string_strcmp/120/0/0            -0.0486         -0.0487            61            58            61            58
BM_string_strcmp/128/0/0            -0.0499         -0.0499            64            61            64            61
BM_string_strcmp/136/0/0            -0.0529         -0.0529            66            63            66            63
BM_string_strcmp/144/0/0            -0.0492         -0.0492            69            66            69            66
BM_string_strcmp/160/0/0            -0.0459         -0.0459            74            71            74            71
BM_string_strcmp/176/0/0            -0.0400         -0.0401            79            76            79            76
BM_string_strcmp/192/0/0            -0.0378         -0.0378            85            81            85            81
BM_string_strcmp/208/0/0            -0.0009         -0.0009            89            89            89            89
BM_string_strcmp/224/0/0            -0.0003         -0.0003            95            95            95            95
BM_string_strcmp/240/0/0            -0.0320         -0.0320           100            96           100            96
BM_string_strcmp/256/0/0            -0.0303         -0.0304           105           102           105           102
BM_string_strcmp/512/0/0            -0.0171         -0.0171           187           183           187           183
BM_string_strcmp/1024/0/0           -0.0091         -0.0091           350           347           350           347
BM_string_strcmp/8192/0/0           -0.0030         -0.0031          2668          2660          2668          2660
BM_string_strcmp/16384/0/0          +0.0007         +0.0007          5449          5452          5448          5452
BM_string_strcmp/32768/0/0          +0.0635         +0.0635         10868         11558         10867         11557
BM_string_strcmp/65536/0/0          -0.0017         -0.0017         21824         21786         21822         21784
BM_string_strcmp/131072/0/0         +0.0012         +0.0012         43485         43536         43480         43532
BM_string_strcmp/1/4/0              +0.7630         +0.7630             7            12             7            12
BM_string_strcmp/2/4/0              +0.9265         +0.9265            12            23            12            23
BM_string_strcmp/3/4/0              -0.0000         -0.0000            14            14            14            14
BM_string_strcmp/4/4/0              +0.0372         +0.0372            19            19            19            19
BM_string_strcmp/6/4/0              -0.0921         -0.0921            20            19            20            19
BM_string_strcmp/7/4/0              -0.0291         -0.0291            19            19            19            19
BM_string_strcmp/8/4/0              +0.0648         +0.0648            20            22            20            22
BM_string_strcmp/9/4/0              +0.0001         -0.0055            22            22            22            22
BM_string_strcmp/10/4/0             -0.1924         -0.1924            23            19            23            19
BM_string_strcmp/11/4/0             -0.2347         -0.2347            24            19            24            19
BM_string_strcmp/12/4/0             -0.2738         -0.2739            26            19            26            19
BM_string_strcmp/13/4/0             -0.3804         -0.3804            42            26            42            26
BM_string_strcmp/14/4/0             -0.3581         -0.3582            41            26            41            26
BM_string_strcmp/15/4/0             -0.3905         -0.3905            43            26            43            26
BM_string_strcmp/16/4/0             -0.4068         -0.4068            44            26            44            26
BM_string_strcmp/24/4/0             -0.4917         -0.4917            57            29            57            29
BM_string_strcmp/32/4/0             -0.5607         -0.5607            70            31            70            31
BM_string_strcmp/40/4/0             -0.5940         -0.5940            82            33            82            33
BM_string_strcmp/48/4/0             -0.5303         -0.5302            95            45            95            45
BM_string_strcmp/56/4/0             -0.4975         -0.4975           108            54           108            54
BM_string_strcmp/64/4/0             -0.5167         -0.5167           121            58           121            58
BM_string_strcmp/72/4/0             -0.5325         -0.5325           133            62           133            62
BM_string_strcmp/80/4/0             -0.5523         -0.5523           146            65           146            65
BM_string_strcmp/88/4/0             -0.5686         -0.5686           159            69           159            69
BM_string_strcmp/96/4/0             -0.5815         -0.5815           172            72           172            72
BM_string_strcmp/104/4/0            -0.5931         -0.5931           185            75           185            75
BM_string_strcmp/112/4/0            -0.6046         -0.6046           197            78           197            78
BM_string_strcmp/120/4/0            -0.6113         -0.6113           210            82           210            82
BM_string_strcmp/128/4/0            -0.6186         -0.6186           223            85           223            85
BM_string_strcmp/136/4/0            -0.6278         -0.6278           237            88           237            88
BM_string_strcmp/144/4/0            -0.6410         -0.6410           253            91           253            91
BM_string_strcmp/160/4/0            -0.6506         -0.6506           280            98           280            98
BM_string_strcmp/176/4/0            -0.6593         -0.6593           304           104           304           104
BM_string_strcmp/192/4/0            -0.6647         -0.6647           330           111           330           111
BM_string_strcmp/208/4/0            -0.6741         -0.6741           357           116           357           116
BM_string_strcmp/224/4/0            -0.6761         -0.6761           381           123           381           123
BM_string_strcmp/240/4/0            -0.6824         -0.6824           406           129           406           129
BM_string_strcmp/256/4/0            -0.6846         -0.6846           432           136           432           136
BM_string_strcmp/1/0/4              +1.0024         +1.0024             7            14             7            14
BM_string_strcmp/2/0/4              +0.1591         +0.1591            12            14            12            14
BM_string_strcmp/3/0/4              -0.0015         -0.0015            14            14            14            14
BM_string_strcmp/4/0/4              -0.0809         -0.0809            15            14            15            14
BM_string_strcmp/5/0/4              -0.1535         -0.1536            17            14            17            14
BM_string_strcmp/6/0/4              -0.2111         -0.2111            18            14            18            14
BM_string_strcmp/7/0/4              -0.2650         -0.2650            19            14            19            14
BM_string_strcmp/8/0/4              -0.3118         -0.3118            20            14            20            14
BM_string_strcmp/9/0/4              -0.1741         -0.1740            22            18            22            18
BM_string_strcmp/10/0/4             -0.2201         -0.2201            23            18            23            18
BM_string_strcmp/11/0/4             -0.2610         -0.2610            24            18            24            18
BM_string_strcmp/12/0/4             -0.2987         -0.2987            26            18            26            18
BM_string_strcmp/13/0/4             -0.5748         -0.5748            42            18            42            18
BM_string_strcmp/14/0/4             -0.5796         -0.5796            43            18            43            18
BM_string_strcmp/15/0/4             -0.6167         -0.6167            47            18            47            18
BM_string_strcmp/16/0/4             -0.6303         -0.6303            49            18            49            18
BM_string_strcmp/24/0/4             -0.6557         -0.6557            61            21            61            21
BM_string_strcmp/32/0/4             -0.6612         -0.6612            70            24            70            24
BM_string_strcmp/40/0/4             -0.6812         -0.6813            82            26            82            26
BM_string_strcmp/48/0/4             -0.6974         -0.6974            95            29            95            29
BM_string_strcmp/56/0/4             -0.7151         -0.7151           108            31           108            31
BM_string_strcmp/64/0/4             -0.5717         -0.5717           121            52           121            52
BM_string_strcmp/72/0/4             -0.5927         -0.5927           134            54           134            54
BM_string_strcmp/80/0/4             -0.6004         -0.6004           146            58           146            58
BM_string_strcmp/88/0/4             -0.6145         -0.6145           159            61           159            61
BM_string_strcmp/96/0/4             -0.6287         -0.6287           172            64           172            64
BM_string_strcmp/104/0/4            -0.6351         -0.6351           185            67           185            67
BM_string_strcmp/112/0/4            -0.6423         -0.6423           197            71           197            71
BM_string_strcmp/120/0/4            -0.6489         -0.6489           210            74           210            74
BM_string_strcmp/128/0/4            -0.6578         -0.6578           223            76           223            76
BM_string_strcmp/136/0/4            -0.6597         -0.6597           236            80           236            80
BM_string_strcmp/144/0/4            -0.6674         -0.6674           250            83           250            83
BM_string_strcmp/160/0/4            -0.6751         -0.6751           274            89           274            89
BM_string_strcmp/176/0/4            -0.6798         -0.6798           300            96           300            96
BM_string_strcmp/192/0/4            -0.6873         -0.6855           327           102           325           102
BM_string_strcmp/208/0/4            -0.6903         -0.6903           351           109           351           109
BM_string_strcmp/224/0/4            -0.6907         -0.6907           376           116           376           116
BM_string_strcmp/240/0/4            -0.6897         -0.6897           402           125           402           125
BM_string_strcmp/256/0/4            -0.6937         -0.6937           427           131           427           131
BM_string_strcmp/1/4/4              +0.0009         +0.0009            14            14            14            14
BM_string_strcmp/2/4/4              -0.2229         -0.2229            14            11            14            11
BM_string_strcmp/3/4/4              -0.2256         -0.2256            14            11            14            11
BM_string_strcmp/4/4/4              -0.2241         -0.2240            14            11            14            11
BM_string_strcmp/5/4/4              -0.2220         -0.2220            20            15            20            15
BM_string_strcmp/6/4/4              -0.2267         -0.2267            20            15            20            15
BM_string_strcmp/7/4/4              -0.2228         -0.2227            20            15            20            15
BM_string_strcmp/8/4/4              -0.2219         -0.2219            20            15            20            15
BM_string_strcmp/9/4/4              -0.2220         -0.2220            20            15            20            15
BM_string_strcmp/10/4/4             -0.2227         -0.2227            20            15            20            15
BM_string_strcmp/11/4/4             -0.2210         -0.2210            20            15            20            15
BM_string_strcmp/12/4/4             -0.2224         -0.2224            20            15            20            15
BM_string_strcmp/13/4/4             -0.1778         -0.1778            21            17            21            17
BM_string_strcmp/14/4/4             -0.1863         -0.1863            21            17            21            17
BM_string_strcmp/15/4/4             -0.1780         -0.1780            21            17            21            17
BM_string_strcmp/16/4/4             +0.0031         +0.0031            21            21            21            21
BM_string_strcmp/24/4/4             +0.0041         +0.0041            24            24            24            24
BM_string_strcmp/32/4/4             -0.0001         -0.0000            25            25            25            25
BM_string_strcmp/40/4/4             +0.0016         +0.0016            26            26            26            26
BM_string_strcmp/48/4/4             +0.0001         +0.0001            28            28            28            28
BM_string_strcmp/56/4/4             -0.0001         -0.0001            30            30            30            30
BM_string_strcmp/64/4/4             -0.0342         -0.0342            32            31            32            31
BM_string_strcmp/72/4/4             -0.0186         -0.0186            34            34            34            34
BM_string_strcmp/80/4/4             +0.0004         +0.0004            36            36            36            36
BM_string_strcmp/88/4/4             -0.0000         -0.0000            39            39            39            39
BM_string_strcmp/96/4/4             -0.0510         -0.0510            62            59            62            59
BM_string_strcmp/104/4/4            -0.0502         -0.0502            63            60            63            60
BM_string_strcmp/112/4/4            -0.0490         -0.0490            65            62            65            62
BM_string_strcmp/120/4/4            -0.0387         -0.0387            67            65            67            65
BM_string_strcmp/128/4/4            -0.0426         -0.0426            70            67            70            67
BM_string_strcmp/136/4/4            -0.0408         -0.0408            73            70            73            70
BM_string_strcmp/144/4/4            -0.0194         -0.0194            75            74            75            74
BM_string_strcmp/160/4/4            -0.0035         -0.0035            81            81            81            81
BM_string_strcmp/176/4/4            -0.0001         -0.0001            86            86            86            86
BM_string_strcmp/192/4/4            -0.0002         -0.0002            91            91            91            91
BM_string_strcmp/208/4/4            -0.0335         -0.0335            96            93            96            93
BM_string_strcmp/224/4/4            -0.0314         -0.0314           101            98           101            98
BM_string_strcmp/240/4/4            -0.0303         -0.0303           106           103           106           103
BM_string_strcmp/256/4/4            -0.0288         -0.0288           111           108           111           108

[1] Commit id: f98f2a6780d686ca3d44f8011c7823d42d9b083a

Test: bionic tests and benchmarks on aarch64.
Change-Id: I75f8948782b8bd459d21f15e75e1d420905f5e5a
2018-08-21 17:48:52 +00:00
Adhemerval Zanella
4ab56af82d [AArch64] Optimize memcmp for medium to large sizes
This patch was originally written by Siddhesh Poyarekar and pushed on
cortex-strings [1]. This improved memcmp provides a fast path for
compares up to 16 bytes and then compares 16 bytes at a time, thus
optimizing loads from both sources.

Comparison on the default bionic and proposed optimized routines
shows the following performance improvements on A72 (using the
new proposed memcmp input data from test_memcmp.xml):

Benchmark                               Time             CPU      Time Old      Time New       CPU Old       CPU New
--------------------------------------------------------------------------------------------------------------------
BM_string_memcmp/1/0/0               -0.2074         -0.2074            15            12            15            12
BM_string_memcmp/2/0/0               -0.5193         -0.5193            31            15            31            15
BM_string_memcmp/3/0/0               -0.1291         -0.1291            19            17            19            17
BM_string_memcmp/4/0/0               -0.2889         -0.2889            17            12            17            12
BM_string_memcmp/5/0/0               -0.2606         -0.2606            15            11            15            11
BM_string_memcmp/6/0/0               -0.1656         -0.1655            17            14            17            14
BM_string_memcmp/7/0/0               -0.1721         -0.1721            19            15            19            15
BM_string_memcmp/8/0/0               -0.3048         -0.3048            15            10            15            10
BM_string_memcmp/9/0/0               -0.3041         -0.3041            15            10            15            10
BM_string_memcmp/10/0/0              -0.3040         -0.3040            15            10            15            10
BM_string_memcmp/11/0/0              -0.3048         -0.3048            15            10            15            10
BM_string_memcmp/12/0/0              -0.3041         -0.3041            15            10            15            10
BM_string_memcmp/13/0/0              -0.3040         -0.3040            15            10            15            10
BM_string_memcmp/14/0/0              -0.3048         -0.3048            15            10            15            10
BM_string_memcmp/15/0/0              -0.3040         -0.3040            15            10            15            10
BM_string_memcmp/16/0/0              -0.3041         -0.3041            15            10            15            10
BM_string_memcmp/24/0/0              -0.1209         -0.1209            15            13            15            13
BM_string_memcmp/32/0/0              -0.3228         -0.3228            20            13            20            13
BM_string_memcmp/40/0/0              -0.2937         -0.2937            22            15            22            15
BM_string_memcmp/48/0/0              -0.3299         -0.3299            23            15            23            15
BM_string_memcmp/56/0/0              -0.1845         -0.1845            24            20            24            20
BM_string_memcmp/64/0/0              -0.2247         -0.2247            26            20            26            20
BM_string_memcmp/72/0/0              -0.1947         -0.1947            27            22            27            22
BM_string_memcmp/80/0/0              -0.2275         -0.2275            28            22            28            22
BM_string_memcmp/88/0/0              -0.2360         -0.2360            29            22            29            22
BM_string_memcmp/96/0/0              -0.2675         -0.2675            31            22            31            22
BM_string_memcmp/104/0/0             -0.2559         -0.2559            32            24            32            24
BM_string_memcmp/112/0/0             -0.2787         -0.2786            33            24            33            24
BM_string_memcmp/120/0/0             -0.2599         -0.2599            34            25            34            25
BM_string_memcmp/128/0/0             -0.2860         -0.2860            35            25            35            25
BM_string_memcmp/136/0/0             -0.4708         -0.4708            53            28            53            28
BM_string_memcmp/144/0/0             -0.4719         -0.4719            53            28            53            28
BM_string_memcmp/160/0/0             -0.4680         -0.4680            56            30            56            30
BM_string_memcmp/176/0/0             -0.4645         -0.4645            60            32            60            32
BM_string_memcmp/192/0/0             -0.4641         -0.4641            63            34            63            34
BM_string_memcmp/208/0/0             -0.4555         -0.4555            66            36            66            36
BM_string_memcmp/224/0/0             -0.4558         -0.4557            69            38            69            38
BM_string_memcmp/240/0/0             -0.4534         -0.4534            72            40            72            40
BM_string_memcmp/256/0/0             -0.4463         -0.4463            75            42            75            42
BM_string_memcmp/512/0/0             -0.3077         -0.3077           126            88           126            88
BM_string_memcmp/1024/0/0            -0.3493         -0.3493           229           149           229           149
BM_string_memcmp/8192/0/0            -0.4173         -0.4173          1729          1007          1729          1007
BM_string_memcmp/16384/0/0           -0.3855         -0.3855          3377          2076          3377          2075
BM_string_memcmp/32768/0/0           -0.2968         -0.2968          6847          4815          6847          4814
BM_string_memcmp/65536/0/0           -0.2496         -0.2496         13715         10292         13714         10291
BM_string_memcmp/131072/0/0          -0.2676         -0.2676         27354         20033         27351         20031
BM_string_memcmp/262144/0/0          -0.2319         -0.2319         54604         41943         54598         41939
BM_string_memcmp/524288/0/0          -0.2359         -0.2359        109225         83460        109212         83449
BM_string_memcmp/1048576/0/0         -0.0439         -0.0439        423367        404791        423251        404686
BM_string_memcmp/2097152/0/0         -0.0023         -0.0024        762470        760701        761956        760122
BM_string_memcmp/512/4/4             -0.2853         -0.2853           125            89           125            89
BM_string_memcmp/1024/4/4            -0.3377         -0.3377           228           151           227           151
BM_string_memcmp/8192/4/4            -0.4083         -0.4083          1706          1009          1706          1009
BM_string_memcmp/16384/4/4           -0.3853         -0.3853          3376          2075          3376          2075
BM_string_memcmp/32768/4/4           -0.2974         -0.2974          6846          4810          6845          4810
BM_string_memcmp/65536/4/4           -0.2485         -0.2485         13619         10235         13618         10234
BM_string_memcmp/131072/4/4          -0.2387         -0.2387         27056         20597         27054         20595
BM_string_memcmp/512/4/0             -0.2898         -0.2898           123            88           123            88
BM_string_memcmp/1024/4/0            -0.3401         -0.3401           225           149           225           149
BM_string_memcmp/8192/4/0            -0.4167         -0.4167          1727          1007          1727          1007
BM_string_memcmp/16384/4/0           -0.3820         -0.3820          3384          2092          3384          2091
BM_string_memcmp/32768/4/0           -0.2535         -0.2535          6886          5141          6886          5140
BM_string_memcmp/65536/4/0           -0.1897         -0.1897         13850         11223         13849         11223
BM_string_memcmp/131072/4/0          -0.1972         -0.1972         27536         22106         27533         22104
BM_string_memcmp/512/0/4             -0.2854         -0.2854           125            89           125            89
BM_string_memcmp/1024/0/4            -0.3332         -0.3333           226           151           226           151
BM_string_memcmp/8192/0/4            -0.4199         -0.4199          1740          1009          1740          1009
BM_string_memcmp/16384/0/4           -0.3811         -0.3811          3383          2094          3383          2094
BM_string_memcmp/32768/0/4           -0.2409         -0.2409          6900          5238          6899          5237
BM_string_memcmp/65536/0/4           -0.1920         -0.1920         13922         11250         13921         11248
BM_string_memcmp/131072/0/4          -0.2029         -0.2029         27699         22079         27697         22077

I see similar improvements on A54 as well:

Benchmark                               Time             CPU      Time Old      Time New       CPU Old       CPU New
--------------------------------------------------------------------------------------------------------------------
BM_string_memcmp/1/0/0               -0.2074         -0.2074            15            12            15            12
BM_string_memcmp/2/0/0               -0.5193         -0.5193            31            15            31            15
BM_string_memcmp/3/0/0               -0.1291         -0.1291            19            17            19            17
BM_string_memcmp/4/0/0               -0.2889         -0.2889            17            12            17            12
BM_string_memcmp/5/0/0               -0.2606         -0.2606            15            11            15            11
BM_string_memcmp/6/0/0               -0.1656         -0.1655            17            14            17            14
BM_string_memcmp/7/0/0               -0.1721         -0.1721            19            15            19            15
BM_string_memcmp/8/0/0               -0.3048         -0.3048            15            10            15            10
BM_string_memcmp/9/0/0               -0.3041         -0.3041            15            10            15            10
BM_string_memcmp/10/0/0              -0.3040         -0.3040            15            10            15            10
BM_string_memcmp/11/0/0              -0.3048         -0.3048            15            10            15            10
BM_string_memcmp/12/0/0              -0.3041         -0.3041            15            10            15            10
BM_string_memcmp/13/0/0              -0.3040         -0.3040            15            10            15            10
BM_string_memcmp/14/0/0              -0.3048         -0.3048            15            10            15            10
BM_string_memcmp/15/0/0              -0.3040         -0.3040            15            10            15            10
BM_string_memcmp/16/0/0              -0.3041         -0.3041            15            10            15            10
BM_string_memcmp/24/0/0              -0.1209         -0.1209            15            13            15            13
BM_string_memcmp/32/0/0              -0.3228         -0.3228            20            13            20            13
BM_string_memcmp/40/0/0              -0.2937         -0.2937            22            15            22            15
BM_string_memcmp/48/0/0              -0.3299         -0.3299            23            15            23            15
BM_string_memcmp/56/0/0              -0.1845         -0.1845            24            20            24            20
BM_string_memcmp/64/0/0              -0.2247         -0.2247            26            20            26            20
BM_string_memcmp/72/0/0              -0.1947         -0.1947            27            22            27            22
BM_string_memcmp/80/0/0              -0.2275         -0.2275            28            22            28            22
BM_string_memcmp/88/0/0              -0.2360         -0.2360            29            22            29            22
BM_string_memcmp/96/0/0              -0.2675         -0.2675            31            22            31            22
BM_string_memcmp/104/0/0             -0.2559         -0.2559            32            24            32            24
BM_string_memcmp/112/0/0             -0.2787         -0.2786            33            24            33            24
BM_string_memcmp/120/0/0             -0.2599         -0.2599            34            25            34            25
BM_string_memcmp/128/0/0             -0.2860         -0.2860            35            25            35            25
BM_string_memcmp/136/0/0             -0.4708         -0.4708            53            28            53            28
BM_string_memcmp/144/0/0             -0.4719         -0.4719            53            28            53            28
BM_string_memcmp/160/0/0             -0.4680         -0.4680            56            30            56            30
BM_string_memcmp/176/0/0             -0.4645         -0.4645            60            32            60            32
BM_string_memcmp/192/0/0             -0.4641         -0.4641            63            34            63            34
BM_string_memcmp/208/0/0             -0.4555         -0.4555            66            36            66            36
BM_string_memcmp/224/0/0             -0.4558         -0.4557            69            38            69            38
BM_string_memcmp/240/0/0             -0.4534         -0.4534            72            40            72            40
BM_string_memcmp/256/0/0             -0.4463         -0.4463            75            42            75            42
BM_string_memcmp/512/0/0             -0.3077         -0.3077           126            88           126            88
BM_string_memcmp/1024/0/0            -0.3493         -0.3493           229           149           229           149
BM_string_memcmp/8192/0/0            -0.4173         -0.4173          1729          1007          1729          1007
BM_string_memcmp/16384/0/0           -0.3855         -0.3855          3377          2076          3377          2075
BM_string_memcmp/32768/0/0           -0.2968         -0.2968          6847          4815          6847          4814
BM_string_memcmp/65536/0/0           -0.2496         -0.2496         13715         10292         13714         10291
BM_string_memcmp/131072/0/0          -0.2676         -0.2676         27354         20033         27351         20031
BM_string_memcmp/262144/0/0          -0.2319         -0.2319         54604         41943         54598         41939
BM_string_memcmp/524288/0/0          -0.2359         -0.2359        109225         83460        109212         83449
BM_string_memcmp/1048576/0/0         -0.0439         -0.0439        423367        404791        423251        404686
BM_string_memcmp/2097152/0/0         -0.0023         -0.0024        762470        760701        761956        760122
BM_string_memcmp/512/4/4             -0.2853         -0.2853           125            89           125            89
BM_string_memcmp/1024/4/4            -0.3377         -0.3377           228           151           227           151
BM_string_memcmp/8192/4/4            -0.4083         -0.4083          1706          1009          1706          1009
BM_string_memcmp/16384/4/4           -0.3853         -0.3853          3376          2075          3376          2075
BM_string_memcmp/32768/4/4           -0.2974         -0.2974          6846          4810          6845          4810
BM_string_memcmp/65536/4/4           -0.2485         -0.2485         13619         10235         13618         10234
BM_string_memcmp/131072/4/4          -0.2387         -0.2387         27056         20597         27054         20595
BM_string_memcmp/512/4/0             -0.2898         -0.2898           123            88           123            88
BM_string_memcmp/1024/4/0            -0.3401         -0.3401           225           149           225           149
BM_string_memcmp/8192/4/0            -0.4167         -0.4167          1727          1007          1727          1007
BM_string_memcmp/16384/4/0           -0.3820         -0.3820          3384          2092          3384          2091
BM_string_memcmp/32768/4/0           -0.2535         -0.2535          6886          5141          6886          5140
BM_string_memcmp/65536/4/0           -0.1897         -0.1897         13850         11223         13849         11223
BM_string_memcmp/131072/4/0          -0.1972         -0.1972         27536         22106         27533         22104
BM_string_memcmp/512/0/4             -0.2854         -0.2854           125            89           125            89
BM_string_memcmp/1024/0/4            -0.3332         -0.3333           226           151           226           151
BM_string_memcmp/8192/0/4            -0.4199         -0.4199          1740          1009          1740          1009
BM_string_memcmp/16384/0/4           -0.3811         -0.3811          3383          2094          3383          2094
BM_string_memcmp/32768/0/4           -0.2409         -0.2409          6900          5238          6899          5237
BM_string_memcmp/65536/0/4           -0.1920         -0.1920         13922         11250         13921         11248
BM_string_memcmp/131072/0/4          -0.2029         -0.2029         27699         22079         27697         22077

[1] Commit id: f77e4c932b4fd65177b57dd5e220bd17fb4037d6

Test: bionic tests and benchmarks on aarch64.
Change-Id: I2791e2b20d1c0ad429e8e5a41d3e47b1ac02c921
2018-08-21 17:48:12 +00:00
Evgenii Stepanov
be551f596f HWASan support in bionic.
* Allow sanitization of libc (excluding existing global sanitizers)
  and disallow sanitization of linker. The latter has not been
  necessary before because HWASan is the first sanitizer to support
  static binaries (with the exception of CFI, which is not used
  globally).
* Static binary startup: initialize HWASan shadow very early so that
  almost entire libc can be sanitized. The rest of initialization is
  done in a global constructor; until that is done sanitized code can
  run but can't report errors (will simply crash with SIGTRAP).
* Switch malloc_common from je_*  to __sanitizer_*.
* Call hwasan functions when entering and leaving threads. We can not
  intercept pthread_create when libc depends on libclang_rt.hwasan.
  An alternative to this would be a callback interface like requested
  here:
    https://sourceware.org/glibc/wiki/ThreadPropertiesAPI

All of the above is behind a compile-time check
__has_feature(hwaddress_sanitizer). This means that HWASan actually
requires libc to be instrumented, and would not work otherwise. It's
an implementation choice that greatly reduces complexity of the tool.
Instrumented libc also guarantees that hwasan is present and
initialized in every process, which allows piecemeal sanitization
(i.e. library w/o main executable, or even individual static
libraries), unlike ASan.

Change-Id: If44c46b79b15049d1745ba46ec910ae4f355d19c
2018-08-21 00:15:47 +00:00
Christopher Ferris
ad935c8139 Add more descriptive text around app starting.
Test: NA
Change-Id: If3bcf060b11ec08835863236b0a1408aebe43355
2018-08-16 17:57:23 -07:00
Christopher Ferris
841c9c1ce2 Merge "Add new malloc benchmarks." 2018-08-16 01:09:17 +00:00
George Burgess IV
fa5410fdb7 libc: enable -Wimplicit-fallthrough
libc had some -Wimplicit-fallthrough warnings. They all seem to be
benign. We're trying to enable this flag globally, so we need to
annotate these breaks here.

Bug: 112564944
Test: Builds
Change-Id: I5afae694cc4cf26ad1a61e2c8ae91f00cda7c733
2018-08-15 10:11:08 -07:00
Christopher Ferris
0dc784431b Add new malloc benchmarks.
This runs through the trace of the allocations in a sql benchmark app
executed in the benchmark thread.

Add one benchmark with decay time set to 0 and another with decay time
set to 1.

Include a script that can generate a header file that can be used to
regenerate the data.

Bug: 112317428

Test: Builds, ran unit tests, ran benchmarks.
Change-Id: I62e287cc06b74b74bcc5a4bbee71b0fac0a196fd
2018-08-14 16:01:58 -07:00
Bernie Innocenti
817f578bf4 Merge "Clear the resolver timeout when setting default __res_params" 2018-08-10 02:15:20 +00:00
Treehugger Robot
fce5dae8a3 Merge "Make the resolver retry timeout configurable via __res_params" 2018-08-10 01:55:09 +00:00
Treehugger Robot
a2650eaf1c Merge "seccomp: Allow read(2) and getdents(2) in x86_64 for UBSan's sake" 2018-08-09 23:47:14 +00:00
Luis Hector Chavez
ea82982b87 seccomp: Allow read(2) and getdents(2) in x86_64 for UBSan's sake
This change allows the use of read(2) and getdents(2) so that UBSan can
work correctly on x86_64.

Bug: 111999822
Test: CtsWrapWrapDebugTestCases
Change-Id: I44aac17fffdffc5c3f5d87fb3d876af28c8044b2
2018-08-09 12:32:01 -07:00
Bernie Innocenti
96c619f7db Clear the resolver timeout when setting default __res_params
This is currently a non-functional change, because base_timeout_msec is
never set to a non-default value (other than in unit tests).

Test: netd_unit_test --gtest_filter='ResolverTest.*'
Change-Id: I21989bab5cc9f55ee1392e30965eb405d720a28e
2018-08-09 17:58:35 +09:00
Elliott Hughes
b7b2884a21 Merge "Reland "Retire GCC FORTIFY."" 2018-08-08 15:26:37 +00:00
Bernie Innocenti
58d13622a5 Make the resolver retry timeout configurable via __res_params
The primary motivation is speeding up tests for non-responsive
nameservers. It's also base infrastructure for future work to compute
retry timeouts dynamically.

Using default timeouts (RES_TIMEOUT = 5 seconds):
  ResolverTest.GetAddrInfoV6_nonresponsive (45141 ms)

With base_timeout_msec=100:
  ResolverTest.GetAddrInfoV6_nonresponsive (1264 ms)

Test: executed unsubmitted test from aosp/713993
Change-Id: Id902089ca69ca8d28032180ba51e8937262ef490
2018-08-08 15:45:19 +09:00
Treehugger Robot
f2fb3b11c6 Merge "seccomp: Generate the policy files at compile time" 2018-08-07 13:17:42 +00:00
Josh Gao
e16082f717 fdsan: expose the address of the table to the platform.
Let the debuggerd handler get the address of the fdsan table so that
crash_dump can parse it and print it out in tombstones.

Test: debuggerd `pidof adbd`
Change-Id: I2297200cae52d0ff24479dba55d1ab4938583501
2018-08-06 18:48:52 -07:00
Josh Gao
e6dab7b55f fdsan: minor refactoring.
Make it easier for other code to parse the fdsan table themselves by
making it so that they can include the bionic_fdsan.h header to get a
struct definition with the layout without bringing in other
dependencies.

Test: treehugger
Change-Id: I3583ef113991234aa83cd193a4eb139ad06737c7
2018-08-06 18:47:29 -07:00
Josh Gao
4b7c1cc13f fdsan: enable by default.
Test: adb shell crasher fdsan_file
Change-Id: I6be0f7372ddb9d622a0bd8d1eeb80a4f747c99e3
2018-08-06 15:11:08 -07:00
Elliott Hughes
f80e3f4413 Merge "Make all popen(3) file descriptors O_CLOEXEC." 2018-08-06 18:43:40 +00:00
Luis Hector Chavez
fa09b3c754 seccomp: Generate the policy files at compile time
This change avoids having to run the genseccomp.py script every time a
policy file is edited, and instead generates these files at
compile-time.

Bug: None
Test: m
Test: find out/soong/ -name x86_64_global_policy.cpp  # Shows files
Test: generated policies are equivalent to original policies
Change-Id: I12461fe0c5fb02c008c1b2503fbb994b8aa2f56b
2018-08-06 11:10:25 -07:00
Treehugger Robot
ea6aff66fa Merge "genseccomp.py: Add a way to better find the clang prebuilt" 2018-08-04 02:54:36 +00:00
Elliott Hughes
9b6fefd89b Make all popen(3) file descriptors O_CLOEXEC.
POSIX says "The popen() function shall ensure that any streams from
previous popen() calls that remain open in the parent process are closed
in the new child process". It doesn't appear to disallow all popen(3) file
descriptors from being O_CLOEXEC, and it's not obvious why anyone would want
them inherited. Let's see if we can make the stricter guarantee...

Bug: N/A
Test: ran tests
Change-Id: I2c85170d730b211637afb8ba10df150ca3237262
2018-08-03 15:54:18 -07:00
Josh Gao
08b7a4008f fdsan: improve errors some more.
Add handling for all 4 cases of failure of exchange_owner_tag. Also,
mask off and sign extend the type byte of the owner tag, and add a
test for that.

Test: bionic_unit_tests
Change-Id: Ic7c49f0ee5498623f05c49b5b4cd055db48a4b9f
2018-08-03 15:03:41 -07:00
Yi Kong
35bb46188c Merge "Modernize codebase by replacing NULL with nullptr" 2018-08-03 20:07:44 +00:00
Luis Hector Chavez
fd3f6d7126 genseccomp.py: Add a way to better find the clang prebuilt
This change makes it possible to invoke this tool without having to
fiddle with the path.

Bug: None
Test: ./bionic/libc/tools/genseccomp.py  # Succeeded
Change-Id: Ib24d70abc973fe774cda4209e46a5b66ae7617be
2018-08-03 12:57:21 -07:00
Luis Hector Chavez
ef1a34c85d seccomp: Allow readlink(2) in x86_64 for UBSan's sake
This change allows the use of readlink(2) so that UBSan can work
correctly on x86_64.

Bug: 111999822
Test: CtsWrapWrapDebugTestCases
Change-Id: I7f3013c712e3e41567a0d8e1bbb9d378c04b4433
2018-08-03 10:36:02 -07:00
Yi Kong
32bc0fcf69 Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.

Test: m
Bug: 68236239
Change-Id: I5b4123bc6709641315120a191e36cc57541349b2
2018-08-02 18:09:44 -07:00
Ryan Prichard
6fdfd92e56 Use LIBC_Q for LIBC_PRIVATE / LIBC_PLATFORM
Bug: none
Test: run bionic unit tests
Change-Id: I59794597db9cbd23c917498e5e82296a379c8fb5
2018-07-31 00:17:02 -07:00
Ryan Prichard
c1c8a188b2 Fix arm32/64 dynamic TLS relocations
arm32: Add a relocation for TLS descriptors (e.g. gcc's
-mtls-dialect=gnu2).

arm64: Add all the dynamic TLS relocations.

Two of the relocations here are obsolete:

 - ARM documents R_ARM_SWI24 as an obsolete static relocation without
   saying what it did. It's been replaced by R_ARM_TLS_DESC, a dynamic
   relocation. We could probably remove it, but I left it because arm32
   is old, and I see the macro in other libc's. It's probably analogous
   to R_ARM_THM_SWI8, which is also an obsolete relocation reserved for
   a future dynamic relocation.

 - I couldn't find any ARM documentation at all for
   R_AARCH64_TLS_DTPREL32. It seems to have been part of three
   relocations:

    - R_AARCH64_TLS_DTPREL32 1031
    - R_AARCH64_TLS_DTPMOD32 1032
    - R_AARCH64_TLS_TPREL32 1033

Bug: b/78026329
Test: run bionic unit tests
Change-Id: I5e7432f6e3e906152dc489be5e812fd8defcbafd
2018-07-30 23:49:19 -07:00
Treehugger Robot
3bf897e12d Merge "Update to FreeBSD libm r336665." 2018-07-25 20:11:28 +00:00
Treehugger Robot
3e98d88823 Merge "fdsan: improve diagnostics." 2018-07-25 00:40:29 +00:00
Treehugger Robot
439bb1d048 Merge "Fixup an out of date comment." 2018-07-24 23:09:57 +00:00
Tom Cherry
576f525302 Merge "Add recovery_available: true to libseccomp_policy" 2018-07-24 23:04:21 +00:00
Tom Cherry
a06c49c37f Add recovery_available: true to libseccomp_policy
Init needs this in order to be built in Android.bp

Test: build

Change-Id: I0ce67a3c84cf476b28be039b9c9b345bc381de7b
2018-07-24 13:36:59 -07:00
Tom Cherry
0fe2203309 Fixup an out of date comment.
Test: n/a
Change-Id: Ieb5d18d479becb8c92cbf71a8bb7cd67f7c27dba
2018-07-24 13:34:34 -07:00