Commit graph

27072 commits

Author SHA1 Message Date
Dan Willemsen
d6bf019204 Rework the linker_wrapper to work with lld
This is use by Host Bionic to bootstrap into an embedded copy of the
linker by tweaking the AT_* values before calling in to the linker entry.

Similarly to 9729f35922, get the base
address from AT_PHDR, so that we're not relying on the relative offset
before relocation, which doesn't work with lld (at least with the
standard flags).

To find the offset to the linker code, we can still use an absolute
symbol created by extract_linker (which is currently hardcoded to 0x1000).

Instead of relying on something similar for the linker entry point,
we're now just reading the entry point from the linker's ELF header.

Then we get the address to the real _start function using
host_bionic_inject, which injects the value into a global variable after
the link step is finished. It also uses that opportunity to verify that
the linker is embedded as we expect it to be.

Bug: 31559095
Test: build with host bionic
Change-Id: I9d81ea77c51c079de06905da1ebe421fead1dc3b
2018-10-22 22:52:25 +00:00
Christopher Ferris
a8a716e42a Merge "Make the test less specific." 2018-10-20 16:13:34 +00:00
Christopher Ferris
18cbed7008 Make the test less specific.
Remove the need to add every benchmark to the list of all benchmarks.

Also, add some hard-coding of the location of the benchmark executable.
Add a test to make sure the benchmark exists so it's possible to detect
if the executable changes location.

Finally, make the tests isolated so that they finish in half the time.

Test: Ran unit tests.
Change-Id: I1e59eb283e31d29b14e54c44ac865827c9704127
2018-10-19 14:05:14 -07:00
Hans Boehm
de1353b8a4 Merge "Add benchmarks for heap size retrieval" 2018-10-19 16:53:41 +00:00
Florian Mayer
85772259b3 Merge "Add RT signal to load heapprofd library." 2018-10-19 09:36:12 +00:00
Hans Boehm
3e5754c6ad Add benchmarks for heap size retrieval
Add benchmarks for mallinfo, and for retrieving RSS from
/proc/self/statm, since we're considering using these for GC
triggering.

Add some static linkage specifiers, after running into a build
problem due to a spurious conflict.

Bug: 111447610

Test: Ran benchmarks
Change-Id: Ie50d512294993882728c63ce51ec507590257d80
2018-10-18 17:56:58 -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
104fd9e649 Merge "Properly fail with ESRCH when pthread_killing an exited thread."
am: 7ff7d03286

Change-Id: I2b5d2a12035bd08f275e82927015498c3b918492
2018-10-18 11:32:42 -07:00
Josh Gao
7ff7d03286 Merge "Properly fail with ESRCH when pthread_killing an exited thread." 2018-10-18 17:47:17 +00:00
Elliott Hughes
30440b29ae Merge "Don't #define __ANDROID_NDK__ for the platform build!"
am: 8937600897

Change-Id: I2bb0af09714a31bdce8e7f2ecec66bc7c552999a
2018-10-17 20:00:44 -07:00
Elliott Hughes
8937600897 Merge "Don't #define __ANDROID_NDK__ for the platform build!" 2018-10-18 02:15:14 +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
Elliott Hughes
bb63df0c52 Merge "strerror: add missing ERFKILL and EHWPOISON."
am: ecf0c7515d

Change-Id: I1ca2952dcbedddd42377157cdafa26c9f34109e6
2018-10-15 17:33:20 -07:00
Treehugger Robot
ecf0c7515d Merge "strerror: add missing ERFKILL and EHWPOISON." 2018-10-15 23:56:22 +00:00
Greg Hackmann
045b126d69 Merge "fdsan: reset va_list between varargs traversals"
am: daf746b155

Change-Id: Id30f514ef17a56be8f2f7b037e314ff0dee073c2
2018-10-15 14:22:09 -07:00
Haibo Huang
710072909a Merge "Add support for A76 in bionic"
am: 3a47adadad

Change-Id: Ifcb9feca8d4af3f47f2a52f9026f725bec354d22
2018-10-15 14:15:09 -07:00
Treehugger Robot
daf746b155 Merge "fdsan: reset va_list between varargs traversals" 2018-10-15 21:05:44 +00:00
Haibo Huang
3a47adadad Merge "Add support for A76 in bionic" 2018-10-15 21:01:30 +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
Tom Cherry
83b0bf56e9 Merge "Waive AID Range check for upgrading devices launched before P"
am: 4e29cdec23

Change-Id: I3994ef6ad33a1a9c7a3e4f4d4896e2b16dfdce1c
2018-10-15 11:05:51 -07:00
Tom Cherry
4e29cdec23 Merge "Waive AID Range check for upgrading devices launched before P" 2018-10-15 17:59:59 +00: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
Dan Willemsen
ddc249c8f3 Merge "Allow host bionic to use libdl_static"
am: a2af8bea8c

Change-Id: If8421dcd1a1a06dc4b2389c8ca11ce43ac2474ed
2018-10-12 12:18:46 -07:00
Treehugger Robot
a2af8bea8c Merge "Allow host bionic to use libdl_static" 2018-10-12 19:08:11 +00:00
Dan Willemsen
17b35598f5 Allow host bionic to use libdl_static
Bug: 31559095
Test: attempt to build host bionic
Change-Id: If057681a3e098efcf79f9d8a74608b10b1ac20da
2018-10-11 23:35:18 -07:00
Tom Cherry
5c941435ac Waive AID Range check for upgrading devices launched before P
We added a check in P that ensures all vendor provided AIDs only
appear in the carved out ranges for vendors to use.  However,
upgrading devices may be using AIDs outside of this range and it is
very difficult to change these AIDs, so we waive this test for them.

Bug: 116830906
Test: test succeeds on upgrading devices
Change-Id: Iddcacb1dce77a150d5138e7b3115abf25bf60a6e
2018-10-11 11:57:13 -07:00
Ryan Prichard
546cd5bac7 Merge "Allow invoking the linker on an executable."
am: 391af2cefe

Change-Id: I2590130eb3f5419758ec9068feab8adf950ae70b
2018-10-10 18:26:26 -07: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
0bd2520fff Merge "Block TIMER_SIGNAL in sigprocmask(SIG_SETMASK, ...)."
am: 069d5aef90

Change-Id: I2da0d2b41f97a443798e6a4466d4226a740ec48e
2018-10-10 13:51:03 -07:00
Josh Gao
069d5aef90 Merge "Block TIMER_SIGNAL in sigprocmask(SIG_SETMASK, ...)." 2018-10-10 20:38:46 +00:00
Elliott Hughes
af32e53777 Merge "Add _SC_UIO_MAXIOV as a synonym for _SC_IOV_MAX."
am: d3aa44f7e9

Change-Id: Iefc3d62d42f838a7cdb37edf258b78e7b8b2d05e
2018-10-10 10:01:12 -07: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
06ec50f087 Merge changes I8c6b2d1d,I06e0f759,I95d79809
am: cb8ed207d2

Change-Id: I0b0a272d704788d3f21a0365e34f6b09a792529b
2018-10-08 13:45:49 -07:00
Ryan Prichard
cb8ed207d2 Merge changes I8c6b2d1d,I06e0f759,I95d79809
* changes:
  Add async_safe_format_fd_va_list
  Fix normalize_path's handling of "/.."
  linker: fix invalid zip file handling
2018-10-08 20:29:00 +00: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
Ryan Prichard
269bb496c5 Fix normalize_path's handling of "/.."
Currently it normalizes the path to a string with a single uninitialized
byte. It should instead normalize it to "/".

Bug: none
Test: /data/nativetest/linker-unit-tests/linker-unit-tests32
Test: /data/nativetest64/linker-unit-tests/linker-unit-tests64
Change-Id: I06e0f7598d16acfa21875dad53efbc293cfeb44d
2018-10-08 13:27:16 -07:00
Ryan Prichard
0adf09b370 linker: fix invalid zip file handling
The argument to CloseArchive has type ZipArchiveHandle, but we're
passing it a ZipArchiveHandle*. The compiler doesn't detect the type
mismatch because ZipArchiveHandle is a typedef for void*.

Remove a duplicate close() call:

The fourth argument to OpenArchiveFd is "bool assume_ownership = true".
Even if the function fails, ownership of the fd is still transferred to
a ZipArchive object that's deleted when this code calls CloseArchive.

AFAIK, this code path is rarely or never hit.

Bug: none
Test: manual (eventually, 'linker64 /system!/foo')
Change-Id: I95d79809b6e118fb3c39c7b98b8055c8e324db1a
2018-10-08 13:27:16 -07:00
Elliott Hughes
adf9339e1a Merge "<sys/param.h>: pollute the namespace with <endian.h>."
am: 773c697f81

Change-Id: Ia39030966521ed2f9b90fda2417c1ba345f96cb7
2018-10-05 17:31:52 -07:00
Treehugger Robot
773c697f81 Merge "<sys/param.h>: pollute the namespace with <endian.h>." 2018-10-06 00:17:35 +00: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
ac59303f5e Merge "Another round of documentation."
am: 9ebcb013b1

Change-Id: I3b924ada853a96c6747b619087694bb81e63abaa
2018-10-05 14:17:13 -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
0143ea885a Merge "Add new parameter for creation of MapInfo object."
am: 4b7c5cca7f

Change-Id: I57bef03ec0ed044cce23a70bcd18a95bc20bbca9
2018-10-04 15:48:27 -07:00
Christopher Ferris
4b7c5cca7f Merge "Add new parameter for creation of MapInfo object." 2018-10-04 22:38:26 +00:00