Commit graph

30141 commits

Author SHA1 Message Date
Elliott Hughes
d1f1e41d8c Merge "Take a getopt_long() patch from upstream FreeBSD." 2019-10-30 14:43:15 +00:00
Peter Collingbourne
e1ab123dd3 Merge "Add arm64 string.h function implementations for use with hardware supporting MTE." 2019-10-30 04:42:53 +00:00
Elliott Hughes
c430451205 Merge "Take a quick_exit() patch from upstream FreeBSD." 2019-10-30 02:10:15 +00:00
Peter Collingbourne
900d07d6a1 Add arm64 string.h function implementations for use with hardware supporting MTE.
As it turns out, our "generic" arm64 implementations of certain string.h
functions are not actually generic, since they will eagerly read memory
possibly outside of the bounds of an MTE granule, which may lead to a segfault
on MTE-enabled hardware. Therefore, move the implementations into a "default"
directory and use ifuncs to select between them and a new set of "mte"
implementations, conditional on whether the hardware and kernel support MTE.

The MTE implementations are currently naive implementations written in C
but will later be replaced with a set of optimized assembly implementations.

Bug: 135772972
Change-Id: Ife37c4e0e6fd60ff20a34594cc09c541af4d1dd7
2019-10-29 16:18:31 -07:00
Treehugger Robot
6f9a97f864 Merge "Revert "Load /dev/linker/ld.config.txt by default"" 2019-10-29 21:15:57 +00:00
Elliott Hughes
5b4b58aad4 Take a getopt_long() patch from upstream FreeBSD.
r342757 | kevans | 2019-01-03 19:13:24 -0800 (Thu, 03 Jan 2019) | 19 lines

  getopt_long(3): fix case of malformed long opt

  When presented with an arg string like '-l-', getopt_long will successfully
  parse out the 'l' short option, then proceed to match '--' against the first
  longopts entry as it later does a strncmp with len=0. This latter bit is
  arguably another bug in itself, but presumably not a practical issue as all
  callers of parse_long_options are already doing the right thing (except this
  one pointed out).

  An opt string like '-l-' should be considered malformed and throw a bad
  argument rather than behaving as if '--' were passed. It cannot possibly do
  what the invoker expects, and it's probably the result of a typo (ls -l- a)
  rather than any intent.

  Reported by:	Tony Overfield <toverfield@yahoo.com>
  Reviewed by:	imp
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D18616

Test: treehugger
Change-Id: I593713bc35d70eb1975c9d7587528f2b3f9731af
2019-10-29 20:09:49 +00:00
Elliott Hughes
d310125a68 Take a quick_exit() patch from upstream FreeBSD.
r325389 | kib | 2017-11-04 03:52:58 -0700 (Sat, 04 Nov 2017) | 7 lines

  C++17 requires quick_exit(3) to be async-signal safe.

  Make it safe, and update man page with the useful information.

  Sponsored by: The FreeBSD Foundation
  MFC after:  1 week

Test: treehugger
Change-Id: Idf84b1f1e360c031b0e39d5f6e80d17308db1940
2019-10-29 13:07:42 -07:00
Roland Levillain
09bde95f3b Revert "Load /dev/linker/ld.config.txt by default"
This reverts commit 61a97e9505.

Reason for revert: Breaks ART run-tests (b/143458513).

Test: Run ART tests on device in a chroot environment
Bug: 143458513
Bug: 139638519
Change-Id: Ib047a24d6e82e38ebdaafeab294b8be44b74bd9c
2019-10-29 19:39:49 +00:00
Peter Collingbourne
609d6ec416 Merge "Adopt GNU calling convention for ifunc resolvers." 2019-10-29 17:19:33 +00:00
Elliott Hughes
dbe72ca7a1 Merge "sleep/usleep: switch to trivial implementations." 2019-10-29 14:48:20 +00:00
Elliott Hughes
ca3f8e4901 sleep/usleep: switch to trivial implementations.
Upstream keeps rearranging the deckchairs for these, so let's just
switch to the [roughly] one-liners rather than track that...

Test: treehugger
Change-Id: If655cf7a7f316657de44d41fadd43a8c55ee6f23
2019-10-28 22:25:02 -07:00
Treehugger Robot
83108971a7 Merge "Take a bunch of trivial SPDX changes from upstream FreeBSD." 2019-10-29 03:20:50 +00:00
Peter Collingbourne
e949195f64 Adopt GNU calling convention for ifunc resolvers.
In order for an ifunc resolver to detect the presence of certain CPU features,
access to getauxval(AT_HWCAP) or getauxval(AT_HWCAP2) may be required. In order
for getauxval() to work, it needs to access the pointer to the auxiliary vector
stored by the linker in the libc shared globals data structure. Accessing the
shared globals requires libc to call the __libc_shared_globals() function
exported by the linker. However, in order to call this function, libc must
be fully relocated, which is not guaranteed to be the case at the point when
ifunc resolvers are called.

glibc solves this problem by passing the values of getauxval(AT_HWCAP)
(and getauxval(AT_HWCAP2) on aarch64) as arguments to the ifunc resolver.
Since this seems to be not only the most straightforward way to solve the
problem but also improves our compatibility with glibc, we adopt their
calling convention.

This change is ABI compatible with old resolvers because the arguments are
passed in registers, so the old resolvers will simply ignore the new arguments.

Bug: 135772972
Change-Id: Ie65bd6e7067f0c878df3d348c815fda61dc12de2
2019-10-28 20:20:29 -07:00
Elliott Hughes
ccea6934fe Take a bunch of trivial SPDX changes from upstream FreeBSD.
Test: treehugger
Change-Id: I2242d47e5ee4e7aaa637e2e2933e0f88b1d05e77
2019-10-28 14:23:15 -07:00
Kiyoung Kim
9615e0ddac Merge "Load /dev/linker/ld.config.txt by default" 2019-10-28 04:23:01 +00:00
Christopher Ferris
40726768de Merge "Add section about libmemunreachable tests." 2019-10-25 23:50:45 +00:00
Christopher Ferris
51863b3671 Add section about libmemunreachable tests.
Test: NA
Change-Id: I0dcb8bbb7a598c44201281c7d493023e7d25c153
2019-10-25 15:27:12 -07:00
Elliott Hughes
b21d968281 Merge "libm: sync with upstream FreeBSD." 2019-10-25 17:19:57 +00:00
Elliott Hughes
ff49a3c03a libm: sync with upstream FreeBSD.
Bug: http://b/143311272
Test: ran tests
Change-Id: I0fbf94fb5cd13e64a55957d0f951757746d0367a
2019-10-24 18:13:32 -07:00
Kiyoung Kim
61a97e9505 Load /dev/linker/ld.config.txt by default
Linker config generator now covers ld.config.txt for Legacy and
VNDK-Lite devices, so linker can use those instead of existing ones
under /system/etc

Bug: 139638519
Test: m -j passed
Change-Id: I90f14727148cbf9629b90dc4fd78362bed8ea4e4
2019-10-24 19:23:25 +09:00
Christopher Ferris
04f27f23dc Merge "Add bionic-stress-tests."
am: 6e5d06336a

Change-Id: Iad2d548953e824302f507095df9aec02049a36a6
2019-10-23 09:56:36 -07:00
Christopher Ferris
6e5d06336a Merge "Add bionic-stress-tests." 2019-10-23 16:40:17 +00:00
Christopher Ferris
ee0ce440fd Add bionic-stress-tests.
I plan to add tests to this test binary that take a long time to run.

The first is a malloc test that demonstrates that jemalloc appears
to be leaking memory slowly over time.

Test: Ran the bionic-stress-tests on host and verified it runs forever,
Test: but doesn't display RSS/VSS data.
Test: Ran the bionic-stress-tests on a taimen and verified it runs forever,
Test: and does display RSS/VSS data.
Change-Id: Ic612e4181ffea898d4d83af097939cd517a180ee
2019-10-22 22:49:06 +00:00
Ryan Prichard
fc093dfbaa Merge changes Ia0c0018c,I2f1fc8b4,Ibe964c3b,I791da8ac
am: 9da992c271

Change-Id: Iea6c640fc20f1586b5ebb1ad7a6308b5c70a992d
2019-10-18 17:14:56 -07:00
Ryan Prichard
9da992c271 Merge changes Ia0c0018c,I2f1fc8b4,Ibe964c3b,I791da8ac
* changes:
  linker: stop relocating R_ARM_REL32
  Factor out R_GENERIC_COPY
  Factor out R_GENERIC_ABSOLUTE
  Remove broken arm64 PREL/ABS relocations
2019-10-19 00:05:29 +00:00
Ryan Prichard
495863f921 linker: stop relocating R_ARM_REL32
This relocation is labeled as a static relocation in the ARM ELF ABI and
shouldn't appear in position-independent code.

It currently calculates the value to relocate incorrectly:

   "sym_addr - rel->r_offset" should be "sym_addr - reloc"

I don't know of any other dynamic linker that handles this relocation.

Test: bionic unit tests
Bug: http://b/19197129
Change-Id: Ia0c0018c82fe98d5edb54ee6f5c9f402b1fa3076
2019-10-18 12:44:01 -07:00
Ryan Prichard
308af5761e Factor out R_GENERIC_COPY
Test: bionic unit tests
Bug: none
Change-Id: I2f1fc8b4b9832f892e5cf13a3c685854de07a8d3
2019-10-18 12:44:01 -07:00
Ryan Prichard
e0a53e2de3 Factor out R_GENERIC_ABSOLUTE
Combine:
 - R_AARCH64_ABS64
 - R_ARM_ABS32
 - R_X86_64_64
 - R_386_32

They do mostly the same thing as R_GENERIC_GLOB_DAT. They always have an
addend, though, and R_GENERIC_GLOB_DAT currently only has an addend on
RELA targets.

Test: bionic unit tests
Bug: none
Change-Id: Ibe964c3b28705086aecb6e7d80c90998aad3c0a4
2019-10-18 12:44:01 -07:00
Ryan Prichard
9ef61a287a Remove broken arm64 PREL/ABS relocations
Specifically, remove:

 - R_AARCH64_ABS32
 - R_AARCH64_ABS16
 - R_AARCH64_PREL64
 - R_AARCH64_PREL32
 - R_AARCH64_PREL16

These relocations never currently appear in dynamic ELF files, and the
linker didn't handle them correctly. The AArch64 ELF ABI document
classifies them as "static relocations", which dynamic linkers don't need
to handle. (The document also classifies R_AARCH64_ABS64 as static,
though, and that relocation is common in DSOs. Perhaps static linkers
can't use R_AARCH64_GLOB_DAT to relocate data outside the GOT.)

Previously, for {ABS,PREL}{32,16}, Bionic always failed with an
out-of-range error. e.g. For {ABS,PREL}16, the value had to satisfy two
conditions:
 - be at least (Elf64_Addr)INT16_MIN, i.e. 0xffff_ffff_ffff_8000
 - be at most (Elf64_Addr)UINT16_MAX, i.e. 0xffff

The PREL relocations should have used sym_addr + addend - reloc, not
sym_addr + addend - rel->r_offset.

Bug: http://b/19197129
Test: bionic unit tests
Change-Id: I791da8ac471b3fb108cf77405c222f6e4bd34ae4
2019-10-17 23:12:05 -07:00
Christopher Ferris
489c68b7b4 Merge "Updated memory_replay description."
am: 3629e87621

Change-Id: I1c64cf15f3f562366afc11fbd83a92a8a81ce018
2019-10-17 18:05:17 -07:00
Christopher Ferris
3629e87621 Merge "Updated memory_replay description." 2019-10-18 00:55:11 +00:00
Christopher Ferris
2f5fc3372a Updated memory_replay description.
The description of memory_replay talks about unzippping the trace
files, but this is no longer necessary. This language has been
updated to reflect this.

Test: NA
Change-Id: Id808f9bd1286284c8de12b19c08eb8677c76dd53
2019-10-17 15:20:55 -07:00
Jooyung Han
2c4f2bd982 Merge "Revert "Change linker config variable: VNDK_VER""
am: 919dc05d66

Change-Id: Ib2a7d3aba78f62ce02d1d4e13c636d4554e7de88
2019-10-17 05:07:54 -07:00
Treehugger Robot
919dc05d66 Merge "Revert "Change linker config variable: VNDK_VER"" 2019-10-17 11:50:47 +00:00
TreeHugger Robot
18408d6860 Merge "Skip QD1A.190821.011 in stage-aosp-master" into stage-aosp-master 2019-10-17 01:35:32 +00:00
Steven Moreland
2d166715b9 Merge "Add dladdr benchmark."
am: 31c4effccc

Change-Id: I89fd06ae64220972f02ab0fa77d21a0b74910bae
2019-10-16 16:55:51 -07:00
Jooyung Han
a365ac10a2 Revert "Change linker config variable: VNDK_VER"
This reverts commit e30a7f5d1f.

Reason for revert: some targets are broken

Bug: 142773030
Change-Id: I651ef00a9d1aaac6f0119d31712fb588d8aa68f0
2019-10-16 23:42:56 +00:00
Steven Moreland
31c4effccc Merge "Add dladdr benchmark." 2019-10-16 23:41:31 +00:00
Xin Li
b88f71a8b9 Skip QD1A.190821.011 in stage-aosp-master
Bug: 141248619
Change-Id: I286a3b32b13a5b3774d4e816fc3692184dc37eb8
2019-10-16 15:19:11 -07:00
Ryan Prichard
5ea49d9249 Merge "Cleanup linker unwinder integration"
am: 2ab4e0f999

Change-Id: I4f0acacc441b6108f9cc2ffd6d58a4ebaeeb5ea2
2019-10-16 14:26:11 -07:00
Ryan Prichard
2ab4e0f999 Merge "Cleanup linker unwinder integration" 2019-10-16 21:13:58 +00:00
Elliott Hughes
b1fad690d7 Merge "Remove __ANDROID_NDK__ from bionic, and document our #defines."
am: ed1b861d0d

Change-Id: Ie837197400e7553d0fe8aeb78a6109c797449aed
2019-10-16 09:46:46 -07:00
Elliott Hughes
ed1b861d0d Merge "Remove __ANDROID_NDK__ from bionic, and document our #defines." 2019-10-16 16:37:05 +00:00
Steven Moreland
c4e727bff3 Add dladdr benchmark.
Bug: 142684469
Test: adb shell /data/benchmarktest64/bionic-benchmarks/bionic-benchmarks --benchmark_filter="BM_dladdr.*"
-------------------------------------------------------------------
Benchmark                         Time             CPU   Iterations
-------------------------------------------------------------------
BM_dladdr_libbase_split        92.6 ns         92.4 ns      6673841
BM_dladdr_libc_printf          8690 ns         8667 ns        80916
BM_dladdr_libdl_dladdr          133 ns          132 ns      5342791
BM_dladdr_local_function       93.0 ns         92.7 ns      7625562

Change-Id: I259dd8f64ccc288835576a2eb08b8b8132777a4b
2019-10-16 08:59:06 -07:00
Jiyong Park
bd66362f55 Merge "libc_malloc_[debug|hooks] are not available for platform"
am: 0ace96d754

Change-Id: I8d1d7a93c8103b27ed673c918886eccfd778ffaa
2019-10-15 21:20:55 -07:00
Ryan Prichard
d9a4115273 Cleanup linker unwinder integration
The linker shouldn't throw exceptions, but because it links with
libc++_static.a, there are code paths that could throw an exception. On
those code paths, the unwinder needs to lookup EH information for the
linker binary, and the linker had two inconsistent ways of doing this:

 * dl_iterate_phdr (for libgcc): dlfcn.cpp defined a linker-internal
   version of this API that forwarded to __loader_dl_iterate_phdr

 * __gnu_Unwind_Find_exidx (for arm32 libgcc): linker_exidx_static.c was
   an old, broken copy of exidx_static.c that used
   __exidx_start/__exidx_end symbols. (The file should have used the
   addresses of the symbols rather than their contents.)

The linker's data structures might be in an inconsistent state at a point
where exceptions are thrown, so it seems better to limit its unwinder to
just the linker binary's EH info. Rather than forward the dl* EH APIs,
link in the static-binary versions from libc_unwind_static.a. That library
is already part of libc_nomalloc.a, but include it directly with
whole_static_libs so that __gnu_Unwind_Find_exidx is defined when we're
using libgcc on arm32.

Try to link in libunwind_llvm.a into the arm32 linker binary so we're
using the same unwinder as normal arm32 binaries. I'm not sure the library
will appear in the right order, but maybe it doesn't matter given LLD's
unconventional archive linking semantics.

Test: bionic unit tests
Test: "readelf --dyn-syms linker" reports no UNDEF symbols
Test: "readelf -r linker" reports only relative relocations
Bug: none
Change-Id: I5982ec830ba0f15d066536de24f6cd7e9503498b
Merged-In: I5982ec830ba0f15d066536de24f6cd7e9503498b
2019-10-16 04:20:23 +00:00
Treehugger Robot
0ace96d754 Merge "libc_malloc_[debug|hooks] are not available for platform" 2019-10-16 02:09:44 +00:00
Ryan Prichard
e6c2516385 Merge "Move dl_unwind_find_exidx from libdl.a to libc.a"
am: 1fee3b2104

Change-Id: Iaeb41f85ad6c63f860227052c7ecc3974c4ea34d
2019-10-15 14:57:18 -07:00
Ryan Prichard
1fee3b2104 Merge "Move dl_unwind_find_exidx from libdl.a to libc.a" 2019-10-15 21:41:05 +00:00
Elliott Hughes
80e9f65c04 Remove __ANDROID_NDK__ from bionic, and document our #defines.
__ANDROID_NDK__ is moving into the NDK's <android/ndk-version.h>
instead.

Test: treehugger
Change-Id: I192016165a929547009d15dbcc30e8f6dad1ac88
2019-10-15 13:30:12 -07:00