Commit graph

206 commits

Author SHA1 Message Date
Elliott Hughes
25f17e48df Better backwards compatibility for stat64.
Caused problems for some Google source switching to unified headers
because the legacy headers just used #define instead.

Bug: http://b/73210428
Test: builds
Change-Id: If8a36f284031e57af419903610029a8c34a23d91
2018-02-12 15:48:01 -08:00
Tom Cherry
ab8c861597 Merge "Add ability to read /etc/passwd and /etc/group" 2018-02-12 16:27:20 +00:00
Tom Cherry
6034ef85d8 Add ability to read /etc/passwd and /etc/group
Add the capability to read /etc/passwd and /etc/group for getpw* and
getgr* functions.

Bug: 27999086
Test: pwd, grp, grp_pwd_file unit tests
Test: Read in custom users/groups from /etc/{passwd,group}
Change-Id: Idc1f054af8a7ca34743a90493495f0ccc775a0d8
2018-02-08 12:38:57 -08:00
Treehugger Robot
0f546f45d7 Merge "Run bpfmt manually." 2018-02-06 03:58:23 +00:00
Elliott Hughes
d50a1de565 Run bpfmt manually.
Bug: N/A
Test: builds
Change-Id: I0cf145c3b699ac8ef170a63366832f63a9cc1a91
2018-02-05 17:30:57 -08:00
Elliott Hughes
211c4d35f2 Rewrite getentropy.
The error handling was a mess, resulting in an infinite loop
(and a test timeout) if you actually took the /dev/urandom
fallback. I'm also unconvinced that the getrandom(2) path was correct
because of the various reasons why we might get a short count back
(http://man7.org/linux/man-pages/man2/getrandom.2.html). In this version,
the two paths look very similar except for the getrandom(2) failure case,
where it's now much clearer that we just give up so that we can boot
(http://b/33059407).

Bug: http://b/33059407
Bug: http://b/67015565
Test: ran tests on hikey and a ICS Galaxy Nexus
Change-Id: Ie715d59b46f7a70bae66943c316168838787b40d
2018-02-05 12:57:22 -08:00
Elliott Hughes
5905d6f879 Add sigset64_t and accompanying functions.
This doesn't address `struct sigaction` and `sigaction`. That will
come later.

Bug: http://b/72493232
Test: ran tests
Change-Id: I4134346757ce3a4dac6feae413361cec16223386
2018-01-30 18:47:16 -08:00
Elliott Hughes
6dafb4ac78 Move all the short <signal.h> functions together.
Bug: N/A
Test: ran tests
Change-Id: Ie5509e4108efcd5d403227ce99bef2b61c79f757
2018-01-26 17:47:56 -08:00
Dan Albert
40f15ec4b1 Package bionic static libraries in the NDK.
Test: build/soong/scripts/build-ndk-prebuilts.sh
Bug: https://github.com/android-ndk/ndk/issues/272
Change-Id: Ibb21d799fdcf230ed45db0b809e20dd86d2d8e52
2018-01-22 12:40:56 -08:00
Elliott Hughes
3048a36a34 Simplify CT_CCL and CT_STRING inner loop.
Makes no difference to the benchmarks, but does make the code a bit
more readable.

Bug: http://b/68672236
Test: ran tests, benchmarks
Change-Id: I63fa5f78d077c86e4f4f194f2c76ab5510c29109
2018-01-19 17:58:07 -08:00
Treehugger Robot
2b66844a0b Merge "Support %mc/%ms/%m[ in sscanf." 2018-01-20 01:17:25 +00:00
Elliott Hughes
38e4aefe6c Support %mc/%ms/%m[ in sscanf.
Also support the "long" (wchar_t) variants.

Bug: http://b/68672236
Test: ran tests
Change-Id: I060e98b4d2feb61e12986d9d51e4710b2b1d9724
2018-01-19 14:53:55 -08:00
Ian Pedowitz
b6310c2aa7 Fixing app compat issue b/72143978
This is a squash revert of a4a4854 and 1b0f2b4

  Revert "Remove a test for backwards compatibility we no longer support."

  This reverts commit a4a485454a.

  # This is the commit message #2:

  Revert "Remove obsolete workaround."

  This reverts commit 1b0f2b49d5.

Bug: 72143978
Bug: 24465209
Test: Tested failing case on sailfish, reverted back all CL's since
Test: 3471433 for b/24465209 and apps open
2018-01-18 16:26:45 -08:00
Elliott Hughes
f1515f6408 Clean up the time(2) implementation.
This is also slightly faster for the no VDSO case (56ns vs 66ns).

Bug: N/A
Test: ran tests, benchmarks
Change-Id: I2b0edd06ee6942eb57c32678279278a53ca5ee9b
2018-01-12 15:20:28 -08:00
Elliott Hughes
1b0f2b49d5 Remove obsolete workaround.
Bug: http://b/24465209
Test: manually ran the app.
Change-Id: I1e2a498864c74ff3a9886b97f7dc60ad7f6dfa44
2018-01-10 11:05:19 -08:00
Dimitry Ivanov
a238a9a328 Merge "Fix dlclose for libraries with thread_local dtors" 2018-01-10 13:50:01 +00:00
dimitry
06016f226e Fix dlclose for libraries with thread_local dtors
Introduce new flag to mark soinfo as TLS_NODELETE when
there are thread_local dtors associated with dso_handle
belonging to it.

Test: bionic-unit-tests --gtest_filter=dl*
Test: bionic-unit-tests-glibc --gtest_filter=dl*
Bug: https://github.com/android-ndk/ndk/issues/360
Change-Id: I724ef89fc899788f95c47e6372c38b3313f18fed
2018-01-10 10:24:06 +01:00
Dan Willemsen
ca056d742f Expose kernel input headers for toolbox
Toolbox is moving to Android.bp, and its genrule needs access to these
kernel headers.

Test: mmma system/core/toolbox
Change-Id: I213a36e1f4bb5d4e3e3e105ed7ab01ec945014a2
2018-01-08 14:00:24 -08:00
Elliott Hughes
9dc37b9439 Merge "Refactor the ato* and strto* family." 2017-12-20 00:05:57 +00:00
Elliott Hughes
1921dce886 Refactor the ato* and strto* family.
There are no meaningful changes here, just a minimal conversion to two
C++ templates to make further changes easier.

Bug: N/A
Test: ran tests, benchmarks
Change-Id: I958fbf17a85f19dd8f17bfb4bbb9314d220daa3b
2017-12-19 13:55:54 -08:00
Tom Cherry
e275d6d72d Split properties into their own class to make testing better
Reinitializing system properties can result in crashes later in the
program, and is generally not recommended or even supported.  This
change moves the actual logic for system properties into a class that
can be tested in isolation, without reinitializing the actual system
property area used in libc.

Bug: 62197783
Test: boot devices, ensure properties work
Test: system property unit tests and benchmarks
Change-Id: I9ae6e1b56c62f51a4d3fdb5b62b8926cef545649
2017-12-18 15:17:55 -08:00
Treehugger Robot
b9d5a87b1b Merge "Use treble_linker_namespace instead of treble." 2017-12-15 17:41:27 +00:00
Steven Moreland
96bbc5ca87 Use treble_linker_namespace instead of treble.
More specific. Treble is being removed.

Bug: 62019611
Test: manual
Change-Id: I94c21c6a5cb6a258bfb36a0b7da23abdc73a67fb
2017-12-13 14:11:26 -08:00
Tom Cherry
e6e8f6ee77 Merge "Add support for serialized property contexts" 2017-12-13 01:28:29 +00:00
Tom Cherry
79b724ca5a Add support for serialized property contexts
This adds support for reading a serialized
/dev/__properties__/property_info file, which contains a
serialized trie that maps property names to the SELinux context to
which they belong.

Performance wise on walleye, this change reduces the start up cost in
libc from ~3000us to ~430us.  On a benchmark that calls
__system_property_find() for each property set on the system, it
reduces the time per iteration from ~650us to ~292us.

Bug: 36001741
Test: Boot bullhead, walleye, run unit tests
Test: Benchmark initialization and lookup performance

Change-Id: I0887a3a7da88eb51b6d1bd494fa5bce593423599
2017-12-12 00:36:20 -08:00
Elliott Hughes
ee291c021c Explain why the mips/mips64 ndk headers need to be present.
Bug: N/A
Test: N/A
Change-Id: I70e3a043884784d86a9a3ec7066d945803481b54
2017-12-11 11:32:34 -08:00
Lazar Trsic
790d2f7161 Revert "Remove mips/mips64 headers from the NDK sysroot."
This reverts commit 050f046d3d.

Change-Id: I2549dfccced02b61383cd9e534bfd34cf1d6dba1
2017-11-27 16:48:14 +01:00
Isaac Chen
b7d6df2b61 Merge "Optimize libc for generic armv7/armv8 neon cores" 2017-11-23 09:08:24 +00:00
Tom Cherry
fd44b9f8d8 Split system_properties.cpp into its component pieces
system_properties.cpp is a little bit unmanageable in its current
form, and is overdue for a refactoring into more clearly defined
components.

Of particular interest, is creating of a Contexts interface that
handles mapping of system property name -> SEContext and its
associated prop_area, and creating two classes that implement the
current and legacy functionality.  This is needed as there will likely
be a third even newer way to do this mapping.

Bug: 36001741
Test: boot bullhead, system property unit tests
Change-Id: Ie75ec6fea1a95f90813918f54669d533e51327c6
2017-11-14 08:50:52 -08:00
Treehugger Robot
db4f334695 Merge "Clean up crt defaults" 2017-11-06 22:09:22 +00:00
Colin Cross
8697f10e74 Merge "Remove no_default_compiler_flags from crt*" 2017-11-06 18:59:00 +00:00
Colin Cross
7d7b368a44 Clean up crt defaults
Make crt_so_defaults inherit from crt_defaults, remove duplicates
from crt_so_defaults, and make the users of crt_so_defaults not
directly use crt_defaults.

Test: m checkbuild
Change-Id: I1448a5a4c86521b994fd4d79120e0b7d3a9c5ba9
2017-11-03 13:38:40 -07:00
Colin Cross
6a2610dbd3 Remove no_default_compiler_flags from crt*
no_default_compiler_flags is unnecessary and causes problems when
necessary flags like -no-canonical-prefixes are not passed.

Bug: 68719465
Test: m checkbuild
Change-Id: Ifdc68067eb3208b151b0a96820aa9a57b82db057
2017-11-03 13:37:42 -07:00
Dan Albert
050f046d3d Remove mips/mips64 headers from the NDK sysroot.
Test: build/soong/scripts/build-ndk-prebuilts.sh
Bug: None
Change-Id: Iac212939636abbbf8402c85c5e89c724fb531c91
2017-11-03 12:02:50 -07:00
Elliott Hughes
2f9c8ce38a Start de-duplicating the regular and wide printf implementations.
This patch switches to C++ (in anticipation of needing it later), removes
a little duplication (via a macro for now), and ensures uniform support
for %C/%lc and %S/%ls between regular and wide (with new tests).

Since it's so hard to debug problems in printf (as the time I've wasted
already today will testify), that's all I want to do in this change. The
other 500 lines of diff can wait...

(Also merge "floatio.h" into "local.h" now all the users are in forked
code.)

Bug: http://b/67371539
Test: ran tests
Change-Id: I083353d89c32b9302d759ca6967cc6d8a62cd8a5
2017-11-01 18:13:36 -07:00
Treehugger Robot
07e412419b Merge "More missing _unlocked <stdio.h> functions." 2017-10-31 22:43:34 +00:00
Elliott Hughes
37ad959783 More missing _unlocked <stdio.h> functions.
Also simplify trivial one-liners like perror/puts/fputs, and clean up
fread/fwrite slightly.

Fix perror to match POSIX.

Add basic perror and *_unlocked tests.

Bug: N/A
Test: ran tests
Change-Id: I63f83c8e0c15c3c4096509d17421ac331b6fc23d
2017-10-31 13:23:41 -07:00
Elliott Hughes
3a589c2362 Fork vfprintf.c/vfwprintf.c.
Future changes will start reducing the duplication...

Bug: http://b/67371539
Test: ran tests
Change-Id: I477afea34f9e1f41817823984bd0548944ee5eec
2017-10-30 11:43:58 -07:00
Elliott Hughes
cc3d04f03a Add null checks to <dirent.h> functions.
Move all the new checks over to the existing __fortify_fatal.

Bug: http://b/67455242
Test: ran tests
Change-Id: Idb899c58c32d52d3b423caf1a91feb7defcba9b3
2017-10-26 16:16:33 -07:00
Elliott Hughes
fa386e0d1e Add POSIX swab.
Surprisingly to me, there are actual uses of `swab` in the codebases
I have available to search, including one with a #ifndef __ANDROID__
around it.

Bug: N/A
Test: ran tests
Change-Id: Ic91b78ae22bb65c346cb46dd38916f48d979abe0
2017-10-18 13:34:32 -07:00
Josh Gao
0e0e370154 Add libc_nopthread.
Add a static library containing the non-pthread dependent parts of
libc.

Bug: http://b/64400027
Test: sailfish boots
Test: bionic-unit-tests32/64, no new failures
Test: bionic-unit-tests-static32/64, no new failures
Change-Id: I93dc3811acddad7936d11b369b98cefd945ee2d5
2017-10-16 21:31:37 -07:00
Elliott Hughes
ddd6436df2 Merge "Unified sysroot: kill arch-specific include dirs." 2017-10-12 22:23:58 +00:00
Elliott Hughes
d4ca231ae2 Unified sysroot: kill arch-specific include dirs.
<machine/asm.h> was internal use only.

<machine/fenv.h> is quite large, but can live in <bits/...>.

<machine/regdef.h> is trivially replaced by saying $x instead of x in
our assembler.

<machine/setjmp.h> is trivially inlined into <setjmp.h>.

<sgidefs.h> is unused.

Bug: N/A
Test: builds
Change-Id: Id05dbab43a2f9537486efb8f27a5ef167b055815
2017-10-12 13:19:51 -07:00
Elliott Hughes
14e3ff9f09 Implement <spawn.h>.
As described here:

  http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html

And here:

  http://man7.org/linux/man-pages/man3/posix_spawn.3.html

Bug: N/A (but mentioned in my inbox since 2013)
Test: ran tests
Change-Id: I0b27b2919b660779e3bd8a25fb429527c16dc621
2017-10-11 14:57:49 -07:00
Isaac Chen
5e7c90b7f1 Optimize libc for generic armv7/armv8 neon cores
If (2nd) arch is "arm", (2nd) arch variant is "armv7-a-neon" or
"armv8-a", and (2nd) cpu variant is "generic", current Android.bp only
uses generic ARM assmebly or C code, even though they all have NEON.

This change use functions optimized for cortex-a15 (for these generic
cores), which are a reasonable balance for most ARM cores with Neon.

Also build script for specific armv7/armv8 cores are refactored to
take advantage of the common part (mostly cortex-a15 code), so more
than 150 repeated lines are removed.

Bug: 66064745
Test: For armv7-a-neon/armv8-a "generic" core
       - boot with GSI on sailfish
       - related cortex-a15 function are built and linked.
      All libc.a/libc.so built are identical for the following cores:
       - cortex-a7, cortex-a8, cortex-a9, cortex-a15, krait
       - cortex-a53, cortex-a53.a57, cortex-a73, denver, kryo
      $ lunch aosp_arm64 # with TARGET_2ND_CPU_VARIANT unset
      # For each $core listed above
      $ TARGET_2ND_CPU_VARIANT=$core m -e -j libc
Change-Id: Ia565d3ea09e034adcd014e7467a5b791cff908cb
2017-10-11 19:12:21 +08:00
Christopher Ferris
93ea09f65c Add directives to force stop unwinding.
On aarch64/x86/x86_64 add a macro that inserts a cfi directive that will
stop unwinding.

For arm, clang doesn't allow emitting .cantunwind, so add a comment and
leave it the same as it current is.

Add this macro to __libc_init and __start_thread.

Also, remove duplicate compilation of libc_init_static.cpp that already
includes the static library that includes that file.

Bug: 15469122

Test: Did unwinds using new unwinder tool (unwind) and debuggerd -b
Test: and verified new unwinder works on aarch64/x86/x86_64.
Test: Verified that it works on old unwinder for aarch64/x86, but
Test: x86_64 doesn't work properly, but as well as before.
Change-Id: I77302e8f6c7ba1549d98a4a164106ee82c9ecadc
2017-10-05 15:18:47 -07: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
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
Treehugger Robot
7e6f98b93d Merge "Remove clang: true" 2017-09-11 21:39:41 +00: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