Commit graph

6741 commits

Author SHA1 Message Date
Dimitry Ivanov
19acb698e8 [MIPS] Add __popcountsi2 to libgcc_compat.c
Also removed outdated genlibgcc_compat.py script
and references to it.

Bug: http://b/27340856
Change-Id: I7eef362364078867c60a27e72abba515f08b6651
2016-02-25 14:28:45 -08:00
Christopher Ferris
0e2a026579 Fix wrong guard values for 64 bit.
I added the code to force alignments of 8 for 32 bit and 16 for 64 bit,
but I missed a couple of tests that failed due to this change. Fix the
failing tests.

Bug: 26739265
Change-Id: Ice9932d1419e59c07483c4c9fcdb84970844f0a6
2016-02-22 19:14:26 -08:00
Christopher Ferris
f499dc91e7 Fix incorrect size of array.
When using sscanf and "%4s", the array passed in must include space for
a nul terminator.

Bug: 26739265
Change-Id: I0140a6100ca370666ae61689087ba41b4914789d
2016-02-19 18:13:29 -08:00
Colin Cross
d75d4bea54 malloc_debug: reread /proc/pid/maps when entry is missing
Reread /proc/pid/maps on demand in case a new library has been loaded.

Change-Id: Iac8109b3e6a07bf02c38300b21eecabf4bcd54df
2016-02-18 16:09:17 -08:00
Colin Cross
2c75991359 Add backtrace_string and export to libmemunreachable
Add backtrace_string to convert a malloc_debug backtrace to a string.
Also move the backtrace functions to libc_malloc_debug_backtrace so that
libmemunreachable can reuse them.

Change-Id: I5ad67001c0b4d184903c762863a8588181d4873b
2016-02-18 16:09:17 -08:00
Colin Cross
2d4721c0c5 Export malloc_backtrace
Change-Id: Ic1adb4dfd86b9ca698443a36263a3df2c91edda3
2016-02-18 16:09:16 -08:00
Colin Cross
869691c6f7 Export malloc_iterate and friends
Export malloc_iterate, malloc_enable, and malloc_disable to be used by
libmemunreachable.

Change-Id: I08a50349af82a95d096b6b4cbac37ababe4b9b06
2016-02-18 15:05:38 -08:00
Christopher Ferris
4327ae07b9 Merge "Fix cfi directives for memmove/strlcpy." 2016-02-18 18:46:28 +00:00
Elliott Hughes
90ea63a862 Merge "Fix scope ids for link-local IPv6 addresses from getifaddrs(3)." 2016-02-18 18:35:00 +00:00
Christopher Ferris
97b6e131fd Fix cfi directives for memmove/strlcpy.
Bug: 27227225
Change-Id: I47ca82daaadb3ec24cefc3c9aa4df7ed1798aced
2016-02-17 19:17:02 -08:00
Christopher Ferris
de84e51f8c Fix cfi directives in small strncmp case.
Bug: 27227225
Change-Id: Id4f88fe288109a82822ad1b2291858c1c85b0ca7
2016-02-17 16:34:02 -08:00
Elliott Hughes
7dac8b8aab Fix scope ids for link-local IPv6 addresses from getifaddrs(3).
Bug: http://b/27219454
Change-Id: I7a166ff5553565f7afdab18dd2c703af4d475ab4
2016-02-17 14:38:09 -08:00
Colin Cross
598cb89790 Merge "malloc_debug: reset TrackData mutex after fork" 2016-02-17 20:38:02 +00:00
Christopher Ferris
249fefbda0 Merge "Fix the default alignment of the allocations." 2016-02-13 01:37:06 +00:00
Christopher Ferris
72df6708c8 Fix the default alignment of the allocations.
In order to enforce this constraint:

The pointer returned if the allocation succeeds shall be suitably
aligned so that it may be assigned to a pointer to any type of object
and then used to access such an object in the space allocated.

Force all allocations on 32 bit systems to have 8 byte alignment,
and all allocations on 64 bit systems to have 16 byte alignment.

Add a test to verify that the allocator returns the correct alignments.

Bug: 26739265
Change-Id: I9af53279617408676b94e4ec6481b3ed7ffafc6a
2016-02-12 17:30:30 -08:00
Colin Cross
7a28a3cf1f malloc_debug: reset TrackData mutex after fork
Add a pthread_atfork handler to malloc_debug to lock the TrackData mutex
during fork and reset it in the child.  Ensures that the TrackData is
consistent when forking from a multi-threaded process, and that the
mutex is in a defined state in the child.

Change-Id: I0dfed30045a28551217ceac227d33b2e18894932
2016-02-12 16:41:14 -08:00
Elliott Hughes
cac2908b08 Fix regerror(..., nullptr, 0).
Found by passing a bad regular expression to the Google benchmark
code (https://github.com/google/benchmark).

Change-Id: I475db71c25706bbf02091b754acabe8254062f3a
2016-02-12 16:00:53 -08:00
Elliott Hughes
01b85d5df3 Set x86 TLS limit to 0xfffff, not PAGE_SIZE.
Not least because we set limit_in_pages to 1. PAGE_SIZE pages was never
anyone's intention.

Change-Id: Ide867f44a2fb20d4d5d0cd67ced468e8665a0193
2016-02-09 22:44:16 -08:00
Chih-hung Hsieh
4c3cf4ad4d Merge "Enable clang for x86_64 after fp128 fix in clang-2577113." 2016-02-09 01:27:01 +00:00
Chih-Hung Hsieh
63fedd76ad Enable clang for x86_64 after fp128 fix in clang-2577113.
Upstream LLVM fix was included in prebuilt clang-2577113.

BUG: 21899249
Change-Id: Ief3f3e28650c0bbf8749a5e5d26f45c39e15ed62
2016-02-08 17:07:33 -08:00
Elliott Hughes
b4931cee76 Update NOTICE files.
Change-Id: I6c4628534c5842c9835ead1bfff6582c5dce38e3
2016-02-08 17:00:12 -08:00
Mike Frysinger
9c212fc436 Merge "define pw_gecos to pw_passwd for LP32 systems" 2016-02-06 19:29:29 +00:00
Mike Frysinger
ca6af7f4a8 define pw_gecos to pw_passwd for LP32 systems
Since we set both fields to NULL all the time, we can alias the two
fields together on LP32 to provide build-time compatibility.

BUG=24918750
TEST=python now builds for Brillo boards

Change-Id: I3394aea80c9a5288669389f71d0e4132f2157e3c
2016-02-06 09:28:44 -05:00
Christopher Ferris
831c8a5249 Merge "Updated to v4.4.1 kernel headers." 2016-02-06 05:24:53 +00:00
Dan Willemsen
138a11c8a1 Merge "Update Android.bp" 2016-02-06 00:43:13 +00:00
Christopher Ferris
05d08e9716 Updated to v4.4.1 kernel headers.
Small modifications needed to allow compilation with the new headers:

- Manually modify bionic/libc/kernel/uapi/asm-mips/asm/siginfo.h to
  remove the uapi from the include.
- PR_XXX defines are now available for mips, so remove the definition
  from linker_mips.cpp.

Bug: 23789423
Change-Id: I6dc8a03b012426d3a937db15cb24d3a50fab5a8c
2016-02-05 16:03:55 -08:00
Dimitry Ivanov
b90837c3d3 Merge "Add check for pthread_self() when looking up a thread" 2016-02-05 04:29:54 +00:00
Dimitry Ivanov
4bc739a54c Add check for pthread_self() when looking up a thread
Check if thread_id is in fact pthread_self before
locking on g_thread_list_lock in __pthread_internal_find.

The main reason for doing this is not performance but to allow
the linker use raise() which was not working because pthread_kill()
couldn't find pthread_self() thread because the global thread
list is initialized in libc.so and the linker's version of this
list is empty.

Bug: http://b/25867917
Change-Id: I18fe620e8cd465b30f0e1ff45fff32958f3c5c00
2016-02-04 16:48:47 -08:00
Dan Willemsen
3e62171516 Update Android.bp
Also reorders some arch-specific sources to match the order in the
Android.mk system.

Change-Id: Ibde46a7cef9840b759be796ce9ac6618d3b06532
2016-02-03 21:48:08 -08:00
Elliott Hughes
0c485dae70 Add in6addr_any and in6addr_loopback symbols.
Change-Id: I3a90fa448b6bd43321672ba74b84a4e9e8a67738
2016-02-03 14:13:52 -08:00
Elliott Hughes
5f26c6bc91 Really add adjtimex(2), and add clock_adjtime(2) too.
Change-Id: I81fde2ec9fdf787bb19a784ad13df92d33a4f852
2016-02-03 13:19:10 -08:00
Elliott Hughes
f226ee59e0 Add fopen64/freopen64/tmpfile64 aliases.
Our fopen/freopen/tmpfile are already always O_LARGEFILE, but let's add
the aliases for _LARGEFILE_SOURCE compatibility.

Bug: http://b/24807045
Change-Id: I5d99b3ef3c9f27ce70f13313f6a92e96c7f21f80
2016-02-03 11:24:28 -08:00
Elliott Hughes
e4fa6e9cc7 Expose ftello64.
Also add the missing test that would have caught this.

Bug: http://b/24807045
Change-Id: I756a4d825595b52396b15898e3f717156fd1ba2f
2016-02-02 22:39:15 -08:00
Xia Yang
6b45d57739 use GNU C89 extern inline semantics for __size_mul_overflow()
__size_mul_overflow generates warning under following compilation envrionment:

-OX -D_FORTIFY_SOURCE=2 (X=1, 2, 3)

For example:

echo '#include <stdio.h>' | \
prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-gcc \
    -I bionic/libc/arch-arm/include \
    -I bionic/libc/include \
    -I bionic/libc/kernel/uapi \
    -I bionic/libc/kernel/common \
    -I bionic/libc/kernel/uapi/asm-arm \
    -I bionic/libm/include \
    -I bionic/libm/include/arm \
    -I bionic/libc/include \
    -Werror \
    -O1 \
    -D_FORTIFY_SOURCE=2 \
    -c \
    -x c \
    -

bionic/libc/include/stdio.h:360:13: error: '__size_mul_overflow' is
static but used in inline function 'fread' which is not static [-Werror]
         if (__size_mul_overflow(size, count, &total)) {
                          ^

C99 - 6.7.4
"An inline definition of a function with external linkage shall not contain
a definition of a modifiable object with static storage duration, and shall
not contain a reference to an identifier with internal linkage."

As standard does not require compiler to determine when it is safe to
reference an internal function in an external inline function, but instead
delegalizes such reference as a whole, gcc throws a warning for such code
under C99 compilation.  Warning produced by libc header is inhereted widely
and strips the option of using -Werror to track code sanity.

Replace static inline specifier with gnu89 extern inline. Latter "is used
only for inlining. In no case is the function compiled on its own", which
is slightly different from former semantically, but should produce the same
result here.

Change-Id: I6a3374498e5499d110e54468cf9d0d67d2debbe2
2016-02-02 17:28:16 -08:00
Christopher Ferris
701bb65511 Remove the unused TrackHeader structure.
Change-Id: I07ae5de717e1fcfbe5dfe552a531db9f630da622
2016-02-02 13:22:40 -08:00
Christopher Ferris
4821db1b3e Merge "Add better free tracking." 2016-02-02 20:40:36 +00:00
Greg Hackmann
5992e5fb6d Merge changes I8ca219fa,Ia92d35b1
* changes:
  socket.h: update AF_* constants
  Add adjtimex
2016-02-02 18:03:35 +00:00
Greg Hackmann
c7ca8f3a63 socket.h: update AF_* constants
Change-Id: I8ca219fa429ca8d8f872ed1db98275cd1a06f00b
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-02-02 00:28:35 +00:00
Christopher Ferris
7993b80f89 Add better free tracking.
Included in this change:

- Change the tag when a pointer is freed so it's easy to detect if
  an already freed pointer is being used.
- Move the free backtrace out of the header. This backtrace is only
  used under only some circumstances, so no need to allocate space
  in all headers for it.
- Add new option free_track_backtrace_num_frames to specify how many
  frames to record when the free occurs. This removes the dependency
  on the backtrace option to get backtraces.

Bug: 26739265
Change-Id: I76f5209507dcf46af67ada162a7cb2bf282116f2
2016-01-29 15:19:22 -08:00
Shinichiro Hamaji
37591462fa Merge "Tell kati about generated dependencies around crt" 2016-01-29 06:37:46 +00:00
Christopher Ferris
50647711eb Merge "Add min/max values for config values." 2016-01-29 02:31:07 +00:00
Greg Hackmann
3f3f6c526b Add adjtimex
Change-Id: Ia92d35b1851e73c9f157a749dba1e98f68309a8d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-01-28 13:41:22 -08:00
Shinichiro Hamaji
3bcf094f21 Tell kati about generated dependencies around crt
This was a regression since kati has been introduced. Without
this, touching libc/arch-common/bionic/__dso_handle.h doesn't
let ninja rebuild object files.

Bug: 26839129
Change-Id: Ie9ef4559c0d1ff0910a4d250ea36938b291d15db
2016-01-28 19:39:50 +09:00
Christopher Ferris
166c8535a5 Add min/max values for config values.
This is to only allow realistic values for some of the options.

Bug: 26739265

Change-Id: I172d5401c27e5d638d80f1c93c678c26c4dae0fc
2016-01-27 18:13:09 -08:00
Dimitry Ivanov
fd799baf81 Merge changes I7dc213e9,I2928d682
* changes:
  Hide '__moddi3' symbol for x86 and mips
  Hide '__isthreaded' for lp64 libc.so
2016-01-27 23:36:18 +00:00
Dimitry Ivanov
ffaa2169d7 Hide '__moddi3' symbol for x86 and mips
Bug: http://b/26805673
Change-Id: I7dc213e9f25510a2a74a30e8c43fd7a64cb3dbdb
2016-01-27 15:12:19 -08:00
Dimitry Ivanov
aa2fd0fece Hide '__isthreaded' for lp64 libc.so
Bug: http://b/26805673
Change-Id: I2928d68287894be9f9ae7ed1858af512d8c80a3b
2016-01-27 14:54:36 -08:00
Christopher Ferris
2fc7f9db3d Remove unused file.
This file should have been deleted with the malloc debug rewrite, but
popped back into existence due to a merge conflict.

Change-Id: I74e53daaf3febf650b20e3da5329558ac84c5bcd
2016-01-27 10:58:36 -08:00
Elliott Hughes
955426ef79 Fix a sign extension bug in stdio.
This also lets us test the EOVERFLOW behavior, which pointed out that the
fgetpos/fsetpos return on failure has always been wrong...

Bug: http://b/24807045
Change-Id: I35273eb07c8c9155af858adb27569983397580b6
2016-01-26 18:25:52 -08:00
Tom Cherry
194860a9e6 Merge "Replace snprintf() with __libc_format_buffer()" 2016-01-27 00:09:52 +00:00