Commit graph

8336 commits

Author SHA1 Message Date
Dan Albert
f66fa495a8 Add __ANDROID_NDK__ to identify using the NDK.
I've added some things like __ANDROID_MAJOR__ to an ndk-version.h, but
that is only in the NDK itself and so doesn't help the platform. Add
__ANDROID_NDK__ to identify that you're building for the NDK and not
the platform.

Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/407
Change-Id: I2d1f1c28e3764e4e658cf675b290b7a17253ee33
2017-07-26 14:27:43 -07:00
Treehugger Robot
9306889509 Merge "Build crtbegin with clang too." 2017-07-25 21:03:26 +00:00
Treehugger Robot
33f9043f48 Merge "Create global seccomp policy." 2017-07-25 20:18:51 +00:00
Elliott Hughes
b348d5cda8 Build crtbegin with clang too.
If _start_main is static, clang optimizes it out and then generates an
undefined reference from the inline assembler, so let's explicitly tell
the compiler it's used.

Bug: N/A
Test: ran tests
Change-Id: Iba3d9c63abae9a0dc32f236b01783515f0190956
2017-07-25 11:54:33 -07:00
Treehugger Robot
086b1b5a22 Merge "Split our FORTIFY implementation into libc_fortify" 2017-07-25 18:05:42 +00:00
George Burgess IV
6cb0687932 Split our FORTIFY implementation into libc_fortify
As requested in the bug. This also rips __memcpy_chk out of memcpy.S,
which lets us cut down on copypasta (all of the implementations look
identical).

Bug: 12231437
Test: mma on aosp_{arm,arm64,mips,x86,x86_64} internal master;
checkbuild on bullhead internal master; CtsBionicTestCases on bullhead.
No new failures.
Change-Id: I88c39ca166bacde0b692aa3063e743bb046a5d2f
2017-07-24 14:20:16 -07:00
Treehugger Robot
4fce647a5b Merge "Remove the HASLB and FREEUB macros." 2017-07-24 21:05:37 +00:00
Elliott Hughes
bff8da308f Merge "Replace fmemopen." 2017-07-24 20:36:16 +00:00
Elliott Hughes
89ff49942b Merge "Apply recent strto* fix, add new tests." 2017-07-24 20:18:34 +00:00
Elliott Hughes
57ad09278f Merge "Replace killpg." 2017-07-24 20:16:40 +00:00
Treehugger Robot
fd80e39546 Merge "Switch to FreeBSD for wcsstr and wmemcpy." 2017-07-24 19:23:36 +00:00
Elliott Hughes
80e4c1529d Remove the HASLB and FREEUB macros.
Because we hate macros.

Bug: N/A
Test: ran tests
Change-Id: I2c94085ff502ec5ce6d8598ec6b3c10e7a4b5510
2017-07-24 11:58:23 -07:00
Elliott Hughes
3a4c45499e Replace fmemopen.
A new implementation starting from the FreeBSD fmemopen rather than the
OpenBSD one we used to use.

The tests were arrived at by translating each sentence in
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fmemopen.html,
plus http://man7.org/linux/man-pages/man3/fmemopen.3.html for historical
GNU bugs.

Bug: http://b/31304889
Test: ran tests
Change-Id: Id8b168c9ecde638e9cdedbc3b8a0982fc83c7048
2017-07-24 10:48:42 -07:00
Steve Muckle
aa3f96c9c4 Create global seccomp policy.
Enabling seccomp across all processes, rather than just zygote, is
useful for auditing the syscall usage of AOSP. Create a global seccomp
policy that can optionally be enabled by init.

Bug: 37960259
Test: confirm global seccomp by removing finit_module from policy and
      observing modprobe fail, confirm regular seccomp unchanged by
      comparing length of installed bpf
Change-Id: Iac53a42fa26a80b05126f262dd9525f4f66df558
2017-07-21 20:30:21 -07:00
Treehugger Robot
71853ad5c5 Merge "Remove outdated _FORTIFY_SOURCE #undefs" 2017-07-21 21:35:37 +00:00
George Burgess IV
53c4c8abb0 Remove outdated _FORTIFY_SOURCE #undefs
AFAICT, all of these were added prior to the new-style FORTIFY going
in. Because clang saw two definitions of the "same" function, it got
upset. (e.g. 35d937e4eb)

Now that our FORTIFY functions are overloads of their library functions,
these undefs can be removed.

(This is a step toward making FORTIFY a library with -U_FORTIFY_SOURCE
on it, as requested in the bug.)

Bug: 12231437
Test: CtsBionicUnitTests. No new failures.

Change-Id: I844ff77106ee2bea72ae1cd0bb85d146939ecd05
2017-07-21 11:25:52 -07:00
Elliott Hughes
7c5a851656 Use __RENAME_IF_FILE_OFFSET64 where possible.
It's not usable for cases where the off_t and off64_t functions became
available in different API levels, so it's not as big an improvement as
we'd hoped, but it cleans up several headers and should be usable for
any future additions (though recent Linux additions have _only_ supported
off64_t anyway).

Bug: N/A
Test: builds
Change-Id: I18b00f30666079d9d12d5b9c0ed916076d6c3641
2017-07-20 10:00:28 -07:00
Dan Albert
f5605374da Add __RENAME_IF_FILE_OFFSET64.
Convenience macro for __RENAME if __USE_FILE_OFFSET64 mode. Lets us
avoid duplicating all the doxygen comments in frameworks headers.

Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/459
Change-Id: Ica44f22b2f1596e484694006c0926d94d16187b5
2017-07-17 14:05:44 -07:00
Treehugger Robot
dcdd0e3760 Merge "Hide various mbstate implementation details." 2017-07-15 03:12:36 +00:00
Treehugger Robot
65cebf0804 Merge "Allow passing filenames to generate-NOTICE.py." 2017-07-15 01:07:39 +00:00
Elliott Hughes
697f42afdb Hide various mbstate implementation details.
...by inlining them.

Also fix a couple of harmless bugs in passing. I've added tests, but in
both cases I don't think it was actually possible to hit the bad behavior:
we'd hit another test and fail immediately after in an externally
indistinguishable way.

Bug: N/A
Test: readelf
Change-Id: I8466050b0bfe2b7b94c76b383cf10c1d9d28debd
2017-07-14 17:00:05 -07:00
Elliott Hughes
aac7c3affa Allow passing filenames to generate-NOTICE.py.
For the libandroid_support NOTICE file, we need to combine all the files
in that directory, plus the specific files pulled from bionic.

Also cleaned up some of the Python style.

Bug: N/A
Test: used for libandroid_support
Change-Id: If433e3a0f0478f06d99a9b3556e99dde06a7e5e1
2017-07-14 15:41:11 -07:00
Elliott Hughes
5ea0b0667f libm symbol cleanup.
Some of this code is used in the NDK libandroid_support now, as a static
library, so just being HIDDEN in the ELF sense isn't sufficient.

Rename digittoint to __libm_digittoint so we don't trample anyone's toes.

Also remove imprecise_powl and imprecise_tgammal. It turns out (to my
surprise) that we don't even have ld128 implementations of powl and tgammal,
so even LP64 was just using the "fake_long_double.c" hack in effect. Since
that's the case, let's *actually* do that because then we're not polluting
with the internal names in addition to the aliases.

Bug: N/A
Test: readelf
Change-Id: I273cc8fdc7ce53f9b8dfd4ef7796e358fe901837
2017-07-13 17:33:15 -07:00
Dan Albert
3f03579589 Move wchar _l functions out of wchar.cpp.
We don't need these in libandroid_support, but we do need the other
parts of wchar.cpp, and they're not really related.

Test: make checkbuild
Bug: None
Change-Id: I40f3089b034abfd4873e81c0b6216a7cfd977d8d
2017-07-13 10:29:20 -07:00
Elliott Hughes
20f3399956 Switch to FreeBSD for wcsstr and wmemcpy.
Almost all of our w* functions come from FreeBSD already. The one downside is
that we can't take all our w* functions from FreeBSD because FreeBSD handles
locales very differently from us.

Bug: N/A
Test: ran tests
Change-Id: I177b4332499992babd5d5afe5b3f469f8c4345a5
2017-07-13 09:45:00 -07:00
Elliott Hughes
f826a37b95 Apply recent strto* fix, add new tests.
The behavior with "0xy" was wrong: we'd swallow the 'x'.

Bug: N/A
Test: ran tests
Change-Id: I2464d22a2408e99880303876306f18a25c390ad9
2017-07-13 09:35:15 -07:00
Dan Albert
2d585e0070 Merge changes from topic 'locale-android-support'
* changes:
  Add a non-TLS slot implementation of locale.cpp.
  Move non-locale.h APIs out of locale.cpp.
2017-07-13 08:34:57 +00:00
Dan Albert
1a8b7f2d1c Add a non-TLS slot implementation of locale.cpp.
libandroid_support shouldn't be using Bionic's TLS slot. Add a
thread_local based implementation. We can't use the thread_local
implementation in bionic because the linker needs this and pthread
thread-locals (which is how thread_local is implemented) doesn't work
that early.

Test: make checkbuild
Test: adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
Bug: https://github.com/android-ndk/ndk/issues/300
Change-Id: I7dcbf554ade2264d541d722fa3f86df04926e67a
2017-07-12 13:47:42 -07:00
Dan Albert
e2fd01035b Move non-locale.h APIs out of locale.cpp.
libandroid_support only needs the locale.h stuff.

Test: make checkbuild
Bug: None
Change-Id: I0c53fe9d2df4f9ff4b99771727034508bc89cb32
2017-07-12 12:41:47 -07:00
Elliott Hughes
7532b32627 Replace killpg.
Upstream's killpg is diverging further from glibc behavior, so let's just fork.

Bug: N/A
Test: ran tests
Change-Id: I70a3543018bc0a5c0bbf019ac527043b90568fda
2017-07-11 15:00:17 -07:00
Elliott Hughes
b364683ea6 Sync with upstream OpenBSD: trivial stuff.
No active ingredient to any of these changes.

Bug: N/A
Test: builds
Change-Id: Ib1191a5c2826da024245d03dfc57557c8903a6cc
2017-07-11 12:34:19 -07:00
Treehugger Robot
61fcd39e17 Merge "The future passed part of <stdlib.h> by..." 2017-07-11 18:54:24 +00:00
Victor Khimenko
73d17e7720 Merge "Move environ valiable into it's own file" 2017-07-10 22:33:54 +00:00
Elliott Hughes
e76ff925df Merge "Make inline tcsetattr definition match constants." 2017-07-10 20:40:53 +00:00
Treehugger Robot
6aaa227f74 Merge "Undo recent _FILE_OFFSET_BITS=64 changes." 2017-07-10 20:20:53 +00:00
Treehugger Robot
c2828b87ec Merge "Fix ffs on x86 for old API levels." 2017-07-10 20:07:01 +00:00
Elliott Hughes
00fedf5879 Undo recent _FILE_OFFSET_BITS=64 changes.
We had several bugs filed saying "if I set _FILE_OFFSET_BITS=64 when
targeting an API < L, various functions are missing". Instead of
saying "yes, they are", we quietly just modified the header files to
expose the non-64-bit variants. This makes no sense. We can't just say
"oh, yeah, we don't have a version of this function that agrees with
your calling code about how large off_t is, but here's a version that
doesn't: I'm sure it'll be fine".

_FILE_OFFSET_BITS=64 on Android LP32 has always been a game of chance,
but that game should be "are all the functions my code needs available
at compile time?", not "will my code actually work at run time?".

Bug: https://github.com/android-ndk/ndk/issues/449
Bug: https://github.com/android-ndk/ndk/issues/442
Bug: https://github.com/android-ndk/ndk/issues/333
Bug: https://github.com/android-ndk/ndk/issues/332
Bug: https://github.com/android-ndk/ndk/issues/324
Test: builds
Change-Id: Ib095251d3e21e77ed50cc3575388107fecec4ecd
2017-07-10 19:52:18 +00:00
Victor Khimenko
0a0743f864 Move environ valiable into it's own file
Test: build statically the example program below

  char** environ;
  int main() {
  }

Change-Id: I3f01652da1d5063d92ba7cbff7fb09bd0a89325c
2017-07-10 21:44:17 +02:00
Elliott Hughes
4cae5c374e The future passed part of <stdlib.h> by...
Bug: N/A
Test: builds
Change-Id: Ibac3c1abd82838dccd360cb70decb7083401c28e
2017-07-10 11:51:00 -07:00
Elliott Hughes
6c716a155d Merge "Support building binutils out of the box for x86/x86-64." 2017-07-06 22:33:42 +00:00
Elliott Hughes
1de6d0bb8a Merge "Make <sys/ttydefaults.h> more usable." 2017-07-06 22:20:34 +00:00
Elliott Hughes
0ff813fb48 Merge "Update <arpa/*> from FreeBSD." 2017-07-06 22:15:04 +00:00
Elliott Hughes
4ceefe27e7 Merge "Claim to have a POSIX shell and utilities." 2017-07-06 21:22:20 +00:00
Elliott Hughes
10c836fe08 Merge "Conditionally expose splice(2) and sync_file_range(2) constants." 2017-07-06 21:21:20 +00:00
Elliott Hughes
8d307c9a30 Support building binutils out of the box for x86/x86-64.
x86 needs the <sys/user.h> additions, x86-64 the <sys/procfs.h> ones.

Bug: N/A
Test: ndkports x86 and x86_64 binutils-2.28
Change-Id: I2e4738d3f8343d12db0536ca77045e2a0ccc6596
2017-07-06 11:10:01 -07:00
Elliott Hughes
02fdd0570e Make <sys/ttydefaults.h> more usable.
* TTYDEF_OFLAG referred to the BSD OXTABS constant instead of the Linux XTABS,
  so references to it wouldn't compile.

* CEOL was incorrect (compared to `stty -a`).

* ttydefchars wouldn't compile (removed rather than attempt to fix something
  of unclear utility).

Bug: http://b/63145226
Test: new test
Change-Id: I823e5eaab789cafd2eeea03f77ea553346822f74
2017-07-06 10:33:15 -07:00
Elliott Hughes
964564d290 Claim to have a POSIX shell and utilities.
We pretty much do these days. And apparently some GNU tools turn on obsolete
backwards-compatible behaviors otherwise.

Bug: http://b/63145226
Test: builds
Change-Id: I9a8af860768cc2c10548f172d1e8b4fba3e5115b
2017-07-05 16:45:55 -07:00
Elliott Hughes
02a3fe9fc6 Update <arpa/*> from FreeBSD.
We've had <arpa/telnet.h> for years, despite being slightly more useless
than <arpa/ftp.h> and <arpa/tftp.h>. The inetutils package expects these
to be available.

Bug: http://b/63145226
Test: builds
Change-Id: I1e3c7421779e965b3342d681fefb8dc2561b604d
2017-07-05 16:03:59 -07:00
Elliott Hughes
9d2507205e Conditionally expose splice(2) and sync_file_range(2) constants.
As in other places, only expose the constants at API levels where
we're also exposing the functions (to cope with "poor man's configure"
where an author assumes the presence of the #define to imply the
availability of the function).

Bug: http://b/63145226
Test: builds
Change-Id: I524f7288513aa6c35479c550e748a619397929b0
2017-07-05 15:59:58 -07:00
Elliott Hughes
0af3e8febd Fix <dirent.h> d_ino/d_off types.
Bug: http://b/63336806
Test: builds
Change-Id: I781e7c66c41bcb772d49ce7c23aab185ddd5da1e
2017-07-05 12:34:29 -07:00