Commit graph

30523 commits

Author SHA1 Message Date
Elliott Hughes
5828ad7dfe Clean up some obsolete NetBSD portability cruft.
Test: treehugger
Change-Id: I9197e6ebcaec6811ff5ee12e4d2e7a14c2881f64
2019-10-29 19:58:17 -07:00
Elliott Hughes
c996c73f76 Clean up some obsolete FreeBSD portability cruft.
Test: treehugger
Change-Id: I86ddeb64c7b8bda80633f063fd70fddd2ac113ed
2019-10-29 19:49:19 -07:00
Elliott Hughes
2b14f0b49d Merge "Take a quick_exit() patch from upstream FreeBSD."
am: c430451205

Change-Id: I9106b49bbddad7c580da802d7fb758ff75e95ea5
2019-10-29 19:25:03 -07: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
Roland Levillain
86ab352136 Merge "Revert "Load /dev/linker/ld.config.txt by default""
am: 6f9a97f864

Change-Id: I8c7f73e038b3abb1a1d02c23a5df1dda8a9213d4
2019-10-29 15:20:34 -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
89c4e4a43e Take a couple of wcs MTE patches from upstream FreeBSD.
r293856 | brooks | 2016-01-13 13:50:08 -0800 (Wed, 13 Jan 2016) | 10 lines

  Avoid reading pass the end of the source buffer when it is not NUL
  terminated.

  If this buffer is adjacent to an unmapped page or a version of C with
  bounds checked is used this may result in a crash.

  PR:		206178
  Submitted by:	Alexander Cherepanov <cherepan@mccme.ru>
  MFC after:	1 week

and

  r293855 | brooks | 2016-01-13 13:49:01 -0800 (Wed, 13 Jan 2016) | 10 lines

  Avoid reading pass the end of the source buffer when it is not NUL
  terminated.

  If this buffer is adjacent to an unmapped page or a version of C with
  bounds checked is used this may result in a crash.

  PR:		206177
  Submitted by:	Alexander Cherepanov <cherepan@mccme.ru>
  MFC after:	1 week

Test: treehugger
Change-Id: I3f7b9e6d0648574d2836f7721dfe47c1bae146de
2019-10-29 20:10:59 +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
92adfbb687 Merge "Adopt GNU calling convention for ifunc resolvers."
am: 609d6ec416

Change-Id: Ie5bbd72a166321bcd361229e9f3adf784ec322b9
2019-10-29 10:37:06 -07:00
Peter Collingbourne
609d6ec416 Merge "Adopt GNU calling convention for ifunc resolvers." 2019-10-29 17:19:33 +00:00
Elliott Hughes
af5253629f Merge "sleep/usleep: switch to trivial implementations."
am: dbe72ca7a1

Change-Id: Ie5e10781299298ad327d6cb6982fa200bd52bc78
2019-10-29 08:14:34 -07: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
Elliott Hughes
9fb328dc4b Merge "Take a bunch of trivial SPDX changes from upstream FreeBSD."
am: 83108971a7

Change-Id: Ic8f895c6c644d7f0a51a691d48ea68e804fee4bc
2019-10-28 21:15:33 -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
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
05b0aeeb5f Merge "Load /dev/linker/ld.config.txt by default"
am: 9615e0ddac

Change-Id: I40f2a3ed101e2677ab7805a000feb2c9c2763425
2019-10-27 21:36:25 -07:00
Kiyoung Kim
9615e0ddac Merge "Load /dev/linker/ld.config.txt by default" 2019-10-28 04:23:01 +00:00
Ryan Prichard
78cd283480 linker: remove COUNT_PAGES
COUNT_PAGES tries to count the pages dirtied by relocations, but this
implementation is broken because it's merging rel->r_offset values from
multiple DSOs. The functionality is hard to use, because it requires
rebuilding the linker, and it's not obvious to me that it should belong
in the linker. If we do want it, we should make it work without rebuilding
the linker.

Similar information can currently be collected by parsing the result of
`readelf -r` on a binary (or a set of binaries).

Bug: none
Test: m linker libc com.android.runtime ; adb sync ; run something
Change-Id: I760fb6ea4ea3d1927eb5145cdf4ca133851d69b4
2019-10-25 17:46:43 -07:00
Christopher Ferris
bab956330b Merge "Add section about libmemunreachable tests."
am: 40726768de

Change-Id: Iecf0666033cfbdace46ba56fcbb741ab8c91391b
2019-10-25 17:13:01 -07:00
Christopher Ferris
40726768de Merge "Add section about libmemunreachable tests." 2019-10-25 23:50:45 +00:00
Dmytro Chystiakov
6e36dd2c15 Limit threads in pthread_leak#detach for low power devices.
This patch decreases created threads to 50 (instead of 90)
on devices with 2 cores CPU. It is a second decrease as this
test case started to fail on same devices after kernel uprev

Bug: b/142210680
Test: Run CtsBionic module on 2 core device with command
	"run cts -m CtsBionicTestCases

Change-Id: I4f73363b342b38c92d64aaf213071f899e5b52ac
Signed-off-by: Dmytro Chystiakov <dmytro.chystiakov@intel.com>
2019-10-25 16:12:47 -07:00
Christopher Ferris
51863b3671 Add section about libmemunreachable tests.
Test: NA
Change-Id: I0dcb8bbb7a598c44201281c7d493023e7d25c153
2019-10-25 15:27:12 -07:00
Elliott Hughes
884369bbd0 Merge "libm: sync with upstream FreeBSD."
am: b21d968281

Change-Id: Ic8ba46d413844fffcd594209a26f99be909f0d8e
2019-10-25 10:36:09 -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