Commit graph

1453 commits

Author SHA1 Message Date
George Burgess IV
78d878c8df Merge "libc: Move FORTIFY into one file; make style fixups"
am: 4f36cabd8d

Change-Id: I17f125e6100e0af30c083df7a6a7a19a90696dc3
2017-07-26 02:55:44 +00:00
George Burgess IV
d34b0a946c libc: Move FORTIFY into one file; make style fixups
This addresses post-commit feedback from
I88c39ca166bacde0b692aa3063e743bb046a5d2f. With this, our FORTIFY impl
now sits in one file.

Bug: 12231437
Test: mma; no new CtsBionicTestCases failures on bullhead internal
master.
Change-Id: I6f9ff81c3e86cf9d6a0efa650eb5765f1e2fa09c
2017-07-25 17:39:21 -07:00
George Burgess IV
b231a63354 Merge "Split our FORTIFY implementation into libc_fortify"
am: 086b1b5a22

Change-Id: I6e05d09bc00135657a35420fe102a37ccf8c59fc
2017-07-25 18:13:10 +00: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
Elliott Hughes
778b1bd7f6 Merge "Replace killpg."
am: 57ad09278f

Change-Id: Ib1902dbe08b5c797278a4425ae8434dcadd7f06b
2017-07-24 20:22:39 +00:00
Elliott Hughes
57ad09278f Merge "Replace killpg." 2017-07-24 20:16:40 +00:00
George Burgess IV
9a626a86e1 Merge "Remove outdated _FORTIFY_SOURCE #undefs"
am: 71853ad5c5

Change-Id: I4778897a4f7ccb9bb302480696ef765d549733d0
2017-07-21 21:41:51 +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
452c185a0b Merge "Hide various mbstate implementation details."
am: dcdd0e3760

Change-Id: I4f2941939f40c04344f3f9dcfd5debe7780d9275
2017-07-15 03:19:16 +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
Dan Albert
021d7ca543 Merge "Move wchar _l functions out of wchar.cpp."
am: 78c8b306ee

Change-Id: Ia871cf273fde5c70737378b0a7634f2a634d5587
2017-07-13 19:27:42 +00: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
Dan Albert
5f78abdbd8 Merge changes from topic 'locale-android-support'
am: 2d585e0070

Change-Id: I993d7f4c2bd448aa11f0ad30d6db4cba625cb590
2017-07-13 08:37:05 +00: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
Victor Khimenko
ea426865a8 Merge "Move environ valiable into it's own file"
am: 73d17e7720

Change-Id: I9b9533f7e3a70aa5b1e917953b51cc73d7881f32
2017-07-10 22:46:44 +00:00
Victor Khimenko
73d17e7720 Merge "Move environ valiable into it's own file" 2017-07-10 22:33:54 +00:00
Elliott Hughes
0969d4609c Merge "Make inline tcsetattr definition match constants."
am: e76ff925df

Change-Id: Ia6a48c54ac793c510ff2ab5559b920dd84ff02b9
2017-07-10 20:50:34 +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
1449974d27 Make inline tcsetattr definition match constants.
Before this change we have the old NDK inline termios functions with the
modern constants. Unfortunately the old NDK inline functions relied on
hacking the constants. Fix things by sharing the implementation between
the platform and the NDK headers.

Bug: https://github.com/android-ndk/ndk/issues/441
Test: ran tests
Change-Id: I2773634059530bc954167f29c4783413a2294d5a
2017-07-05 12:00:29 -07:00
George Burgess IV
f437c90407 Merge "bionic: fix assorted static analyzer warnings"
am: e202036e03

Change-Id: I88dce02b7f483fb7bc2819406d800d5056c2fc48
2017-06-29 16:34:13 +00:00
George Burgess IV
705910094d bionic: fix assorted static analyzer warnings
Warnings:

bionic/libc/bionic/fts.c:722:5: warning: Null passed to a callee that
requires a non-null 1st parameter

bionic/libc/bionic/sched_cpualloc.c:34:25: warning: Result of 'malloc'
is converted to a pointer of type 'cpu_set_t', which is incompatible
with sizeof operand type 'unsigned long'

bionic/linker/linker_main.cpp:315:7: warning: Access to field 'e_type'
results in a dereference of a null pointer (loaded from variable
'elf_hdr')

bionic/linker/linker_main.cpp:493:66: warning: Access to field 'e_phoff'
results in a dereference of a null pointer (loaded from variable
'elf_hdr')

bionic/linker/linker_main.cpp:90:14: warning: Access to field 'next'
results in a dereference of a null pointer (loaded from variable 'prev')

Bug: None
Test: mma; analyzer warnings are gone. CtsBionicTestCases pass.
Change-Id: I699a60c2c6f64c50b9ea06848a680c98a8abb44a
2017-06-28 15:03:15 -07:00
Stephen Crane
ff5a101adf Merge "Disable stack protector for __libc_preinit" am: 814e3a2b31
am: aca18a3d3a

Change-Id: Id1d3447b37dd37aec7d82c757eb87b2cc1fe2d08
2017-06-22 01:47:27 +00:00
Stephen Crane
f4b1cbda4a Disable stack protector for __libc_preinit
__libc_preinit sets up the stack protector global cookie value, and thus
cannot intialize a stack protector cookie for itself in the function
prologue. LTO compilation can inline functions requiring a stack
protector into __libc_preinit. This patch disables stack protection for
__libc_preinit and forces all potentially inlined functions into a
helper that can have a stack protector.

Test: run bionic-unit-tests

Change-Id: I45911611190f216c91eb6feff722967214c5f99f
2017-06-21 23:53:46 +00:00
Elliott Hughes
02a12a3fd4 Merge "Shave another uninteresting stack frame off aborts." am: e300bf837f
am: 14dddaef5a

Change-Id: I364afd38ee1112cac0bc30232bdb43e4f31c0e17
2017-06-21 00:32:19 +00:00
Elliott Hughes
d7c52625f2 Shave another uninteresting stack frame off aborts.
With this, stack frame 0 is the abort, not tgkill.

arm:

     #00 pc 0001a41c  /system/lib/libc.so (abort+63)

arm64:

     #00 pc 000000000001d75c  /system/lib64/libc.so (abort+120)

Also "include what you use" for <sys/syscall.h>.

Bug: N/A
Test: ran `crasher abort` and `crasher64 abort`
Change-Id: I6517ac67b39b4133e890d52efc115071c812958b
2017-06-20 14:58:16 -07:00
Elliott Hughes
069be703ff Merge "Move a <wchar.h> implementation detail into the implementation." am: 0bd23e4706
am: 1c9325d8f7

Change-Id: I26bb23ea144f72cf3922a390554cf3179b663b51
2017-06-15 21:45:07 +00:00
Elliott Hughes
e2d4663b27 Move a <wchar.h> implementation detail into the implementation.
No other C library expose these, and I couldn't find any callers.

Bug: http://b/62531921
Test: builds
Change-Id: I4a3505bc0897286a4036c48066b98d16665b573a
2017-06-15 10:37:26 -07:00
Elliott Hughes
edc195b403 Merge "Remove volatile from the __errno declaration." am: 7f6bcc4780
am: ccc97f46d3

Change-Id: Ied1902ae342999dc7e344528570793d711946d3c
2017-06-14 01:03:36 +00:00
Treehugger Robot
7f6bcc4780 Merge "Remove volatile from the __errno declaration." 2017-06-14 00:44:33 +00:00
Elliott Hughes
e452cb1ff3 Remove volatile from the __errno declaration.
This breaks code that declares `errno` itself for whatever crazy reason:

  b.c:22:12: error: conflicting types for '__errno'
  extern int errno;
             ^
  /usr/local/google/ndkports/toolchain/bin/../sysroot/usr/include/errno.h:47:20: note: expanded from macro 'errno'
  #define  errno   (*__errno())
                     ^
  /usr/local/google/ndkports/toolchain/bin/../sysroot/usr/include/errno.h:44:15: note: previous declaration is here
  volatile int* __errno(void) __attribute_const__;
                ^

Bug: N/A
Test: built various bits of GNU source
Change-Id: I27c03bf3bde419a001f98f1ea6c267c847f31271
2017-06-13 16:02:07 -07:00
Goran Ferenc
12678c583c Merge "MIPS: 32/64-bit VDSO support" am: 72c8fce6c9 am: d32465b255
am: 85fb061c24

Change-Id: Idc1b6422a1c3213d0c746e135f6c15b49fc5dbc8
2017-06-01 17:59:47 +00:00
Goran Ferenc
996f6decfa MIPS: 32/64-bit VDSO support
File libc/SYSCALLS.TXT is updated to generate bionic's system call wrappers
for clock_gettime() & gettimeofday() that will be called if kernel vdso
implementations fail to execute.
The system call wrappers are generated using a python script gensyscalls.py.

Since all architectures support vdso now, there is no more need for conditional
statements regarding supported architectures in libc/bionic/vdso.cpp &
libc/private/bionic_vdso.h files.

Test: builds
Change-Id: I7213f29c179a7929851499d78a72900638ae861a
Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com>
2017-06-01 08:50:57 -07:00
Mikhail Lappo
620834f8b4 Merge "Va_end should be used with va_start" am: 137a2cf967 am: c29146f9d0
am: 4b0c81661b

Change-Id: Iff6b2d83e33badd2b7fa46e265b5399141120e98
2017-05-20 22:22:26 +00:00
Mikhail Lappo
13ec1cf3da Va_end should be used with va_start
va_start is used and va_end should
be invoked accordingly

Change-Id: I2b0a2af762e22082a351a4d8139aaa48bc791e88
2017-05-20 13:20:41 -07:00
Sandeep Patil
c5f4e9aa59 Merge "properties: do not fail in the absence of vendor properties" into oc-dev
am: f80c5595aa

Change-Id: I5207895e7c85e9179be16caffdbe894bf1f111df
2017-05-18 18:57:08 +00:00
Sandeep Patil
03ed4afec4 properties: do not fail in the absence of vendor properties
/vendor is not mounted in recovery and so the property initialization
must not fail if the vendor property context is not found.

Bug: 38212419
Test: boot into recovery, mount system and run adb shell getprop

Change-Id: I9f7c2fe2b20da86194eff8e7bf94b2352e50bf27
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-05-17 16:26:59 -07:00
Christopher Ferris
a1c0d2fd4c Add support for modifying decay timer.
Add the mallopt function, and only a single option so far.

Bug: 36401135

Test: Built and booted bullhead.
Test: Ran jemalloc unit tests.
Test: Ran bionic unit tests.
Test: Ran a test that allocated and free'd a large piece of memory,
Test: and verified that after changing the parameter, the PSS
Test: sticks around (decay timer set to 1), the PSS is purged (decay
Test: timer set to 0).
Change-Id: I6927929b0c539c1023d34772d9e26bb6a8a45877
2017-05-15 16:59:16 -07:00
Elliott Hughes
dfcb82d92d Clean up __isthreaded.
__isthreaded is annoying for ARC++ and useless for everyone. Just hard-code
the value in ndk_cruft for LP32 and be done with it.

Bug: N/A
Test: builds
Change-Id: I08f11a404bbec55ed57cb1e18b5116163c7d7d13
2017-05-11 15:29:03 -07:00
Josh Gao
d9a741c028 Make raise/abort work with stale cached pid/tid values.
Switch raise to using tgkill with direct syscalls of getpid/gettid,
and switch abort to use raise(SIGABRT).

Bug: http://b/37769298
Test: debuggerd_test
Change-Id: If6f9d17fd8ae6177e742dc9f2f44bd78539431ba
(cherry picked from commit bf2af69fb2)
2017-05-10 16:42:04 -07:00
Elliott Hughes
9ae23720aa Cope with AT_SYSINFO not being set on x86.
Bug: http://b/38034461
Test: ran dexdump under valgrind on x86
Change-Id: I6a54c7ed4fe4e68731e099d9569ab788379820f8
2017-05-09 14:26:30 -07:00
Josh Gao
bf2af69fb2 Make raise/abort work with stale cached pid/tid values.
Switch raise to using tgkill with direct syscalls of getpid/gettid,
and switch abort to use raise(SIGABRT).

Bug: http://b/37769298
Test: debuggerd_test
Change-Id: If6f9d17fd8ae6177e742dc9f2f44bd78539431ba
2017-05-05 14:25:24 -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
7ba2bed0b2 Make unified headers' SIGRTMIN/SIGRTMAX usable before API 21.
Bug: https://github.com/android-ndk/ndk/issues/352
Test: built new NDK test
Change-Id: Iacebe574bbf693701949e038005a40ba6520d592
2017-04-26 14:34:36 -07:00
Treehugger Robot
7b37fa9384 Merge "Move bionic_systrace.cpp over to CachedProperty." 2017-04-18 17:56:07 +00:00
Elliott Hughes
a0e5d06c80 Un-deprecated __system_property_find_nth.
Netflix was using this, and looking the header file, although
__system_property_find_nth has been available since the beginning of time,
__system_property_foreach only appeared in 16. So anyone who wants to run
on pre-JellyBean devices would want to use __system_property_find_nth.

It's pretty much a one-liner in terms of __system_property_foreach anyway,
so it doesn't cost us anything to keep it.

Also restore slightly better tests than we originally removed.

Bug: http://b/36566667
Test: ran tests

(cherry picked from commit 438e01940b)

Change-Id: I639f2142ad4ba049b990b13ccccd255be4b4f479
2017-04-17 17:16:44 -07:00
Treehugger Robot
57e7a0d853 Merge "Un-deprecated __system_property_find_nth." 2017-04-17 23:45:57 +00:00