Commit graph

127 commits

Author SHA1 Message Date
Elliott Hughes
94072fbb4e Switch to inline assembler in crtbegin.
Using __builtin_frame_address was clever, but didn't work for arm64 (for
reasons which were never investigated) and the ChromeOS folks claim it
causes trouble for x86 with ARC++ (though without a reproduceable test case).

Naked functions turn out to be quite unevenly supported: some architectures
do the right thing, others don't; some architectures warn, others don't (and
the warnings don't always match the platforms that _actually_ have problems).

Inline assembler also removes the guessing games: everyone knows what the
couple of instructions _ought_ to be, and now we don't have to reason about
what the compiler will actually do (yet still keep the majority of the code
in C).

Bug: N/A
Test: builds, boots
Change-Id: I14207ef50ca46b6eca273c3cb7509c311146a3ca
2017-05-23 14:47:16 -07:00
Christopher Ferris
94bd274551 Add support for cortex-a73.
Bug: 37647380

Test: Built target with cortex-a73 for both 32 bit/64 bit.
Test: Built target with cortex-a53.cortex-a57 for both 32 bit/64 bit.
Test: Ran bionic unit tests, ran art target tests.

(cherry picked from commit 6fca047b53)

Change-Id: I2c48e1bc7f4a3c4548d1c66f87eab19c8618a0b8
2017-05-15 12:44:58 -07:00
Christopher Ferris
7a3681e5b6 Move libc_log code into libasync_safe.
This library is used by a number of different libraries in the system.
Make it easy for platform libraries to use this library and create
an actual exported include file.

Change the names of the functions to reflect the new name of the library.

Run clang_format on the async_safe_log.cpp file since the formatting is
all over the place.

Bug: 31919199

Test: Compiled for angler/bullhead, and booted.
Test: Ran bionic unit tests.
Test: Ran the malloc debug tests.
Change-Id: I8071bf690c17b0ea3bc8dc5749cdd5b6ad58478a
2017-05-03 08:50:43 -07:00
Elliott Hughes
2fad0d5927 Include the libc/kernel/android/scsi headers in the NDK.
We have some non-upstream (but Android common kernel) scsi headers to include
in the NDK.

Bug: N/A
Test: checked out/soong/ndk/sysroot
Change-Id: If7611e1e554ada63f266ec99d95dfedb99562ae9
2017-04-27 16:26:55 -07:00
Jake Weinstein
04d99df80d libc: ARM: Add 32-bit Kryo memcpy
* Memcpy is based on Scorpion due to Qualcomm's
  128-bit cache line size optimizations.

* PLDOFFSET and PLDSIZE are from the ARM64 Kryo memcpy routine.

Below are the results of the benchmark, tested on a OnePlus 3 with MSM8996.

Before:
BM_string_memcpy/8                          1000k          8    0.934 GiB/s
BM_string_memcpy/64                         1000k         11    5.785 GiB/s
BM_string_memcpy/512                        1000k         25   19.918 GiB/s
BM_string_memcpy/1024                         50M         42   23.938 GiB/s
BM_string_memcpy/8Ki                          10M        473   17.291 GiB/s
BM_string_memcpy/16Ki                          5M        565   28.976 GiB/s
BM_string_memcpy/32Ki                       1000k       1105   29.631 GiB/s
BM_string_memcpy/64Ki                       1000k       2194   29.864 GiB/s

After:
BM_string_memcpy/8                          1000k          6    1.145 GiB/s
BM_string_memcpy/64                         1000k          7    8.560 GiB/s
BM_string_memcpy/512                        1000k         18   27.370 GiB/s
BM_string_memcpy/1024                         50M         33   30.340 GiB/s
BM_string_memcpy/8Ki                          10M        266   30.770 GiB/s
BM_string_memcpy/16Ki                          5M        553   29.599 GiB/s
BM_string_memcpy/32Ki                       1000k       1121   29.219 GiB/s
BM_string_memcpy/64Ki                       1000k       2208   29.678 GiB/s

Test: make otapackage
Test: Ran bionic unit tests on Pixel device. Verified memcpy wins on
Test: Pixel device.

Change-Id: Id7a9c37ef75a306dd5cf8d374d79d0fe83f8a3ba
2017-04-13 11:18:56 -07:00
Jake Weinstein
4d114f9e21 libc: use Cortex-A7/A53 memset on Kryo
Tested on OnePlus 3 with MSM8996

Before (Krait):
BM_string_memset/8                          1000k          7    1.071 GiB/s
BM_string_memset/64                         1000k          9    6.720 GiB/s
BM_string_memset/512                        1000k         19   26.699 GiB/s
BM_string_memset/1024                       1000k         29   34.214 GiB/s
BM_string_memset/8Ki                          10M        184   44.302 GiB/s
BM_string_memset/16Ki                          5M        351   46.656 GiB/s
BM_string_memset/32Ki                          5M        686   47.744 GiB/s
BM_string_memset/64Ki                       1000k       1355   48.342 GiB/s

After (A7/A53):
BM_string_memset/8                          1000k          7    1.017 GiB/s
BM_string_memset/64                         1000k          7    8.039 GiB/s
BM_string_memset/512                        1000k         13   37.976 GiB/s
BM_string_memset/1024                       1000k         21   47.595 GiB/s
BM_string_memset/8Ki                          10M        150   54.354 GiB/s
BM_string_memset/16Ki                         10M        285   57.336 GiB/s
BM_string_memset/32Ki                          5M        555   59.016 GiB/s
BM_string_memset/64Ki                       1000k       1097   59.720 GiB/s

Test: make otapackage
Test: Verified this wins in all dimensions on a Pixel device.

Change-Id: I4cb72cc0363877de7c41d6f991149fda42fd0b4b
2017-04-12 14:58:29 -07:00
Treehugger Robot
21d4a9ac6b Merge "Move localtime.c over to CachedProperty." 2017-04-12 18:15:53 +00:00
Dan Willemsen
230a7a44ce Mark CRT objects as vendor available
This will build separate copies of the CRT for vendor vs system when
BOARD_VNDK_VERSION is set. We'll be able to change crtbrand / etc as
needed with #ifdef __ANDROID_VNDK__ and similar.

Bug: 36426473
Bug: 36079834
Test: Put #ifdef __ANDROID_VNDK__ into crtbrand.S, see changes
Change-Id: I7db0cccfe94d144f072e7cef23832884f3c066f0
2017-04-12 00:06:47 +00:00
Elliott Hughes
0e8616a37a Move localtime.c over to CachedProperty.
Since localtime.c is C, this entails pulling our code out into its own
C++ file, which we should probably have done years ago anyway.

Bug: N/A
Test: ran tests, and manually tested via Settings
Change-Id: Ifc787a553e8f739a87641a2d35321aca40a47286
2017-04-11 14:44:51 -07:00
Dan Willemsen
51a9bf1673 Remove .(ll)ndk suffix from (ll)ndk_library
Soong handles these automatically now.

Bug: 33241851
Test: Android-aosp_arm.mk is the same before/after
Test: build.ninja is the same before/after
Test: build-aosp_arm.ninja is the same before/after
Merged-In: Ibfe4cf5db732d9007b1cc12dbc523c427de1b23d
Change-Id: Ibfe4cf5db732d9007b1cc12dbc523c427de1b23d
2017-04-11 15:15:30 +00:00
Dan Willemsen
b8f7fde4bd Add LLNDK stub libraries for the VNDK
The stub libraries are the same as the (equivalent version) NDK, but
they also contain symbols tagged with 'vndk'. Except there are none of
those in Bionic currently.

For headers, the LLNDK/VNDK isn't using a sysroot like the NDK. Nor is
it hardcoding an explicit source path list like the platform. Instead it
runs the bionic/libc/include directory through versioner like the NDK,
then exports those generated headers and the kernel headers from the
stub library like any other exported header. Except it uses -isystem
instead of -I due to export_headers_as_system.

Test: aosp_arm; m -j
Test: Enable BOARD_VNDK_VERSION on aosp_arm; m -j
Test: Inspect out/soong/build.ninja before/after (w/o vndk)
Change-Id: Ief58a73907a83053b408b1d4b62999cba470d61c
2017-04-05 22:42:08 +00:00
Dan Willemsen
a3ed901ef8 Remove obsolete Android.mk comments
Test: none
Change-Id: I0419800d44a7918a4415baf840c7d30bf30a18ed
2017-04-04 15:52:13 -07:00
Christopher Ferris
07807a10a2 Merge "Add kryo support." 2017-04-04 21:10:55 +00:00
Josh Gao
10ec9286ae Break android_set_abort_message out of libc_logging.
libc_logging is getting statically linked into the crash handler
library, resulting in two copies of the abort message code existing in
processes, one in the linker, and one in the crash handler.

Move android_set_abort_message to its own file to solve this.

Bug: http://b/36862204
Test: /data/nativetest/debuggerd_test/debuggerd_test32
Change-Id: Ie198c5a3bb07645aa43296915c9a6752693f14a9
2017-04-03 16:00:10 -07:00
Christopher Ferris
950a95836d Add kryo support.
Currently, using kryo is the same as using krait, but there are specialized
routines that are pending that will be used after this commit.

Bug: 36728278

Test: Built and booted a sailfish using kryo.
Change-Id: Id7510640673c31f7536367041212db6d96a564f0
2017-04-03 10:30:55 -07:00
Dan Albert
22805ea9b8 Revert "Revert "Run the versioner as part of the build.""
This reverts commit 69c7562f59.

Test: make checkbuild
Change-Id: Ie443029398c01b45e0a0317a8074808b064f35d4
2017-03-27 13:06:45 -07:00
Prashant Patil
fcb877ac4b Add libc optimizations to bionic for MIPS
Test: Used bionic tests available under bionic/tests folder.
      Tested for mips32r1/mips32r2/mips64r6 on emulators.

Change-Id: I589415ddc496df3f6067ae34cb33ca58b3a1f276
Signed-off-by: Prashant Patil <prashant.patil@imgtec.com>
2017-03-16 10:26:24 -07:00
Elliott Hughes
926add1593 Generate both static and shared libseccomp_policy.
Also switch to Android.bp

Bug: N/A
Test: builds
Change-Id: I33697a40b30d071f8d07aa33e1fb2b0c6e8a9f6d
2017-03-02 18:57:44 -08:00
Dimitry Ivanov
4021909162 Revert "Revert "Revert "Make libc.so global"""
This reverts commit 2a4d892c7f.

Bug: http://b/35417197
Bug: http://b/35338922
Bug: http://b/35700074
Test: manual
Change-Id: Ib99d23d46664f3efa5be70213aa093b505e38775
2017-02-28 21:05:34 +00:00
Dimitry Ivanov
2a4d892c7f Revert "Revert "Make libc.so global""
This reverts commit 65236d43e8.

Bug: http://b/35417197
Bug: http://b/35338922
Test: vogar --classpath out/target/common/obj/JAVA_LIBRARIES/core-tests_intermediates/classes.jack  --mode=device --variant=X32 dalvik.system.JniTest#testGetSuperclass
Change-Id: Ibf3bb7396e7d11ebe95e2f9267d0fc4af3fbe8c5
2017-02-17 22:38:22 +00:00
Dimitry Ivanov
65236d43e8 Revert "Make libc.so global"
This reverts commit 879177c9e1.

Bug: http://b/26833548
Change-Id: I23e0b34777d18e369063185da14c57994807da29
2017-02-14 19:03:26 +00:00
Dimitry Ivanov
879177c9e1 Make libc.so global
This is a way to avoid loading multiple libc.so
when non-default namespace search path includes
/system/lib. This is used by some art tests.

Bug: http://b/26833548
Test: m -j32 test-art-target-run-test-004-JniTest
Change-Id: I919d3a0560bd3c9ac19df21a235641a667f0f017
2017-02-13 10:05:17 -08:00
mspector
dd91b32baf Removing the kuser_helper elf note from building
This change removes the kuser_helper note from building automatically
with any binary but leaves the note.
Also fixes a typo in the note.

Original patch adding the note:
Ib8366e2a0810092b71381d57dee4bdaa56369a24

Bug: 34815073
Test: Manual - Note is no longer added to binaries
Change-Id: Ieb81f9d9127d1f8a522434a31c696d743238e2a5
2017-02-09 18:37:52 -08:00
David James
a187a6f12e Merge "Revert "Remove the global thread list."" 2017-02-02 02:46:40 +00:00
Elliott Hughes
7484c21c4c Revert "Remove the global thread list."
This reverts commit b0e8c565a6.

Breaks swiftshader (http:/b/34883464).

Change-Id: I7b21193ba8a78f07d7ac65e41d0fe8516940a83b
2017-02-02 02:41:38 +00:00
Elliott Hughes
9b9d4ebc8b Merge "Remove the global thread list." 2017-02-01 16:16:41 +00:00
Elliott Hughes
f8562c5f8f Remove backwards compatibility for old system properties.
No-one is directly upgrading from pre-K to O...

Also move more implementation details out of the header file.

Bug: http://b/33926793
Test: boots
Change-Id: I7a0936acbb1cea8a3b2cd6797ec53ba7e4a050f3
2017-01-27 16:19:59 -08:00
mspector
2e3d6a1d67 Adding kuser_helper on note to all arm32 binaries.
A kernel change is going in for 64bit arm to disable kuser_helper vector
pages for 32bit processes.  This change adds a special elf note to
all arm32 binaries built with bionic.  This note tells the kernel to
load the kuser_helper vector page for the process.

Bug: 33689037
Test: Manual - Phone boots, 32bit binaries have the notes, 64bit
binaries do not.
Change-Id: Ib8366e2a0810092b71381d57dee4bdaa56369a24
2017-01-25 17:33:05 -08:00
Colin Cross
35bbed8020 Declare dependency on android_filesystem_config.h
android_filesystem_config.h comes from a directory outside bionic/libc
so it can't be referenced directly, add it as a source file through
a filegroup module.

Bug: 34283327
Test: builds
Test: libc rebuilds after touch system/core/include/private/android_filesystem_config.h
Change-Id: I90f6b7b25b70842b8619d558074449f13e6e6b03
2017-01-17 18:31:33 -08:00
Elliott Hughes
940d460f59 Merge "Revert "Revert "move android_ids into bionic""" 2017-01-10 01:15:30 +00:00
Elliott Hughes
b0e8c565a6 Remove the global thread list.
Another release, another attempt to fix this bug.

This change affects pthread_detach, pthread_getcpuclockid,
pthread_getschedparam/pthread_setschedparam, pthread_join, and pthread_kill:
instead of returning ESRCH when passed an invalid pthread_t, they'll now SEGV.

Note that this doesn't change behavior as much as you might think: the old
lookup only held the global thread list lock for the duration of the lookup,
so there was still a race between that and the dereference in the caller,
given that callers actually need the tid to pass to some syscall or other,
and sometimes update fields in the pthread_internal_t struct too.

We can't check thread->tid against 0 to see whether a pthread_t is still
valid because a dead thread gets its thread struct unmapped along with its
stack, so the dereference isn't safe.

Taking the affected functions one by one:

* pthread_getcpuclockid and pthread_getschedparam/pthread_setschedparam
  should be fine. Unsafe calls to those seem highly unlikely.

* Unsafe pthread_detach callers probably want to switch to
  pthread_attr_setdetachstate instead, or using pthread_detach(pthread_self())
  from the new thread's start routine rather than doing the detach in the
  parent.

* pthread_join calls should be safe anyway, because a joinable thread won't
  actually exit and unmap until it's joined. If you're joining an
  unjoinable thread, the fix is to stop marking it detached. If you're
  joining an already-joined thread, you need to rethink your design.

* Unsafe pthread_kill calls aren't portably fixable. (And are obviously
  inherently non-portable as-is.) The best alternative on Android is to
  use pthread_gettid_np at some point that you know the thread to be alive,
  and then call kill/tgkill directly. That's still not completely safe
  because if you're too late, the tid may have been reused, but then your
  code is inherently unsafe anyway.

If we find too much code is still broken, we can come back and disable
the global thread list lookups for anything targeting >= O and then have
another go at really removing this in P...

Bug: http://b/19636317
Test: N6P boots, bionic tests pass
Change-Id: Ia92641212f509344b99ee2a9bfab5383147fcba6
2017-01-07 14:16:46 -08:00
Elliott Hughes
3f6eee9793 Revert "Revert "move android_ids into bionic""
This reverts commit 77cb68d9f2.

Change-Id: Ibc9f775c4cd418be90fd8a6f192dd72ca5dff09a
2016-12-13 23:47:25 +00:00
Christopher Ferris
8b3e812684 Merge "libc: ARM64: update memset/strlen/memcpy/memmove to newlib/cortex-strings" 2016-12-13 23:11:27 +00:00
Treehugger Robot
50ae6dde5b Merge "Revert "move android_ids into bionic"" 2016-12-13 00:31:25 +00:00
Elliott Hughes
77cb68d9f2 Revert "move android_ids into bionic"
This reverts commit 1a13db5b26.

Change-Id: I7f571b3a9d542694d16fb9cf1131ef9e59d330ea
2016-12-12 22:11:37 +00:00
Elliott Hughes
ded6c91acc Merge "move android_ids into bionic" 2016-12-10 00:13:05 +00:00
Dimitry Ivanov
fc0d48078a loader: stop linking libdl/c/m into the loader
This is to prevent situations when libgcc.a calls into incorrect
implementation of dl_iterate_phdr.

Bug: http://b/27106625
Test: build && run bionic-unit-tests --getst_filter=dl*:Dl*
Change-Id: I4cba8c4a156f91f17ba3d95c39cb80f9b70c9d8f
2016-12-06 11:15:24 -08:00
Elliott Hughes
68ddf5cad3 Merge "Abort harder." 2016-11-30 23:06:26 +00:00
William Roberts
1a13db5b26 move android_ids into bionic
Generate the android_ids array and include into the
build.

Test: The bionic is built and that core AIDs work as
expected with commands like chown, mkdir and init services
and builtins.
Bug: 27999086
Change-Id: Ib575bf85326c91801c5674db475dcb9cf44c00dc
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-11-30 12:54:08 -08:00
Treehugger Robot
f563ae89be Merge "Ship all the UAPI bits." 2016-11-30 19:43:30 +00:00
Elliott Hughes
4bf5522662 Abort harder.
Some PoS internal system can't cope with more than 4 stack frames,
so the fact that our abort(3) implementation takes 4 frames by itself
makes it useless.

Re-reading POSIX, it only says "behaves as if", so the previous
implementation chain wasn't mandatory and we can just go straight to
calling tgkill...

Before:

     #00 pc 0000000000069be4  /system/lib64/libc.so (tgkill+8)
     #01 pc 0000000000066d50  /system/lib64/libc.so (pthread_kill+64)
     #02 pc 0000000000028110  /system/lib64/libc.so (raise+24)
     #03 pc 000000000001d4ec  /system/lib64/libc.so (abort+52)

After:

     #00 pc 0000000000069bc8  /system/lib64/libc.so (tgkill+8)
     #01 pc 000000000001d4c8  /system/lib64/libc.so (abort+80)
     #02 pc 0000000000001494  /system/xbin/crasher64 (_ZL9do_actionPKc+872)
     #03 pc 00000000000010e0  /system/xbin/crasher64 (main+88)

This is less useful on 32-bit ARM because there there's an extra trampoline
from an assembler abort(3) implementation, so you'll still only get one
meaningful stack frame. But every other architecture will now get two!

But wait!

It turns out that the assembler hack isn't needed any more. Here we are
unwinding just fine all the way through the 32-bit ARM crasher:

Before (with direct call to tgkill but still using the assembler):

     #00 pc 00049e7c  /system/lib/libc.so (tgkill+12)
     #01 pc 00019c6f  /system/lib/libc.so (__libc_android_abort+50)
     #02 pc 000181f8  /system/lib/libc.so (abort+4)
     #03 pc 00001025  /system/xbin/crasher (_ZL9do_actionPKc+656)
     #04 pc 00017721  /system/lib/libc.so (__libc_init+48)
     #05 pc 00000b38  /system/xbin/crasher (_start+96)

After:

     #00 pc 00049e6c  /system/lib/libc.so (tgkill+12)
     #01 pc 00019c5f  /system/lib/libc.so (abort+50)
     #02 pc 00001025  /system/xbin/crasher (_ZL9do_actionPKc+656)
     #03 pc 00017721  /system/lib/libc.so (__libc_init+48)
     #04 pc 00000b38  /system/xbin/crasher (_start+96)

(As you can see, the fact that we see __libc_init rather than main was true
with the assembler stub too, so that's not a regression even if it does seem
odd...)

Bug: N/A
Test: ran crasher64
Change-Id: I9dd5b214c495604c8b502c7ec0de3631080d8c29
2016-11-29 22:02:25 -08:00
Treehugger Robot
609880c12f Merge "Fix getpriority/setpriority types." 2016-11-30 05:49:03 +00:00
Dan Willemsen
b99b6762b4 Merge "Enable libc/libdl/libm/linker for host bionic" 2016-11-30 05:32:06 +00:00
Elliott Hughes
8f0e42fda6 Fix getpriority/setpriority types.
Bug: N/A
Test: builds
Change-Id: Ica099bae04a0260871783452811a54672094ba4a
2016-11-29 15:14:11 -08:00
Elliott Hughes
bd734f0716 Merge "Use icu4c to implement <wctype.h>." 2016-11-29 23:05:31 +00:00
Dan Willemsen
7ec52b12ef Enable libc/libdl/libm/linker for host bionic
Disables debuggerd integration unless building for android.

Bug: 31559095
Test: Diff out/soong/build.ninja before/after, only change is moving
      linker's libdebuggerd_client static lib to the beginning of the
      list.
Test: lunch aosp_arm64-eng; mmma -j bionic
Change-Id: I62e725f7a9b98b7fe31637d0a835fd5846b0aff0
2016-11-29 21:09:05 +00:00
Elliott Hughes
a57ca0da69 Use icu4c to implement <wctype.h>.
Pretty useless, because the POSIX APIs are useless for actually
internationalization, but it lets us put this to bed for good.

Bug: http://b/18492914
Test: bionic tests
Change-Id: I4dd0aff66c44b5547039be3ffea806c865b9014a
2016-11-29 19:19:30 +00:00
Dan Albert
063e86ace8 Ship all the UAPI bits.
Test: make ndk
Bug: None
Change-Id: I24507846fb62b5844e06d7a424497a5ffc0357d1
2016-11-29 11:17:58 -08:00
Elliott Hughes
86841573ed Merge "Implement <langinfo.h>." 2016-11-29 19:16:09 +00:00
Christopher Ferris
ecebb49ac6 Add cortex-a7 specific routines.
Test: Changed angler target to use cortex-a7 and I compiled.
Test: Booted this version on angler and ran bionic-unit-tests.

Change-Id: Ice7f6ea38a2569582161a8e659d7877918c1a45a
2016-11-28 12:49:36 -08:00