Commit graph

23402 commits

Author SHA1 Message Date
Dan Willemsen
ae407e522a Remove default libraries
libdl is part of system_shared_libs now. -ldl -lpthread -lm are now defaults
for host_ldlibs on Linux and Darwin. -lrt is a default for host_ldlibs on
Linux.

Test: m host
Test: mmma bionic
Change-Id: I966e2f88c24fba5e412bee6b6382045a2026a8e4
2017-09-28 16:16:14 -07:00
Elliott Hughes
b736c41ffe Merge "Add <glob.h>." 2017-09-28 17:01:06 +00:00
Elliott Hughes
f1c568d1ea Add <glob.h>.
This is the FreeBSD implementation, plus some tests. The FreeBSD
implementation includes the GNU extensions and seems to be what
iOS is using too, which should provide bug compatibility for app
developers.

The code unfortunately uses a lot of stack, and uses FreeBSD locale
implementation that we don't have, but it does seem better maintained
than the other BSDs.

Bug: http://b/29251134
Test: ran tests
Change-Id: Ie477b45e42a6df1319b25712098519d2b33adf67
2017-09-26 18:46:09 -07:00
Treehugger Robot
62767bc31d Merge "Link vdso before linking the main executable" 2017-09-26 17:10:00 +00:00
dimitry
c18de1bd47 Link vdso before linking the main executable
Also set linked flag after it is linked and
call constructors. Set RTLD_NODELETE flag to
prevent accidental unloads.

Test: bionic-unit-tests --gtest_filter=dl*:Dl*
Test: bionic-unit-tests-glibc --gtest_filter=dl*
Change-Id: Ib2178849b918cbefd6f8fcfe6d1f78889fe0bf76
2017-09-26 14:34:18 +02:00
Treehugger Robot
9c172c86e7 Merge "Fix error found building relocation packer for host bionic" 2017-09-25 23:56:17 +00:00
Treehugger Robot
2e01f39c31 Merge "All architectures have AT_SYSINFO_EHDR now." 2017-09-25 19:19:38 +00:00
Elliott Hughes
c51a404b1a All architectures have AT_SYSINFO_EHDR now.
Bug: N/A
Test: builds
Change-Id: Ibc894be98ed0781c8b991ffadff34f616b934aa7
2017-09-22 13:08:50 -07:00
Dan Willemsen
7ebc81f4a2 Fix error found building relocation packer for host bionic
bionic/tools/relocation_packer/src/main.cc:109:7: error: comparison of constant
-1 with expression of type 'typeof (read(fd.get(), e_ident, (16)) != (16))'
(aka 'bool') is always false [-Werror,-Wtautological-constant-out-of-range-compare]

  if (TEMP_FAILURE_RETRY(read(fd.get(), e_ident, EI_NIDENT) != EI_NIDENT)) {
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

bionic/libc/include/unistd.h:243:18: note: expanded from macro 'TEMP_FAILURE_RETRY'
    } while (_rc == -1 && errno == EINTR); \
             ~~~ ^  ~~
1 error generated.

Bug: 31559095
Test: mmma bionic
Change-Id: I473a19e3d51ff355233ae7f87b1013be069edb1f
2017-09-22 19:37:35 +00:00
Treehugger Robot
24c9c3f380 Merge "Don't resolve permitted.paths" 2017-09-22 05:56:37 +00:00
Jiyong Park
0f33f23a76 Don't resolve permitted.paths
Linker resolves the paths in /system/etc/ld.config.txt to canonicalize
the paths and to ensure they exist. However, as permitted paths for the
default namespace contain directories such as /vendor/app, /mnt/expand,
and etc., the resolving causes selinux denial on some processes which do
not have access to some of the permitted paths.

In order to silence the bogus selinux denial, resolution is skipped for
permitted paths.

Note that the resolution is not strictly required especially for
Treble-ized devices where permitted paths are already canonicalized (i.e
/vendor isn't a symlink to /system/vendor).

Bug: 65843095
Test: no selinux denial on /vendor/app, /vendor/framework, etc. while
booting.

Merged-In: I1a9921e45f4c15b08cdf8f1caee64c4cb0761e1f
Change-Id: I1a9921e45f4c15b08cdf8f1caee64c4cb0761e1f
(cherry picked from commit 527757e16b)
2017-09-22 11:34:43 +09:00
Treehugger Robot
6e6e1abb89 Merge changes from topic "host_bionic"
* changes:
  Use an embedded linker for host bionic
  linker: Only link to debuggerd on Android
2017-09-21 00:46:41 +00:00
Dan Willemsen
7ccc50d2e4 Use an embedded linker for host bionic
The linux kernel requires that the ELF interpreter (runtime linker)
that's referenced by PT_INTERP be either an absolute path, or a relative
path from the current working directory. We'd prefer a relative path
from the binary, similarly to how we handle looking up shared libraries,
but that's not supported.

Instead, extract the LOAD segments from the runtime linker ELF binary
and embed them into each host bionic binary, omitting the PT_INTERP
declaration. The kernel will treat it as a static binary, and we'll use
a special entry point (linker_wrapper) to fix up the arguments passed by
the kernel before jumping to the embedded linker. From the linker's
point of view, it looks like the kernel loaded the linker like normal.

Bug: 31559095
Test: Enable host bionic, build and run libdemangle_test
Change-Id: I1753401ef91eecbf0ae3376faca31eec1c53842b
2017-09-20 13:59:13 -07:00
Dan Willemsen
4326d84d21 linker: Only link to debuggerd on Android
Don't link to it when building with bionic for the host.

Also add libasync_safe, which is used by linker_globals.h even when
debuggerd isn't used.

Bug: 31559095
Test: mma
Test: Attempt to build host bionic
Change-Id: I374e2c2c288133875da82de780b27917ca524240
2017-09-20 13:16:13 -07:00
Treehugger Robot
e27d29cfaf Merge "Improve pthread_create failure handling." 2017-09-19 23:44:23 +00:00
Treehugger Robot
1ec162d392 Merge "Extend cfi test to verify a range of target pointers." 2017-09-19 22:44:29 +00:00
Elliott Hughes
53dc9dd701 Improve pthread_create failure handling.
Return EAGAIN rather than aborting if we fail to set up the TLS for a new
thread.

Add a test that uses all the VMAs so we can properly test these edge cases.

Add an explicit test for pthread_attr_setdetachstate, which we use in the
previous test, but other than that has no tests.

Remove support for ro.logd.timestamp/persist.logd.timestamp, which doesn't
seem to be used, and which prevents us from logging failures in cases where
mmap fails (because we need to mmap in the system property implementation).

Bug: http://b/65608572
Test: ran tests
Change-Id: I9009f06546e1c2cc55eff996d08b55eff3482343
2017-09-19 14:02:50 -07:00
Evgenii Stepanov
1dfd76ac2c Extend cfi test to verify a range of target pointers.
Test: bionic device tests
Bug: 63400743
Bug: 65590288
Change-Id: Ic4ef9630a2db709cf4edcc7f76c791df3f349192
2017-09-19 13:59:34 -07:00
Elliott Hughes
0d9301e156 Merge "Rename _Exit in a way that works with libandroid_support." 2017-09-19 18:34:52 +00:00
Elliott Hughes
2f94a29d9c Rename _Exit in a way that works with libandroid_support.
Bug: N/A
Test: builds
Change-Id: I2aeaf9bafe7d51e91b67f22d68f4e52191df062b
2017-09-19 18:34:40 +00:00
Treehugger Robot
cce6ada00a Merge "Make <math.h> renames compatible with GCC." 2017-09-19 01:14:29 +00:00
Treehugger Robot
dacbb04cde Merge "Support larger guard regions." 2017-09-19 01:08:25 +00:00
Christopher Ferris
7a5bb687f4 Merge "Drop thread list lock before abort." 2017-09-19 00:15:32 +00:00
Elliott Hughes
d6541c2a97 Make <math.h> renames compatible with GCC.
GCC is fussy about the order in which attributes and renames occur.

Bug: N/A
Test: builds
Change-Id: Icee5ec00aa4626ddad0d89d2d7cee5ec6891c368
2017-09-18 16:22:32 -07:00
Elliott Hughes
d6c678ca90 Support larger guard regions.
This also fixes a long-standing bug where the guard region would be taken
out of the stack itself, rather than being -- as POSIX demands -- additional
space after the stack. Historically a 128KiB stack with a 256KiB guard would
have given you an immediate crash.

Bug: http://b/38413813
Test: builds, boots
Change-Id: Idd12a3899be1d92fea3d3e0fa6882ca2216bd79c
2017-09-18 16:09:43 -07:00
Christopher Ferris
7982914fae Drop thread list lock before abort.
Bug: 65656273

Test: Ran the app and verified it crashes instead of deadlocks.
Change-Id: I7dbe653d50a635a23993c99c5f73ca094ee80b28
2017-09-18 14:40:35 -07:00
Treehugger Robot
0c9ea17e0c Merge "Always log errno when aborting." 2017-09-18 21:33:54 +00:00
Elliott Hughes
df862454b6 Merge "Use __RENAME for long double functions." 2017-09-18 21:33:06 +00:00
Elliott Hughes
7b0af7ad82 Always log errno when aborting.
(Where errno is relevant.)

Also consistently use -1 as the fd for anonymous mmaps. (It doesn't matter,
but it's more common, and potentially more intention-revealing.)

Bug: http://b/65608572
Test: ran tests
Change-Id: Ie9a207632d8242f42086ba3ca862519014c3c102
2017-09-15 16:18:49 -07:00
Treehugger Robot
5e80552642 Merge "[cfi] Fix __cfi_check address calculation." 2017-09-15 23:08:31 +00:00
Evgenii Stepanov
ded4524cb0 [cfi] Fix __cfi_check address calculation.
The current code is incorrect when the target address is 18 bit aligned.

Test: stops random (and extremely rare) crashes in media.extractor
Bug: 63400743
Bug: 65590288

Change-Id: I65b45ff0c4b57a7ff08d3f5b3d80f41167d3c0f8
2017-09-15 14:15:54 -07:00
Bill Yi
5828840e72 Merge remote-tracking branch 'aosp/oreo-cts-dev' into HEAD 2017-09-15 13:44:31 -07:00
Elliott Hughes
50cda38f1d Use __RENAME for long double functions.
We can cut a lot of stuff out of the NDK's libandroid_support with this,
and reduce unnecessary relocations for all LP32 code. LP64 code should
be unaffected.

Bug: https://issuetracker.google.com/64450768
Bug: https://github.com/android-ndk/ndk/issues/507
Test: ran tests, plus manual readelf on the _test.o files
Change-Id: I3de6015921195304ea9c829ef31665cd34664066
2017-09-14 16:10:43 -07:00
Isaac Chen
3b64f8ecb3 Merge "Enable 32-bit armv8 NEON for libm" 2017-09-14 01:56:29 +00:00
Isaac Chen
e719ceb35b Enable 32-bit armv8 NEON for libm
Since ARM neon instructions were only used on armv7-a-neon architecture
variant, the default implementation for 32-bit armv8-a cores doesn't
use these advanced SIMD instructions. By using "neon" key in the
Android.bp, both arch variants (armv7-a-neon and armv8-a) are covered.

Bug: 65569003
Test: lunch aosp_arm64; emulator # on oc-mr1-dev; boot to home screen
      Also checked if sqrt.o and floor.o are actually built and linked
      in the resulted libm.a for both armv7-a-neon/cortex-a15 and
      armv8-a/generic (2nd) arch/cpu variant.
Change-Id: I2084dbdb12e252b06bba5adc65adb59e97a99332
2017-09-13 19:31:08 +08:00
Treehugger Robot
7e6f98b93d Merge "Remove clang: true" 2017-09-11 21:39:41 +00:00
Elliott Hughes
40756d61ac Merge "Cast __builtin_swap64 to uint64_t." 2017-09-11 20:43:36 +00:00
Elliott Hughes
4c0803d165 Cast __builtin_swap64 to uint64_t.
strace 4.19 causes clang to emit a questionable warning:

  external/strace/nlattr.c:254:35: error: format specifies type 'unsigned long' but the argument has type 'unsigned long long' [-Werror,-Wformat]
                tprintf("htobe64(%" PRIu64 ")", be64toh(num));
                                 ~~~            ^~~~~~~~~~~~
  bionic/libc/include/sys/endian.h💯20: note: expanded from macro 'be64toh'
  #define be64toh(x) htobe64(x)
                     ^~~~~~~~~~
  bionic/libc/include/sys/endian.h:80:17: note: expanded from macro 'htobe64'
  #define htobe64 __swap64
                  ^
  bionic/libc/include/sys/endian.h:48:18: note: expanded from macro '__swap64'
  #define __swap64 __builtin_bswap64
                   ^

What's happened here is:

* be64toh is __builtin_bswap64

* PRIu64 is "lu"

* __builtin_bswap64 is internally declared a "ULLiULLi"

All of which leads to the `unsigned long` != `unsigned long long` complaint.

It seems like __builtin_bswap64 should be ULiULi on 64-bit architectures,
where `long` rather than `long long` is the natural way to refer to 64-bit
types, as evidenced by the "lu" for PRIu64.

As long as clang behaves like this, though, we can work around it with a cast.

Also clean up the other casts in the file, be more consistent about whether
these function-like macros are defined with an argument, and remove an
incorrect comment.

Bug: http://b/65495954
Test: ran tests, built strace 4.19 without warnings
Change-Id: I8e06d4bf71e95d62f556eab8661033e04d487e0d
2017-09-11 13:21:35 -07:00
Lennart Wieboldt
2286b9f5ae Remove clang: true
clang is the default compiler since Android nougat

Test: mma & verified it´s still build with clang
Change-Id: Id8b5361d18c1b2febb2dc6cc44502feaa08f605c
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
2017-09-11 21:43:58 +02:00
Elliott Hughes
4c9d528a25 Merge "Finish <search.h>." 2017-09-11 18:39:30 +00:00
Treehugger Robot
d74088bc46 Merge "For devices which are not treble enabled, return the system shell." 2017-09-11 18:20:59 +00:00
Elliott Hughes
60103831eb Merge "Trivial tests for <inttypes.h>/<stdlib.h> *abs and *div functions." 2017-09-08 19:37:16 +00:00
Jayant Chowdhary
ab2f79c0da For devices which are not treble enabled, return the system shell.
For treble enabled devices, still return the appropriate shell depending
on whether the process is a vendor process or a system one.

Test: Manual testing: on a bullhead device, ran test programs from
      /vendor/bin which used popen() and system(). The calls succeeded.

Bug: 65054230

Bug: 64516799

Merged-In: I15dfdbb107cfca7c0f92f337c9bb46b9876eb38e
Change-Id: I15dfdbb107cfca7c0f92f337c9bb46b9876eb38e
(cherry picked from commit 1e52871773)
2017-09-07 17:19:21 -07:00
Elliott Hughes
00d8a8b779 Trivial tests for <inttypes.h>/<stdlib.h> *abs and *div functions.
Because I want something to copy & paste into the NDK support library test
that's slightly better than taking the address of the function...

Bug: https://github.com/android-ndk/ndk/issues/502
Test: ran tests
Change-Id: If43089d16691d6a4dcf5d972450b14ed85bbca81
2017-09-07 17:01:37 -07:00
Elliott Hughes
04503da174 Merge "<stdbool.h> not necessary in C++." 2017-09-07 23:11:22 +00:00
Elliott Hughes
7379018162 <stdbool.h> not necessary in C++.
Bug: N/A
Test: builds
Change-Id: I40fffe92d4273eab5a98bd65013bb9da2aea2171
2017-09-07 13:28:14 -07:00
Christopher Ferris
5a905961f8 Merge "Provide method to dump backtrace heap data." 2017-09-06 01:37:47 +00:00
Christopher Ferris
602b88ccdd Provide method to dump backtrace heap data.
For non-zygote spawned processes, we might want to dump the backtrace
data. Provide a method to send a signal to a process and then dump the
data to a file.

Adds a method to dump the backtrace data on exit.

Update documentation and explain format of heap dump data.

Test: Ran unit tests, enabled new options and used them.
Change-Id: Ie2fa706694160731afe02c1382b037d06df1d069
2017-09-05 15:57:00 -07:00
Treehugger Robot
0f6dd63e06 Merge "Use env to invoke python" 2017-09-01 00:44:43 +00:00
Elliott Hughes
5702c6ff45 Finish <search.h>.
I'm unable to find a bug, but we've had requests for this internally
once or twice (though I pointed those folks at the STL), and there's
code we build for the host or in our bootloaders that would use this,
and there's reasonable-looking FreeBSD implementation ready and waiting.

Bug: N/A
Test: ran tests
Change-Id: I6ddee4b71bea4c22ed015debd31d3eaac4fcdd35
2017-08-31 17:38:51 -07:00