Commit graph

24230 commits

Author SHA1 Message Date
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
Elliott Hughes
232541aa02 Merge "More printf de-duplication." 2017-11-03 15:26:02 +00:00
Elliott Hughes
3a33da5d73 Merge "Fix pthread test race conditions." 2017-11-03 04:55:33 +00:00
Elliott Hughes
4f97cffd29 Merge "Add basic tests for the remaining 9 libm <fenv.h> functions." 2017-11-03 02:52:03 +00:00
Elliott Hughes
618303ca4a More printf de-duplication.
Fix the 'j' (intmax_t/uintmax_t) length qualifier in the wide
variant. (With new tests that fail without this fix.)

Fix a typo in the wide support for intmax_t*, which isn't testable because
%n is disabled on Android (and will be removed in a later cleanup pass).

Also move the public vfprintf/vfwprint functions into stdio.cpp.

Bug: http://b/67371539
Test: ran tests
Change-Id: Ib003599b1e9cb789044a068940b59e447f2cb7cb
2017-11-02 16:58:44 -07:00
Elliott Hughes
18a1957444 Add basic tests for the remaining 9 libm <fenv.h> functions.
It seems that feenableexcept/fegetexcept are lying to us on arm/arm64
because the hardware doesn't actually support such functionality. When
I get confirmation of that from ARM I'll fix the <fenv.h> implementation
correspondingly --- writing to/reading from reserved FP control register
bits as we currently do doesn't seem like the best of ideas.

Bug: http://b/31742322
Test: ran tests on arm/arm64/x86/x86-64
Change-Id: If78f83ddab221b568fa168c3364a7ae95c024983
2017-11-02 16:18:43 -07:00
Treehugger Robot
c7f296ad99 Merge "tools: fix error when /bin/sh isn't bash" 2017-11-02 22:56:40 +00:00
Elliott Hughes
0bd9d13572 Fix pthread test race conditions.
Guarantee that threads live long enough for us to fiddle with them.

Bug: http://b/68768209
Test: ran tests
Change-Id: I06b1bb64fec9f8181b5f5b43ca1030e255fdccc1
2017-11-02 13:11:13 -07:00
Sergii Piatakov
564ed96caf tools: fix error when /bin/sh isn't bash
The following scripts use `bash` specific variable `${BASH_SOURCE[0]}`
so this doesn't work correct in case when `/bin/sh` isn't `bash`.

Test: repo upload bionic
Change-Id: I12ce0666f9404107dceb03960bad4ec11b14ba2d
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
2017-11-02 20:41:59 +02:00
Elliott Hughes
eed523e7cb Merge "Test __fpclassify/__isinf/__isnan." 2017-11-02 16:54:40 +00:00
Elliott Hughes
46621f43b0 Merge "Start de-duplicating the regular and wide printf implementations." 2017-11-02 15:44:32 +00:00
Elliott Hughes
9ecd2cc0a2 Test __fpclassify/__isinf/__isnan.
These are obsolete aliases for equally obsolete functions, but apps built
with old versions of the NDK might still be emitting references to them.

Bug: N/A
Test: ran tests
Change-Id: I6eab910e3cd4d322604167799e83b5b7411c04c3
2017-11-01 22:17:26 -07:00
Chih-hung Hsieh
261dbdf1d0 Merge "Use -Werror in bionic/tests" 2017-11-02 02:16:46 +00: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
48228fb572 Merge changes from topic "versioner_cpp"
* changes:
  versioner: compile headers in both C and C++ mode.
  versioner: follow __asm__ labels.
2017-11-01 22:33:10 +00:00
Chih-Hung Hsieh
b1cc5bd276 Use -Werror in bionic/tests
* Should not use -Wno-error

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I92552b0d9860835216500c4f57574cd2928b24f1
2017-11-01 14:13:24 -07:00
Elliott Hughes
0cbbdaa5cf Merge "Add missing ELF constants from the spec." 2017-11-01 15:32:39 +00:00
Elliott Hughes
a8a23f520e Add missing ELF constants from the spec.
Also add links to the relevant documentation.

Bug: N/A
Test: builds
Change-Id: I65b1a1ec0c63e1f07749ab4e4b0cf3905acc1df7
2017-10-31 17:26:48 -07:00
Elliott Hughes
b1ba8cfffb Merge "elf.h: add STN_UNDEF" 2017-11-01 00:23:57 +00:00
Treehugger Robot
07e412419b Merge "More missing _unlocked <stdio.h> functions." 2017-10-31 22:43:34 +00:00
Treehugger Robot
555a6d19c8 Merge "Rename the fortify compile-time diags test" 2017-10-31 22:13:03 +00:00
Treehugger Robot
c905afa1f2 Merge "clang-format the printf/scanf implementation." 2017-10-31 22:11:46 +00:00
Greg Hackmann
8874d88083 elf.h: add STN_UNDEF
ELF uses index STN_UNDEF = 0 for undefined symbols.  glibc and musl
define this constant in elf.h, and it's needed to build the kernel's
vDSO selftest suite.

Test: Overwrite elf.h in standalone NDK toolchain, then
	cd $kernel/tools/testing/selftests/vDSO && \
	make CC="aarch64-linux-android-gcc -pie" vdso_test
Change-Id: I495586e9ca43d2f0d148ded9f4bd61ec8d14d53b
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2017-10-31 13:52:45 -07: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
George Burgess IV
0086fc813e Rename the fortify compile-time diags test
Following up on comments from I40c66ff9e638b306878ada006bc2c98f2346e77a.
My best attempt at a name that conveys "a test that fails to compile in
N different ways with FORTIFY enabled, and is intended to be used with
either FileCheck, or as a cheap way to check that FORTIFY is getting
properly disabled given some set of flags."

Bug: None
Test: mma.
Change-Id: I6d62875bd1cabc5d01b10ae0f03accd5ee5c8c0a
2017-10-31 13:14:56 -07:00
Elliott Hughes
c8f2c520fa clang-format the printf/scanf implementation.
Bug: N/A
Test: builds
Change-Id: I490fdc1d568cba901c123b9efe0b9053b0d83b64
2017-10-31 13:07:51 -07:00
Treehugger Robot
f6dfe57e41 Merge "Remove some always-on #ifdefery." 2017-10-31 18:26:30 +00:00
Treehugger Robot
9fe034b7bb Merge "libc: Disable FORTIFY if we're using clang-tidy." 2017-10-31 17:36:18 +00:00
Elliott Hughes
d9a7de1b77 Remove some always-on #ifdefery.
Bug: N/A
Test: ran tests
Change-Id: I02d3c0a639f48ae9c415fb59f37ade015e6f46a2
2017-10-31 09:55:40 -07:00
George Burgess IV
e5d66eb86a libc: Disable FORTIFY if we're using clang-tidy.
Having FORTIFY enabled for clang-tidy adds no value, and breaks some
heuristics for recognizing standard library functions (see the bug).

This also disables FORTIFY for the static analyzer (which we use
through clang-tidy), because it presumably tries to recognize standard
library functions through similar heuristics.

Bug: 36664104
Test: mma with and without the patch to cdefs. New test breaks without.
Change-Id: I40c66ff9e638b306878ada006bc2c98f2346e77a
2017-10-30 22:30:40 -07:00
Treehugger Robot
8142b5c5b0 Merge "Fork vfprintf.c/vfwprintf.c." 2017-10-31 01:28:21 +00:00
Josh Gao
ab25d0bd10 versioner: compile headers in both C and C++ mode.
Bug: https://github.com/android-ndk/ndk/issues/440
Test: python run_tests.py
Change-Id: Ib572a8fdcc00f6b88a25003a085b16ce9698d692
2017-10-30 12:47:24 -07:00
Josh Gao
38685e1887 versioner: follow __asm__ labels.
Attribute the versioning information on `void foo() __asm("bar")` to
bar, not foo.

The various long double functions in <math.h> run into this.

Bug: https://github.com/android-ndk/ndk/issues/440
Test: python run_tests.py
Test: m
Change-Id: Idd3681ddbd006b4705608449935c9cfacfa3556e
2017-10-30 12:47:24 -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
82e6ad1242 Merge "Fix pthread.pthread_attr_setinheritsched__PTHREAD_INHERIT_SCHED__PTHREAD_EXPLICIT_SCHED for LP32." 2017-10-30 18:34:31 +00:00
Elliott Hughes
7a66066e66 Fix pthread.pthread_attr_setinheritsched__PTHREAD_INHERIT_SCHED__PTHREAD_EXPLICIT_SCHED for LP32.
LP32 continues to ignore failures to set scheduler attributes for
backwards compatibility with pre-Honeycomb bugs :-(

Bug: http://b/68486614
Test: ran tests (32-bit and 64-bit!)
Change-Id: I18a012cdf2f3c5bb63a5367bca2bac2de7f53ae2
2017-10-30 09:26:06 -07:00
Elliott Hughes
e379a20250 Merge "Preserve historical pthread_create scheduler behavior better." 2017-10-28 17:19:06 +00:00
Elliott Hughes
38f01e05ef Preserve historical pthread_create scheduler behavior better.
At the cost of two flag bits for what POSIX thinks should be a boolean
choice, plus somewhat confusing behavior from pthread_attr_getinheritsched
depending on when you call it/what specific scheduler attributes you've
set in the pthread_attr_t, we can emulate the old behavior exactly and
prevent annoying SELinux denial spam caused by calls to sched_setscheduler.

Bug: http://b/68391226
Test: adb logcat on boot contains no sys_nice avc denials
Change-Id: I4f759c2c4fd1d80cceb0912d7da09d35902e2e5e
2017-10-27 15:40:15 -07:00
Treehugger Robot
dfece7a3ee Merge "Mark __BIONIC_WEAK_FOR_NATIVE_BRIDGE symbols" 2017-10-27 17:47:32 +00:00
Treehugger Robot
6bffdad25b Merge "Log dlclose calls and library unloads" 2017-10-27 17:32:13 +00:00
dimitry
c92ce715c5 Log dlclose calls and library unloads
Bug: http://b/29458203
Bug: http://b/68262627
Test: make && run bionic-unit-tests
Test: set debug.ld.all to dlopen and check the logs
Change-Id: I9a5495843a4145f267cc3a4714294d05b1e1fe90
2017-10-27 15:38:15 +02:00
dimitry
fa432524a6 Mark __BIONIC_WEAK_FOR_NATIVE_BRIDGE symbols
To make it easier for Native Bridge implementations
to override these symbols.

Bug: http://b/67993967
Test: make
Change-Id: I4c53e53af494bca365dd2b3305ab0ccc2b23ba44
2017-10-27 10:01:46 +02:00
Treehugger Robot
ae7483db2a Merge "Don't allow LIBC_DEBUG_MALLOC_OPTIONS to cross security boundaries." 2017-10-27 03:28:23 +00:00
Elliott Hughes
343d1c4953 Don't allow LIBC_DEBUG_MALLOC_OPTIONS to cross security boundaries.
Bug: http://b/68003719
Test: LIBC_DEBUG_MALLOC_OPTIONS=isbad1 MALLOC_CONF=isbad2 su 0 /system/bin/sh -c '/system/bin/echo opt=$LIBC_DEBUG_MALLOC_OPTIONS conf=$MALLOC_CONF'
Change-Id: I796cc21b230a96cb0ed87d02ddcb1706a7749a90
2017-10-26 18:25:19 -07:00
Treehugger Robot
8ae3fe2c50 Merge "Add null checks to <dirent.h> functions." 2017-10-27 01:03:32 +00:00
Treehugger Robot
d10d03ebd6 Merge "Add basic printf benchmarks." 2017-10-27 00:52:44 +00:00
Treehugger Robot
39ec1c3dc7 Merge "The main thread should just INHERIT its scheduler attributes." 2017-10-26 23:43:29 +00: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
928059907b Add basic printf benchmarks.
Bug: http://b/67371539
Test: ran benchmarks
Change-Id: I6ad05540079776b2df4cc8d9c02440c61e42037d
2017-10-26 15:43:34 -07:00
Elliott Hughes
374848a16e The main thread should just INHERIT its scheduler attributes.
Explicitly setting SCHED_OTHER/0 was causing SELinux denials:

  02-08 09:58:05.430   661   661 I auditd  : type=1400 audit(0.0:20): avc: denied { sys_nice } for comm="grep" capability=23 scontext=u:r:init-qcom-devstart-sh:s0 tcontext=u:r:init-qcom-devstart-sh:s0 tclass=capability permissive=0
  02-08 09:58:05.430   662   662 I auditd  : type=1400 audit(0.0:21): avc: denied { sys_nice } for comm="sed" capability=23 scontext=u:r:init-qcom-devstart-sh:s0 tcontext=u:r:init-qcom-devstart-sh:s0 tclass=capability permissive=0

Also use public pthread API rather than modifying the main thread's
pthread_attr_t directly.

Bug: http://b/68328561
Test: strace -f -e true
Change-Id: I65b7ab3ce285a2901a6eaacb243000c780883c3a
2017-10-26 12:56:21 -07:00