Commit graph

7058 commits

Author SHA1 Message Date
Elliott Hughes
203e13d97d Always include <sys/cdefs.h>.
I made a mistake caught by code review earlier, so let's try to be
safer by default.

This patch also moves all our "forwarding" headers to the guardless
just-include-the-other-thing style that we usually use. (Where we
have a comment explaining where the header comes from, I've kept
that.)

Change-Id: I37342cf5e2563c6a269b2ba61a697069b1c7913b
2016-07-22 17:01:54 -07:00
Josh Gao
8778d64d5c Remove __BIONIC_LEGACY_INLINE.
Don't use the same declaration to declare both static and non-static
functions, to make life easier for versioner.

(Also, remove __BIONIC_LEGACY_INLINE from two functions in termios.h
that weren't actually legacy inlines.)

Bug: http://b/30170081
Change-Id: Ibb73377d77a2b4cee016289b7c46a01452e45fae
2016-07-22 15:52:55 -07:00
Elliott Hughes
420d02c56d Merge "Make it possible to build bionic with -I instead of -isystem." 2016-07-22 21:35:02 +00:00
Elliott Hughes
5470c18361 Make it possible to build bionic with -I instead of -isystem.
Various things:

* work around -Wnullability-completeness.
* use C++ casts in C++ and C casts in C.
* stop using attributes clang doesn't support (such as `warning`).
* remove duplicate definitions of XATTR_CREATE and XATTR_REPLACE.

Change-Id: I07649e46275b28a23ca477deea119fe843999533
2016-07-22 13:12:53 -07:00
Treehugger Robot
4f62c5b311 Merge changes I7718b1ba,I648adc35
* changes:
  Only initialize the global stack protector once.
  Make getpid work before TLS has been initialized.
2016-07-22 19:20:58 +00:00
Elliott Hughes
508d292f8d Only define sa_family_t once.
Change-Id: Icf700910c836d22c8a27ad026ec8af11697edd5a
2016-07-21 16:38:43 -07:00
Elliott Hughes
3e3f4a51b8 Treat "persist.sys.timezone" as being a Java-format timezone.
POSIX and Java disagree about the sign in a timezone string like "GMT+3".
This means that if you set "persist.sys.timezone" to such a string, native
code and Java code disagree about what time it is. Resolve this by
translating to POSIX form for native code.

Bug: http://b/25463955
Change-Id: I7c08c459dd8514348a12ce419edcbfbfe8f6d327
Test: manually tested with setprop and date.
2016-07-20 17:23:54 -07:00
Evgenii Stepanov
a9fbaee593 Merge "Align-up and randomize shared libraries." 2016-07-20 20:31:41 +00:00
Christopher Ferris
fe280773ed Merge "Move/remove android only kernel uapi headers." 2016-07-20 18:03:48 +00:00
Evgenii Stepanov
d13e9a603f Align-up and randomize shared libraries.
This change implements the following property:
  Any 2**N aligned memory region on size 2**N contains no more than one DSO.

The value N can be configured, with 16 or 18 looking like a good choice.
Additionally, DSOs are loaded at random page-aligned address inside these large
regions.

This change has dual purpose:
1. Larger values of N allow a lot more compact CFI shadow implementation.
   See change I14dfea630de468eb5620e7f55f92b1397ba06217.
   For example, CFI shadow for the system_server process has the following size (RSS, KB):
   152 for N = 12, 32 for N = 16, 16 for N = 18.
2. Extra randomization is good for security.

This change does not result in extra RAM usage, because everything is still page-aligned.
It does result in a bit more VM fragmentation because of the gaps between shared libraries.
As it turns out, this fragmentation is barely noticeable because the kernel creates new mapping
at the highest possible address, and we do enough small mappings to almost completely fill the
gaps (ex. in the Zygote the gaps are filled with .ttf file mappings and thread stacks).

I've measured VM fragmentation as the sum of all VM gaps (unmapped regions) that are larger
than 1MB according to /proc/$PID/maps. On aosp_angler-userdebug, the numbers are (in GB):

                |   N = 12  |  N = 18
system_server   |   521.9   |  521.1
zygote64        |   522.1   |  521.3
zygote32        |   2.55    |  2.55
mediaserver     |   4.00    |  4.00

Change-Id: Ia6df840dd409c82837efd1f263be420d9723c84a
2016-07-19 18:18:22 -07:00
Elliott Hughes
f47514dd99 Remove __LIBC_ABI_PUBLIC__.
We have much better control over visibility now, so we don't need to
pollute the headers with cruft.

Bug: http://b/24767418
Change-Id: I349f4c3bc30102477375ad9f80926e560c7c1d8b
2016-07-19 13:56:46 -07:00
Christopher Ferris
d6e8b8ca56 Move/remove android only kernel uapi headers.
Move all of the uapi kernel headers that are only found in the android
kernel, and are still used by the tree into their own directory.

Delete all of these files that are not used.

Also, delete binder.h from the linux directory since it already exists
in the linux/android directory.

Bug: 30072483
Change-Id: I879f16e366f7670b8be3546b0a9cf9567fce6526
2016-07-19 12:43:56 -07:00
Elliott Hughes
d2f725eaed Don't declare SYS_* constants for unavailable __NR_* constants.
Bug: https://code.google.com/p/android/issues/detail?id=215853
Change-Id: Iaaa3ce888deb8d032208bf636b7badaed6a72d30
2016-07-18 12:48:39 -07:00
Dan Albert
32c79c279d Put the legacy stdio fds back for pre-M.
Change-Id: I2e397b04cba2969b9f9a3767b9b2fd12a289fcd2
2016-07-15 12:54:14 -07:00
Dan Albert
77bd6073fb Add an alias for _CTYPE_N.
gnustl is using this. It would be easy to change gnustl to *not* use
it for Android, but we've had this in released NDKs for years now so
we probably need this anyway.

Change-Id: I398a550664bf4ccbd9ea54f53c65428293a599a4
2016-07-15 12:54:05 -07:00
Yabin Cui
a24a2476d0 Merge "Force pthread_cond_timedwait_relative_np using CLOCK_MONOTONIC." 2016-07-15 01:29:28 +00:00
Colin Cross
0393437b53 Merge "Convert malloc_debug from Android.mk to Android.bp" 2016-07-14 19:43:29 +00:00
Colin Cross
baa4899d38 Convert malloc_debug from Android.mk to Android.bp
Change-Id: I60ad376d222a92a29263c2804dcd1bd0d3c383d0
2016-07-14 09:07:56 -07:00
Yabin Cui
fe4a4d8f67 Force pthread_cond_timedwait_relative_np using CLOCK_MONOTONIC.
Previous patch changed pthread_cond_timedwait_relative_np to use
CLOCK_REALTIME, which causes app compatibility problem. So change
it back to CLOCK_MONOTONIC.

Bug: 30106240
Change-Id: I8e04058e92ede098f4f9f8d133f094001921441e
2016-07-13 16:08:48 -07:00
Elliott Hughes
4ce902c30e Support 32-bit ARM vdso.
Linux 4.1 added this.

Bug: http://b/19198045
Change-Id: I28be802ff403a61dd6733a001411b3ff05fef5a5
2016-07-12 13:55:51 -07:00
Colin Cross
7f0e89fadd Rename Android.soong.mk to Android.mk
Soong is always on now, so we don't have to distinguish between
makefiles that should be ignored because Soong is handling them with an
Android.bp file, and makefiles that are still needed with Soong.  All
obsolete Android.mk files have been removed, rename all Android.soong.mk
files to Android.mk.

Change-Id: Ic0494e1800dec13a9f5714559cffe3a5ebe49418
2016-07-11 16:54:20 -07:00
Christopher Ferris
2974eeca4c Update the kernel header documentation.
Change the references to using the android kernel source, to use
the linux stable source code repository.

Change-Id: Ibc6c90fc67c80bef235459bb3af31656f4d403ac
2016-07-08 15:29:51 -07:00
Christopher Ferris
7bd01783a8 Add the record alloc option.
This option adds the ability to record all of the allocation requests
and dump them to a file when a signal is sent to the process.

Included in this change, redo the option processing to add a new
string option.

Bug: 27747898

Change-Id: Ida043362e38b5eb1d459c99db9c2581015dab366
2016-07-08 14:05:17 -07:00
Neil Fuller
516f09c963 Update timezone data to 2016f
The 2016f release of the tz code and data is available. It reflects the
following changes, which were either circulated on the tz mailing list
or are relatively minor technical or administrative changes:

   Changes affecting future time stamps

     The Egyptian government changed its mind on short notice, and
     Africa/Cairo will not introduce DST starting 2016-07-07 after all.
     (Thanks to Mina Samuel.)

     Asia/Novosibirsk switches from +06 to +07 on 2016-07-24 at 02:00.
     (Thanks to Stepan Golosunov.)

   Changes to past and future time stamps

     Asia/Novokuznetsk and Asia/Novosibirsk now use numeric time zone
     abbreviations instead of invented ones.

   Changes affecting past time stamps

     Europe/Minsk's 1992-03-29 spring-forward transition was at 02:00
not 00:00.
     (Thanks to Stepan Golosunov.)

Note: Paul Eggert changed the key used to sign the tzdata bundle and
the new public key cannot be found. The changes to the data since
2016e have been verified visually.

Change-Id: I11b49d9916e67313978fd893acf091e9f99f6d33
Test: Ran CTS/android.core.tests.libcore.package.harmony_java_util
Test: Ran CTS/android.core.tests.libcore.package.harmony_java_text
Test: Ran CTS/android.core.tests.libcore.package.libcore
Bug: 29991153
2016-07-06 18:41:23 +01:00
Elliott Hughes
53420fb21e x86-64's va_list is not a pointer type.
Change-Id: I680feeb641d5411ac481daaae6fa1580e74c5563
2016-06-30 13:47:16 -07:00
Treehugger Robot
1fec29e77b Merge "Revert "Skip Clang's integrated-as for hand-coded assembly"" 2016-06-30 20:33:42 +00:00
Josh Gao
b6453c52ac Only initialize the global stack protector once.
Before, dynamic executables would initialize the global stack protector
twice, once for the linker, and once for the executable. This worked
because the result was the same for both initializations, because it
used getauxval(AT_RANDOM), which won't be the case once arc4random gets
used for it.

Bug: http://b/29622562
Change-Id: I7718b1ba8ee8fac7127ab2360cb1088e510fef5c
Test: ran the stack protector tests on angler (32/64bit, static/dynamic)
2016-06-30 12:58:32 -07:00
Josh Gao
1089afb744 Make getpid work before TLS has been initialized.
Bug: http://b/29622562
Change-Id: I648adc35c04604a7e8bc649c425f07a723e96d3a
Test: code dependent on this change no longer crashes
2016-06-30 12:58:32 -07:00
Elliott Hughes
8ed118db61 Apparently mips and x86's va_list is a pointer type.
And clang won't let you have a function declaration where some arguments
have nullability specifiers and others don't.

Change-Id: I450b0221a3f7f068d5fe971dfbc0ba91d25710e8
2016-06-30 12:46:21 -07:00
Elliott Hughes
9eb3ae122f Remove __nonnull (in favor of _Nonnull).
It's a dangerous pain in the ass, and we're only using it in one place, and
that's a mistake too.

Change-Id: Ida1d1286aaa1343bdee95fa092fcb45ff3258f77
2016-06-30 10:37:03 -07:00
Pirama Arumuga Nainar
b2f5a58866 Revert "Skip Clang's integrated-as for hand-coded assembly"
This reverts commit 8d414dd2b1.

Reverting this since https://android-review.googlesource.com/#/c/244800/ adds -fno-integrated-as globally.

Change-Id: I29f53a385c16f44ead5dc744b0f2dd18a4af1731
2016-06-30 00:16:54 +00:00
Treehugger Robot
1159c196db Merge changes I98c9329f,I40936f7b,I09d20ff1
* changes:
  Defer registration of the arc4random fork-detect handler.
  Make getpid work before the main thread is initialized.
  Take the arc4random lock before forking.
2016-06-29 21:45:35 +00:00
Josh Gao
c80ffece02 Defer registration of the arc4random fork-detect handler.
Previously, arc4random would register a fork-detecting pthread_atfork
handler to not have to call getpid() after a fork. pthread_atfork uses
pthread_mutex_lock, which requires the current thread to be initialized,
preventing the use of arc4random for initializing the global stack guard,
which needs to happen before the main thread has been initialized.

Extract the arc4random fork-detection flag and use the existing
arc4random fork handler to set it.

Bug: http://b/29622562
Change-Id: I98c9329fa0e489c3f78cad52747eaaf2f5226b80
2016-06-28 15:52:59 -07:00
Josh Gao
3e45901439 Make getpid work before the main thread is initialized.
Bug: http://b/29622562
Test: code dependent on this change no longer crashes
Change-Id: I40936f7b35d9e58182aeb2e34e52f54088700825
2016-06-28 15:52:59 -07:00
Josh Gao
250667aaf6 Take the arc4random lock before forking.
Bug: http://b/24675038
Test: stepped through a fork call in gdb
Change-Id: I09d20ff1d103d0c005f2a0cdd9b0a8710ab2392c
2016-06-28 15:52:59 -07:00
Treehugger Robot
9158386758 Merge "Skip Clang's integrated-as for hand-coded assembly" 2016-06-27 22:39:49 +00:00
Pirama Arumuga Nainar
8d414dd2b1 Skip Clang's integrated-as for hand-coded assembly
Bug: http://b/28149048
Bug: http://b/29771478

Clang recently switched to using integrated assembler for Mips.
However, it fails to compile some of the hand-coded assembly files in
bionic.  Disable integrated-as for the time being.

Change-Id: I2eed4391f6827224da74383387bdd9105de5a857
2016-06-27 15:09:05 -07:00
Neil Fuller
325b14a76e Update timezone data to 2016e
Changes affecting future time stamps

    Africa/Cairo observes DST in 2016 from July 7 to the end of October.
    Guess October 27 and 24:00 transitions. (Thanks to Steffen Thorsen.)
    For future years, guess April's last Thursday to October's last
    Thursday except for Ramadan.

  Changes affecting past time stamps

    Locations while uninhabited now use '-00', not 'zzz', as a
    placeholder time zone abbreviation.  This is inspired by Internet
    RFC 3339 and is more consistent with numeric time zone
    abbreviations already used elsewhere.  The change affects several
    arctic and antarctic locations, e.g., America/Cambridge_Bay before
    1920 and Antarctica/Troll before 2005.

    Asia/Baku's 1992-09-27 transition from +04 (DST) to +04 (non-DST) was
    at 03:00, not 23:00 the previous day.  (Thanks to Michael Deckers.)

Bug: 29354265
Test: Ran CTS/android.core.tests.libcore.package.harmony_java_util
Test: Ran CTS/android.core.tests.libcore.package.harmony_java_text
Test: Ran CTS/android.core.tests.libcore.package.libcore
(cherry picked from commit 1b0ee2041c)

Change-Id: I00b892b160769faae6fc8e0df2a58211a43bc1a0
2016-06-23 16:47:20 +01:00
Elliott Hughes
9c8d711aa5 Don't expose all BSD extensions.
Just expose the ones that bionic historically leaked.

Also, many of the M_* constants in <math.h> are actually POSIX.

Change-Id: I6275df84c5866b872b71f1c8ed14e2aada12b793
2016-06-13 14:14:43 -07:00
Josh Gao
95fa26e590 Update symbol versions.
Bug: http://b/28178111
Change-Id: I8e9fb919d96693dd320962775e991caf5aeb0107
2016-06-10 17:50:14 -07:00
Treehugger Robot
2ed5852759 Merge "Rationalize visibility." 2016-06-10 20:41:16 +00:00
Elliott Hughes
213584bb9d Remove obsolete GCC workaround.
bionic is no longer built with GCC.

Change-Id: If01c53d8f6ec7e801bfcdc61775cc24356eb8434
2016-06-10 12:49:04 -07:00
Elliott Hughes
3ba55f8022 Rationalize visibility.
If it's C or POSIX, it's in. If it's BSD or GNU, it's guarded by __USE_BSD
or __USE_GNU.

Bug: https://code.google.com/p/android/issues/detail?id=194631
Change-Id: Ife51a21c2b37b060db56780d29c929805b199cb6
2016-06-09 17:40:19 -07:00
Treehugger Robot
93bae32c27 Merge "Fix the SIZE_T_MAX SSIZE_MAX defines." 2016-06-10 00:35:38 +00:00
Christopher Ferris
47fcffff60 Fix the SIZE_T_MAX SSIZE_MAX defines.
This should not affect the underlying values, just the types used
by the defines.

This fixes any warnings where code does something like:

  printf("%zx", SIZE_T_MAX);

Change-Id: I4beb6d382f30261e4fe133a88fb503984911326d
2016-06-09 16:35:37 -07:00
Elliott Hughes
20788aec00 Add ctermid.
Change-Id: I7c7c815c2725df222932db923632c8b6419741ab
2016-06-09 15:16:32 -07:00
Elliott Hughes
449eff02d2 Add futimes, futimesat, and lutimes.
Spotted these while cleaning up <sys/cdefs.h> --- if we remove __USE_XOPEN2K8,
libchrome decides you "must" have futimes. Adding the missing functions (all
just alternative interfaces to utimensat(2) system call) lets us clean up
without breaking anything.

Change-Id: If44fab08ee3de0e31066d650d128a3c96323529b
2016-06-08 19:51:20 -07:00
Elliott Hughes
cf4c3649ad Merge "Move /vendor/bin down with /vendor/xbin." 2016-06-08 19:53:21 +00:00
Elliott Hughes
409e48add1 More C compatibility.
Add C11 static_assert to <assert.h>. Remove uses of __dead while we're there:
__noreturn already does the same thing on those functions.

Fix <uchar.h> so it works from C.

<stdalign.h> and <stdnoreturn.h> are provided by clang, so there's nothing
for us to do.

Bug: http://b/29178582
Change-Id: Iebc46223868729a26d1a61eb125b76cbcb83a22d
2016-06-08 10:52:15 -07:00
Elliott Hughes
8cabd86c43 Move /vendor/bin down with /vendor/xbin.
The intention is that /vendor/*bin _extends_ rather than overrides.

Change-Id: Iad7db78f653345d79aa6f87abe0a3c2a797f71a3
2016-06-08 10:17:26 -07:00