Commit graph

30128 commits

Author SHA1 Message Date
Jooyung Han
09283992ca Add linker config variable: VNDK_APEX_VER
With VNDK APEX, the path for VNDK libs has been changed
from /system/lib/vndk-VER to /apex/com.android.vndk.vVER/lib

In most cases, vndk version can be substituted when generating
ld.config.txt by linkerconfig.

But, ld.config.txt files in APEX packages still rely on runtime substitution.
Specifically, com.android.media.swcodec is using VNDK_VER variable.
Moreover, it cannot migrate to a new location since it should run on
older version of system due to APEX requirements.

For backward compatibility, instead of changing the value of old
variable, a new variable is added.

- VNDK_VER : "-" prefixed vndk version, used for older path
            (e.g. /system/lib/vndk-sp-29)
- VNDK_APEX_VER : "v" prefixed vndk versions.
            (e.g. /apex/com.android.vndk.v29/lib)

Test: add a vendor binary to /apex/com.android.media.swcodec/bin
      which opens /system/lib/vndk-sp{VNDK_VER}/hw/android.hidl.memory@1.0-impl.so
      via android_load_sphal_library()
Bug: 142912195

Change-Id: I3dfb3c1068cff00d5b63e92d51da6c4af00d264e
2019-10-29 05:47:03 +09: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
Jooyung Han
6dc6634cb0 Merge "Change linker config variable: VNDK_VER"
am: 64b6a0b87e

Change-Id: Idca80b45cffd6d8593f8690d207d40838abaca92
2019-10-15 02:43:26 -07:00
Jooyung Han
64b6a0b87e Merge "Change linker config variable: VNDK_VER" 2019-10-15 09:21:19 +00:00
Ryan Prichard
22a6a058c7 Move dl_unwind_find_exidx from libdl.a to libc.a
arm32 has two special APIs to find exidx exception handling info,
dl_unwind_find_exidx and __gnu_Unwind_Find_exdix. The two functions have
identical behavior and function prototypes. libgcc's arm32 unwinder calls
__gnu_Unwind_Find_exdix, whereas LLVM's libunwind previously called
__gnu_Unwind_Find_exdix, but switched to dl_unwind_find_exidx as a result
of three patches (D30306, D30681, D39468).

In Bionic, for dynamic linking, __gnu_Unwind_Find_exdix in libc.so calls
dl_unwind_find_exidx in libdl.so.

For static executables, though, __gnu_Unwind_Find_exdix in libc.a used the
__exidx_* symbols, while dl_unwind_find_exidx in libdl.a(libdl_static.o)
was a return-0 no-op.

To fix the LLVM unwinder, replace the no-op dl_unwind_find_exidx in
libdl.a with a real function in libc.a(exidx_static.o), and have the GNU
function call the dl function for more consistency with dynamic linking.

dl_iterate_phdr follows a similar pattern, where the function exists in
libc.a and libdl.so (not libc.so or libdl.a).

This change makes unwinding work with an updated libunwind_llvm on arm32,
and it helps to allow unwinding in static executables without libdl.a.

Bug: https://github.com/android/ndk/issues/1094
Bug: http://b/141485154
Test: NDK tests, bionic unit tests
Change-Id: Ieeeb9b39a0e28544e21f9afe6fe51ef10d7c828c
2019-10-14 16:34:12 -07:00
Christopher Ferris
dcef02115a Merge "Only get stats for relevant maps."
am: 9571205937

Change-Id: I726c945cc3af99d38f310f95ad0572296f541a2f
2019-10-11 11:35:02 -07:00
Christopher Ferris
9571205937 Merge "Only get stats for relevant maps." 2019-10-11 18:16:01 +00:00
Jooyung Han
e30a7f5d1f Change linker config variable: VNDK_VER
With VNDK APEX, the path for VNDK libs has been changed
from /system/lib/vndk-VER to /apex/com.android.vndk.vVER/lib

Previously, VNDK_VER is replaced with prefix(e.g. "-29"). We could
still prepend prefix("v") to the vndk version, but this change uses a
raw vndk version as the value of VNKD_VER.

Bug: 141451661
Test: m && boot (tested with cuttlefish)
Change-Id: Ibf4cf5e29b7f28e733d4b3bc15171f4359e1d2f2
2019-10-11 10:09:16 +09:00
Christopher Ferris
89b658c265 Only get stats for relevant maps.
Scudo creates a large map on 64 bit which can cause a slow down trying
to get the usage stats for all maps. Since the test only really cares
about a small subset of maps, only get the usage stats for those maps.

Test: Ran unit tests on scudo and jemalloc based systems.
Change-Id: Iba3cff1487ca304083aac323a3971b9f939f5c11
2019-10-10 15:10:40 -07:00
Christopher Ferris
7b76452fe4 Merge "Add support for scudo."
am: 87a10ac108

Change-Id: Ib93d8e332bb46b763c756cc0bde083a30fe6d52a
2019-10-10 10:14:46 -07:00
Christopher Ferris
87a10ac108 Merge "Add support for scudo." 2019-10-10 16:56:21 +00:00
Christopher Ferris
85169658e1 Add support for scudo.
As the first pass, the malloc_info for scudo doesn't return anything.
This feature is hardly ever used, so this seems fine for the first
revision.

Bug: 137795072

Test: Ran unit tests on a taimen using scudo and a taimen using jemalloc.
Change-Id: I675386ae17ba5505c27bd9da12c60242d795464a
2019-10-09 18:54:53 -07:00
Elliott Hughes
c0dbd3a69b Merge "Remove unused -D from libm build."
am: 48da33389b

Change-Id: I27f6e97aa8f3553c1d0043aa6b7cfed99df659f9
2019-10-09 08:41:23 -07:00
Elliott Hughes
393b8a2e4f Merge "Reimplement the <ctype.h> is* functions."
am: e9ff762789

Change-Id: I22560e7cad969cb0cf93e261ed30329a3e64cc87
2019-10-09 08:40:38 -07:00
Elliott Hughes
793cbb6c30 Merge "Restore __ANDROID_NDK__."
am: ee15585029

Change-Id: I2ba5e6e4e24a6eb20c430e0b0b6437819514e218
2019-10-09 08:38:52 -07:00