Commit graph

686 commits

Author SHA1 Message Date
Elliott Hughes
e48b68570d Clean up the pthread_create trampoline.
Bug: 8206355
Bug: 11693195
Change-Id: I35cc024d5b6ebd19d1d2e45610db185addaf45df
2013-11-15 14:57:45 -08:00
Elliott Hughes
062092543f Clean up the 32-bit kernel support, fix LP64 fcntl declaration.
In practice, thanks to all the registers the stubs don't actually change,
but it's confusing to have an incorrect declaration.

I suspect that fcntl remains broken for aarch64; it happens to work for
x86_64 because the first vararg argument gets placed in the right register
anyway, but I have no reason to believe that's true for aarch64.

This patch adds a unit test, though, so we'll be able to tell when we get
as far as running the unit tests.

Change-Id: I58dd0054fe99d7d51d04c22781d8965dff1afbf3
2013-11-06 16:33:39 -08:00
Elliott Hughes
8fbf8deb34 Fix pread/pwrite for LP64.
Unlike on 32-bit systems where off_t is 32-bit, we don't want to
throw away the top 32 bits of an LP64 system's 64-bit off_t.

Change-Id: Ib2e0daeb4fc0b8ab3d1b983d0b371d8f81033b50
2013-11-06 13:10:37 -08:00
Elliott Hughes
66759d6041 Move the pthread debugging flags to the right place.
Change-Id: Ie805bd837d1f72cdf1818e056c0baeb0857e4e84
2013-10-31 14:09:39 -07:00
Elliott Hughes
c3f114037d <pthread.h> fixes and pthread cleanup.
<pthread.h> was missing nonnull attributes, noreturn on pthread_exit,
and had incorrect cv qualifiers for several standard functions.

I've also marked the non-standard stuff (where I count glibc rather
than POSIX as "standard") so we can revisit this cruft for LP64 and
try to ensure we're compatible with glibc.

I've also broken out the pthread_cond* functions into a new file.

I've made the remaining pthread files (plus ptrace) part of the bionic code
and fixed all the warnings.

I've added a few more smoke tests for chunks of untested pthread functionality.

We no longer need the libc_static_common_src_files hack for any of the
pthread implementation because we long since stripped out the rest of
the armv5 support, and this hack was just to ensure that __get_tls in libc.a
went via the kernel if necessary.

This patch also finishes the job of breaking up the pthread.c monolith, and
adds a handful of new tests.

Change-Id: Idc0ae7f5d8aa65989598acd4c01a874fe21582c7
2013-10-31 12:31:16 -07:00
Elliott Hughes
b5b97f20a8 Remove an obsolete ARM gdb hack.
Experiment shows that the claim in the makefile was false: gdb works fine
setting breakpoints in these functions when compiled without special treatment.

Change-Id: Ibdf4dd5a14d171c954b8c2089daaf28e1c310be9
2013-10-30 14:32:42 -07:00
Elliott Hughes
2f287bc728 Factor out some of the makefile cruft.
I really don't want to add yet another copy for aarch64.

Also sort arm, mips, and x86.

Also silence the "TARGET_ARCH_VARIANT" warning for non-ARM; Intel and MIPS
have both complained about it.

Change-Id: I32c592a90c0cf0cdae250d84035b3e4655543781
2013-10-29 16:59:54 -07:00
Elliott Hughes
567a8de3ca Start moving 32-bit cruft somewhere it won't pollute 64-bit.
Change-Id: I03a6a50a5243f29e50fb58a3cf8b5e7198640baa
2013-10-24 17:14:55 -07:00
Elliott Hughes
bf425680e4 Let the compiler worry about implementing ffs(3).
It does at least as good a job as our old hand-written assembly anyway.

Change-Id: If7c4a1ac508bace0b71ee7b67808caa6eabf11d2
2013-10-24 16:29:40 -07:00
Elliott Hughes
11952073af Remove dependencies on obsolete __ARCH_WANT_SYSCALL_DEPRECATED system calls.
(aarch64 kernels don't have these system calls.)

Change-Id: I6f64075aa412f71520f2df71c3d69b647f91c1ca
2013-10-24 15:48:32 -07:00
Elliott Hughes
cac7b9d6ec Remove dependencies on obsolete __ARCH_WANT_SYSCALL_NO_FLAGS syscalls.
(aarch64 kernels only have the newer system calls.)

Also expose the new functionality that's exposed by glibc in our header files.

Change-Id: I45d2d168a03f88723d1f7fbf634701006a4843c5
2013-10-23 09:48:29 -07:00
Elliott Hughes
f8fcfbc85a Move away from the __ARCH_WANT_SYSCALL_NO_AT system calls.
Modern architectures only get the *at(2) system calls. For example,
aarch64 doesn't have open(2), and expects userspace to use openat(2)
instead.

Change-Id: I87b4ed79790cb8a80844f5544ac1a13fda26c7b5
2013-10-22 16:31:01 -07:00
Elliott Hughes
594b1a4af2 Make sure we have a mkfifo symbol.
Bug: https://code.google.com/p/android/issues/detail?id=58888
Change-Id: Ic0a883a5f30beb82cb7be3c4e81b6d693d5fbb4d
2013-10-22 12:03:19 -07:00
Elliott Hughes
c7e9b23317 Fix sigaction(3) for 64-bit.
Also clean up <signal.h> and revert the hacks that were necessary
for 64-bit in linker/debugger.cpp until now.

Change-Id: I3b0554ca8a49ee1c97cda086ce2c1954ebc11892
2013-10-17 11:36:55 -07:00
Elliott Hughes
6b9321b858 am d6e117b6: am 1f29c2f5: Merge "Switch sigpending over to rt_sigpending."
* commit 'd6e117b64bdfbf8d793eb59ea9604b806608ec75':
  Switch sigpending over to rt_sigpending.
2013-10-16 16:09:42 -07:00
Elliott Hughes
40d105ccb3 Switch sigpending over to rt_sigpending.
Change-Id: I7b28984796b5fb343cfbcc47e0afc3a84293d417
2013-10-16 14:07:01 -07:00
Elliott Hughes
afaebc3fef am 87fc78de: am 608c65f6: Merge "Fix sigsuspend to use rt_sigsuspend on all platforms."
* commit '87fc78de6c869d0403ccdd2e756ec1f5d456f3d3':
  Fix sigsuspend to use rt_sigsuspend on all platforms.
2013-10-15 18:20:32 -07:00
Elliott Hughes
1f5af926fa Fix sigsuspend to use rt_sigsuspend on all platforms.
Change-Id: I981c1a66d35480d4457a0a08a1b042dac94daa5b
2013-10-15 18:15:19 -07:00
Elliott Hughes
4681f8244e am 5b3f1d8b: am 22b83da4: Merge "Clean up the sigprocmask/pthread_sigmask implementation."
* commit '5b3f1d8b3a6a1caf059dc376e4967a27ddd57dac':
  Clean up the sigprocmask/pthread_sigmask implementation.
2013-10-15 14:16:02 -07:00
Elliott Hughes
19e62325c2 Clean up the sigprocmask/pthread_sigmask implementation.
Let's have both use rt_sigprocmask, like in glibc. The 64-bit ABIs
can share the same code as the 32-bit ABIs.

Also, let's test the return side of these calls, not just the
setting.

Bug: 11069919
Change-Id: I11da99f85b5b481870943c520d05ec929b15eddb
2013-10-15 11:23:57 -07:00
Nick Kralevich
49bb53c8e2 am 95de0df8: am eda2679e: Merge "FORTIFY_SOURCE: fortify read()"
* commit '95de0df8c2daeefca358010f2d15c3346a5284f1':
  FORTIFY_SOURCE: fortify read()
2013-10-09 21:28:52 -07:00
Elliott Hughes
2d38f0c1c7 am 21d70d5f: am 39385aa7: Merge "Clean up the cpuacct cruft."
* commit '21d70d5fd8ff2823a6879d59c7d5a8d6c3e0ce8b':
  Clean up the cpuacct cruft.
2013-10-09 21:28:51 -07:00
Nick Kralevich
eda2679e30 Merge "FORTIFY_SOURCE: fortify read()" 2013-10-10 04:11:48 +00:00
Nick Kralevich
b036b5ca36 FORTIFY_SOURCE: fortify read()
Change-Id: Ic7de163fe121db13e00560adb257331bc709814d
2013-10-09 20:17:03 -07:00
Elliott Hughes
232163cf70 Clean up the cpuacct cruft.
Change-Id: I6ed63af8dfc2368e211420389fa8af4d5dc0908f
2013-10-09 17:35:36 -07:00
Nick Kralevich
b8771d9fd8 am b35ebe3d: am 848efa9d: Merge "Revert "FORTIFY_SOURCE: fortify read()""
* commit 'b35ebe3d7097899fd4498ebb2b93e48fd836ebcf':
  Revert "FORTIFY_SOURCE: fortify read()"
2013-10-09 16:53:05 -07:00
Nick Kralevich
8d25327639 Revert "FORTIFY_SOURCE: fortify read()"
This change reverts
* fb3f956d07.
* 65c99de2cb

Change-Id: Id5774eeede41130579115cf67a72ee914f2b47d5
2013-10-09 16:46:25 -07:00
Elliott Hughes
1cdc9fe6d5 am 8826ba8a: am bc545e8a: Merge "Fix x86_64 build, clean up intermediate libraries."
* commit '8826ba8ab6922927bdac2466d2903916d5806a06':
  Fix x86_64 build, clean up intermediate libraries.
2013-10-09 16:35:46 -07:00
Nick Kralevich
45e3076cdc am 731ced6b: am c147478c: Merge "FORTIFY_SOURCE: fortify read()"
* commit '731ced6b289629a552b5841561fdcccf08d8c43a':
  FORTIFY_SOURCE: fortify read()
2013-10-09 16:32:25 -07:00
Elliott Hughes
bc545e8a98 Merge "Fix x86_64 build, clean up intermediate libraries." 2013-10-09 23:29:00 +00:00
Nick Kralevich
c147478cb7 Merge "FORTIFY_SOURCE: fortify read()" 2013-10-09 23:23:27 +00:00
Elliott Hughes
eb847bc866 Fix x86_64 build, clean up intermediate libraries.
The x86_64 build was failing because clone.S had a call to __thread_entry which
was being added to a different intermediate .a on the way to making libc.so,
and the linker couldn't guarantee statically that such a relocation would be
possible.

  ld: error: out/target/product/generic_x86_64/obj/STATIC_LIBRARIES/libc_common_intermediates/libc_common.a(clone.o): requires dynamic R_X86_64_PC32 reloc against '__thread_entry' which may overflow at runtime; recompile with -fPIC

This patch addresses that by ensuring that the caller and callee end up in the
same intermediate .a. While I'm here, I've tried to clean up some of the mess
that led to this situation too. In particular, this removes libc/private/ from
the default include path (except for the DNS code), and splits out the DNS
code into its own library (since it's a weird special case of upstream NetBSD
code that's diverged so heavily it's unlikely ever to get back in sync).

There's more cleanup of the DNS situation possible, but this is definitely a
step in the right direction, and it's more than enough to get x86_64 building
cleanly.

Change-Id: I00425a7245b7a2573df16cc38798187d0729e7c4
2013-10-09 16:00:17 -07:00
Elliott Hughes
ac045c32d0 am f83148af: am 0c17099a: Merge "Fix __errno for LP64 and clean up __get_tls."
* commit 'f83148af74704c574ad1bf60082f2f56bcb29706':
  Fix __errno for LP64 and clean up __get_tls.
2013-10-09 13:52:56 -07:00
Nick Kralevich
65c99de2cb FORTIFY_SOURCE: fortify read()
Change-Id: I3d7b4ec86d04efb865117ce7629a2e26917f3331
2013-10-09 13:44:38 -07:00
Elliott Hughes
2a0b873065 Fix __errno for LP64 and clean up __get_tls.
If __get_tls has the right type, a lot of confusing casting can disappear.

It was probably a mistake that __get_tls was exposed as a function for mips
and x86 (but not arm), so let's (a) ensure that the __get_tls function
always matches the macro, (b) that we have the function for arm too, and
(c) that we don't have the function for any 64-bit architecture.

Change-Id: Ie9cb989b66e2006524ad7733eb6e1a65055463be
2013-10-09 13:39:13 -07:00
Elliott Hughes
5ca2f97fb6 am 5596240c: am 65e1c48d: Merge "Don\'t allow int<->pointer conversions."
* commit '5596240cc86920115cffbfe7aac66116d5136a0b':
  Don't allow int<->pointer conversions.
2013-10-08 17:28:25 -07:00
Elliott Hughes
2ec400bfc7 Don't allow int<->pointer conversions.
Normally we don't have -Werror for upstream code, but for those warnings
that probably point to 32-bit assumptions about pointers, we want those
warnings to always be errors.

Change-Id: Ibece9caf09b2f7989ca600ef448d07868669a8fb
2013-10-08 17:04:33 -07:00
Elliott Hughes
4d388c6a32 am 019d0f33: am d262e17e: Merge "Don\'t define the meaningless SOFTFLOAT for x86."
* commit '019d0f33478f10ebd2c885e6a920d3bbed7a8de3':
  Don't define the meaningless SOFTFLOAT for x86.
2013-10-07 10:32:25 -07:00
Elliott Hughes
ee489f6ad2 Don't define the meaningless SOFTFLOAT for x86.
Change-Id: I9f932ad5d9f731a0de18efb881d02cedf9fcbede
2013-10-07 09:53:44 -07:00
Elliott Hughes
83b719a88e am c89f1db0: am 7021e438: Merge "x86_64: Remove lseek64 for x86_64 for a while"
* commit 'c89f1db0a92e4530f1a1686b3629d3d3960f825f':
  x86_64: Remove lseek64 for x86_64 for a while
2013-10-04 12:02:57 -07:00
Elliott Hughes
bc109ea47d am aa3c74d1: am 57d9cebb: Merge "Remove useless x86 fallbacks."
* commit 'aa3c74d175634ab2222ee5a771b01e7434093dbf':
  Remove useless x86 fallbacks.
2013-10-04 11:53:25 -07:00
Pavel Chupin
9373bbb24b x86_64: Remove lseek64 for x86_64 for a while
Just to keep x86_64 libc buildable

Change-Id: I6e69abe2b699bc4ac12e41178ee080df5dac47b7
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-10-04 11:30:27 -07:00
Elliott Hughes
be7b6408b3 am 6d923d49: am 14102932: Merge "Move common arch-* code to arch-common directory"
* commit '6d923d497373c160f6fdddd42f5ed56e7bf0923a':
  Move common arch-* code to arch-common directory
2013-10-04 09:58:23 -07:00
Elliott Hughes
7e841ed688 Remove useless x86 fallbacks.
The NDK ABI requires that you support SSE2, and the build system won't let you
build with ARCH_X86_HAVE_SSE2 set to false. So let's stop pretending this
constant is actually a variable, and let's remove the corresponding dead code.

Also, the USE_SSE2 and USE_SSE3 macros are unused, so let's not bother
setting them.

Change-Id: I40b501d998530d22518ce1c4d14575513a8125bb
2013-10-03 23:30:33 -07:00
Elliott Hughes
141029327c Merge "Move common arch-* code to arch-common directory" 2013-10-03 23:17:58 +00:00
Christopher Ferris
1a086a52d3 am 270c52da: am 1fe477fc: Merge "Add dependencies on included makefiles."
* commit '270c52da0db68c6961eb576b67adc0c41c418763':
  Add dependencies on included makefiles.
2013-10-03 14:57:21 -07:00
Christopher Ferris
d7a632948d Add dependencies on included makefiles.
Bug: 11050594

Merge from internal master.

(cherry-picked from f389284e86)

Change-Id: I2b3e38329a09d26c16870906f9ed1257e2a9dbc8
2013-10-03 14:17:14 -07:00
Pavel Chupin
b49c17c2bf Move common arch-* code to arch-common directory
Will be helpful on adding x86_64

Change-Id: I96cf6fc7912c02f289c75f07ae0079c32d69173f
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-10-03 11:14:33 +04:00
Nick Kralevich
5634373320 am 8598cd68: am f741e1c2: Merge "FORTIFY_SOURCE: Add __FD_* checks"
* commit '8598cd6888366008033286113bd633b44c70b7dd':
  FORTIFY_SOURCE: Add __FD_* checks
2013-10-02 16:30:51 -07:00
Nick Kralevich
90201d5eca FORTIFY_SOURCE: Add __FD_* checks
Add FORTIFY_SOURCE checks for the following macros:

* FD_CLR
* FD_ISSET
* FD_SET

Bug: 11047121
Change-Id: I3c5952136aec9eff3288b91b1318677ff971525c
2013-10-02 16:11:30 -07:00
Stephen Hines
a6d4acc9f9 am 1986d369: am 32c0c6e7: Merge "Use gnu++11 and gnu99 explicitly for C++/C files."
* commit '1986d36957089bfc8a9d8135768f067395e98bd5':
  Use gnu++11 and gnu99 explicitly for C++/C files.
2013-10-02 15:22:56 -07:00
Stephen Hines
762cea46f0 Use gnu++11 and gnu99 explicitly for C++/C files.
Clang and gcc default to different standards, so we should be explicit
about the versions we want to compile for.

Change-Id: I65495a2392dd29f36373b94c616c2506173e6033
2013-10-02 12:37:16 -07:00
Elliott Hughes
14cf72860f am f0470422: am 9461e9fa: Merge "Add missing backslash in MIPS filelist"
* commit 'f04704225b64d2ced8d34036af3336a57d945af5':
  Add missing backslash in MIPS filelist
2013-10-01 19:51:21 -07:00
Chris Dearman
fa4d596abc Add missing backslash in MIPS filelist
Change-Id: I993ea7038cd641ea167d974226e2350e49d41c88
2013-10-01 19:11:26 -07:00
Elliott Hughes
c1cd0f74c9 am f43f8aa8: am b2acd5de: Merge "x86_64: Update Makefiles for x86_64 targets and add symlinks"
* commit 'f43f8aa80a77f59f4ad941d367fe25e30387a72b':
  x86_64: Update Makefiles for x86_64 targets and add symlinks
2013-10-01 15:41:27 -07:00
Pavel Chupin
a567a8e4bd x86_64: Update Makefiles for x86_64 targets and add symlinks
Use basic .c versions of all functions for x86_64 until they are
manually optimized and .s versions released.

Change-Id: I59bba08931e894822db485c8803c2665c226234a
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-10-01 15:36:08 -07:00
Nick Kralevich
9a622f874c am cc362291: am 8427b745: Merge "libc: fortify recvfrom()"
* commit 'cc362291362f8183431eccb19267c8a625f36006':
  libc: fortify recvfrom()
2013-09-27 09:11:00 -07:00
Nick Kralevich
60f4f9a5b9 libc: fortify recvfrom()
Fortify calls to recv() and recvfrom().

We use __bos0 to match glibc's behavior, and because I haven't
tested using __bos.

Change-Id: Iad6ae96551a89af17a9c347b80cdefcf2020c505
2013-09-24 16:45:01 -07:00
Elliott Hughes
a663ebd468 am f8222078: am 43e5badd: Merge "Fix %hhd formats in the printf family."
* commit 'f82220785d20385fa02aa78b02f3fdb98e5aa553':
  Fix %hhd formats in the printf family.
2013-09-23 16:39:13 -07:00
Elliott Hughes
1d13c64d78 Fix %hhd formats in the printf family.
Found by adapting the simple unit tests for libc logging to test
snprintf too. Fix taken from upstream OpenBSD without updating
the rest of stdio.

Change-Id: Ie339a8e9393a36080147aae4d6665118e5d93647
2013-09-23 16:02:39 -07:00
Elliott Hughes
4988ec89db am b9f3d31c: am fc2ceae7: Merge "Remove two -D flags for unused macros."
* commit 'b9f3d31ce40bceec4ecf86e2aaf83f1d8857f346':
  Remove two -D flags for unused macros.
2013-09-23 11:22:05 -07:00
Elliott Hughes
3f33165acd Remove two -D flags for unused macros.
Change-Id: Ia95b0f0e2003cadd875e84437afa1853c8fe2598
2013-09-23 11:12:09 -07:00
Elliott Hughes
bda15698bc am d23ef69a: am 33dd7c11: Merge "Add explicit -m32/-melf_i386 for x86 target"
* commit 'd23ef69ad1d089c10547ac3d42ba199b66260ae3':
  Add explicit -m32/-melf_i386 for x86 target
2013-08-26 10:11:55 -07:00
Pavel Chupin
e85c183424 Add explicit -m32/-melf_i386 for x86 target
Required for x86 build with multilib compiler.

Change-Id: Iac71cdc3461df6fb48cb2a7b713324ca368e6704
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-08-23 16:46:42 +04:00
Elliott Hughes
2d38fced00 am 7003a14b: am 41f08abf: Merge "Apply upstream commit 943a6621866e9d6e654f5cfe1494378c1fb8957a."
* commit '7003a14b536bad08476d2f2005ebcc0490b77b24':
  Apply upstream commit 943a6621866e9d6e654f5cfe1494378c1fb8957a.
2013-08-22 14:32:44 -07:00
Elliott Hughes
713fe6463e Apply upstream commit 943a6621866e9d6e654f5cfe1494378c1fb8957a.
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Aug 22 12:47:51 2013 -0700

    * localtime.c: Fix another integer overflow bug in mktime.

    (time2sub): Avoid undefined behavior on time_t overflow.
    Reported by Elliott Hughes in
    <http://mm.icann.org/pipermail/tz/2013-August/019580.html>.

Bug: 10310929
Change-Id: I3bf26f1f91371552e0a3828457d27e22af55acb2
2013-08-22 14:18:04 -07:00
Elliott Hughes
6b5eb3134a am e5ac43e1: am c44205cf: Merge "Work around tzcode\'s reliance on signed overflow."
* commit 'e5ac43e19afe270c2a70e4fb5d02b4cf056d50d7':
  Work around tzcode's reliance on signed overflow.
2013-08-22 12:27:52 -07:00
Elliott Hughes
7843d44a59 Work around tzcode's reliance on signed overflow.
I've mailed the tz list about this, and will switch to whatever upstream
fix comes along as soon as it's available.

Bug: 10310929
Change-Id: I36bf3fcf11f5ac9b88137597bac3487a7bb81b0f
2013-08-22 12:21:18 -07:00
Christopher Ferris
59a13c122e Optimize __memset_chk, __memcpy_chk. DO NOT MERGE.
This change creates assembler versions of __memcpy_chk/__memset_chk
that is implemented in the memcpy/memset assembler code. This change
avoids an extra call to memcpy/memset, instead allowing a simple fall
through to occur from the chk code into the body of the real
implementation.

Testing:

- Ran the libc_test on __memcpy_chk/__memset_chk on all nexus devices.
- Wrote a small test executable that has three calls to __memcpy_chk and
  three calls to __memset_chk. First call dest_len is length + 1. Second
  call dest_len is length. Third call dest_len is length - 1.
  Verified that the first two calls pass, and the third fails. Examined
  the logcat output on all nexus devices to verify that the fortify
  error message was sent properly.
- I benchmarked the new __memcpy_chk and __memset_chk on all systems. For
  __memcpy_chk and large copies, the savings is relatively small (about 1%).
  For small copies, the savings is large on cortex-a15/krait devices
  (between 5% to 30%).
  For cortex-a9 and small copies, the speed up is present, but relatively
  small (about 3% to 5%).
  For __memset_chk and large copies, the savings is also small (about 1%).
  However, all processors show larger speed-ups on small copies (about 30% to
  100%).

Bug: 9293744

Merge from internal master.

(cherry-picked from 7c860db074)

Change-Id: I916ad305e4001269460ca6ebd38aaa0be8ac7f52
2013-08-14 18:14:43 -07:00
Elliott Hughes
c1772397f9 am ff8dcd4a: am c933493a: Merge "Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols."
* commit 'ff8dcd4a1056257b454da71e1ea1371bb73d3a79':
  Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols.
2013-08-12 14:28:52 -07:00
Elliott Hughes
ff8dcd4a10 am c933493a: Merge "Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols."
* commit 'c933493ac28c40558f369d175da738ba601d8499':
  Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols.
2013-08-12 13:25:48 -07:00
Elliott Hughes
aec2ffbc5a Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols.
Change-Id: I94c411c22634e43184445c82e7388e51fc46a8cc
2013-08-12 12:07:05 -07:00
Elliott Hughes
840a114eb1 Add futimens.
(cherry picked from commit d0be7c8f9a)

Bug: 10239370
Change-Id: I0087e85a94d83b6ce68ec6a0768c44cbe4bd0132
2013-08-08 17:52:06 -07:00
Elliott Hughes
dce94165a5 am ee48fed5: Merge "Add futimens."
* commit 'ee48fed51894f3db324e957058ed2ddcf23dddc7':
  Add futimens.
2013-08-08 17:41:15 -07:00
Elliott Hughes
d0be7c8f9a Add futimens.
Bug: 10239370
Change-Id: I518340084103dc339ef8a065d4837d6258a1381d
2013-08-08 17:13:33 -07:00
Christopher Ferris
4e24dcc8d8 Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE
Create one version of strcat/strcpy/strlen for cortex-a15/krait and another
version for cortex-a9.

Tested with the libc_test strcat/strcpy/strlen tests.
Including new tests that verify that the src for strcat/strcpy do not
overread across page boundaries.

NOTE: The handling of unaligned strcpy (same code in strcat) could probably
be optimized further such that the src is read 64 bits at a time instead of
the partial reads occurring now.

strlen improves slightly since it was recently optimized.

Performance improvements for strcpy and strcat (using an empty dest string):

cortex-a9
- Small copies vary from about 5% to 20% as the size gets above 10 bytes.
- Copies >= 1024, about a 60% improvement.
- Unaligned copies, from about 40% improvement.

cortex-a15
- Most small copies exhibit a 100% improvement, a few copies only
  improve by 20%.
- Copies >= 1024, about 150% improvement.
- Unaligned copies, about 100% improvement.

krait
- Most small copies vary widely, but on average 20% improvement, then
  the performance gets better, hitting about a 100% improvement when
  copies 64 bytes of data.
- Copies >= 1024, about 100% improvement.
- When coping MBs of data, about 50% improvement.
- Unaligned copies, about 90% improvement.

As strcat destination strings get larger in size:

cortex-a9
- about 40% improvement for small dst strings (>= 32).
- about 250% improvement for dst strings >= 1024.

cortex-a15
- about 200% improvement for small dst strings (>=32).
- about 250% improvement for dst strings >= 1024.

krait
- about 25% improvement for small dst strings (>=32).
- about 100% improvement for dst strings >=1024.

Merge from internal master.

(cherry-picked from d119b7b6f4)

Change-Id: I296463b251ef9fab004ee4dded2793feca5b547a
2013-08-08 11:13:46 -07:00
Colin Cross
6771b9cef6 bionic: add function to name memory
Only works on some kernels, and only on page-aligned regions of
anonymous memory.  It will show up in /proc/pid/maps as
[anon:<name>] and in /proc/pid/smaps as Name: <name>

Change-Id: If31667cf45ff41cc2a79a140ff68707526def80e
2013-08-07 15:41:30 -07:00
Christopher Ferris
7c860db074 Optimize __memset_chk, __memcpy_chk.
This change creates assembler versions of __memcpy_chk/__memset_chk
that is implemented in the memcpy/memset assembler code. This change
avoids an extra call to memcpy/memset, instead allowing a simple fall
through to occur from the chk code into the body of the real
implementation.

Testing:

- Ran the libc_test on __memcpy_chk/__memset_chk on all nexus devices.
- Wrote a small test executable that has three calls to __memcpy_chk and
  three calls to __memset_chk. First call dest_len is length + 1. Second
  call dest_len is length. Third call dest_len is length - 1.
  Verified that the first two calls pass, and the third fails. Examined
  the logcat output on all nexus devices to verify that the fortify
  error message was sent properly.
- I benchmarked the new __memcpy_chk and __memset_chk on all systems. For
  __memcpy_chk and large copies, the savings is relatively small (about 1%).
  For small copies, the savings is large on cortex-a15/krait devices
  (between 5% to 30%).
  For cortex-a9 and small copies, the speed up is present, but relatively
  small (about 3% to 5%).
  For __memset_chk and large copies, the savings is also small (about 1%).
  However, all processors show larger speed-ups on small copies (about 30% to
  100%).

Bug: 9293744

Change-Id: I8926d59fe2673e36e8a27629e02a7b7059ebbc98
2013-08-06 15:38:29 -07:00
Christopher Ferris
d119b7b6f4 Optimize strcat/strcpy, small tweaks to strlen.
Create one version of strcat/strcpy/strlen for cortex-a15/krait and another
version for cortex-a9.

Tested with the libc_test strcat/strcpy/strlen tests.
Including new tests that verify that the src for strcat/strcpy do not
overread across page boundaries.

NOTE: The handling of unaligned strcpy (same code in strcat) could probably
be optimized further such that the src is read 64 bits at a time instead of
the partial reads occurring now.

strlen improves slightly since it was recently optimized.

Performance improvements for strcpy and strcat (using an empty dest string):

cortex-a9
- Small copies vary from about 5% to 20% as the size gets above 10 bytes.
- Copies >= 1024, about a 60% improvement.
- Unaligned copies, from about 40% improvement.

cortex-a15
- Most small copies exhibit a 100% improvement, a few copies only
  improve by 20%.
- Copies >= 1024, about 150% improvement.
- Unaligned copies, about 100% improvement.

krait
- Most small copies vary widely, but on average 20% improvement, then
  the performance gets better, hitting about a 100% improvement when
  copies 64 bytes of data.
- Copies >= 1024, about 100% improvement.
- When coping MBs of data, about 50% improvement.
- Unaligned copies, about 90% improvement.

As strcat destination strings get larger in size:

cortex-a9
- about 40% improvement for small dst strings (>= 32).
- about 250% improvement for dst strings >= 1024.

cortex-a15
- about 200% improvement for small dst strings (>=32).
- about 250% improvement for dst strings >= 1024.

krait
- about 25% improvement for small dst strings (>=32).
- about 100% improvement for dst strings >=1024.

Change-Id: Ifd091ebdbce70fe35a7c5d8f71d5914255f3af35
2013-08-02 10:31:51 -07:00
Elliott Hughes
178c418573 am e8bd8c2e: Merge "Upgrade mktemp.c to the current upstream version."
* commit 'e8bd8c2ed9c71c73682f29020456934c55f260e3':
  Upgrade mktemp.c to the current upstream version.
2013-07-19 16:37:52 -07:00
Elliott Hughes
284f788032 Upgrade mktemp.c to the current upstream version.
Yet another archaic relic containing bugs that had been fixed years before the
Android project even started...

Bug: 9935113
Change-Id: I3c9d019a216efd609ee568cf8c70bc360f357403
2013-07-19 15:20:31 -07:00
Elliott Hughes
81b4698059 am f8a66bb3: Merge "Remove some non-unused makefile generality."
* commit 'f8a66bb31204b42f830c1865a795b5f3eb1e0147':
  Remove some non-unused makefile generality.
2013-07-17 17:41:43 -07:00
Elliott Hughes
4c6b925bac Remove some non-unused makefile generality.
MIPS uses .c files like ARM and x86 now.

Change-Id: Ie580647e385121c380316c443ec199dabf657ff8
2013-07-17 17:38:45 -07:00
Elliott Hughes
b6b2375df8 am 8fa9081f: Merge "[MIPS] Rewrite MIPS crtbegin* as C files."
* commit '8fa9081f48c4861f83737d59bf2c2c8f21c7da3f':
  [MIPS] Rewrite MIPS crtbegin* as C files.
2013-07-17 17:36:26 -07:00
Elliott Hughes
8fa9081f48 Merge "[MIPS] Rewrite MIPS crtbegin* as C files." 2013-07-18 00:34:22 +00:00
Pete Delaney
368860124c [MIPS] Rewrite MIPS crtbegin* as C files.
This updates the MIPS arch to be much more in
sync with the commit Nick Kralevich made last
June; see 9d40326830.

    Rewrite
     crtbegin.S        -> crtbegin.c
     crtbegin_so.S     -> crtbegin_so.c
     __dso_handle.S    -> __dso_handle.c
     __dso_handle_so.S -> __dso_handle_so.c
     atexit.S          -> atexit.c

Previously __do_global_dtors_aux was in the tasks
__FINI_ARRAY__ linked with crtbegin.S and it now being
removed as there is no need to call a destructor just
before terminating a process.

Shared libraries, on the other hand, are linked with
crtbegin_so.c and have a hidden destructor declared
to allow the bionic linker to call __on_dlclose().

Change-Id: Ieb4da5199b54573de05743990e309db381a11cb8
Signed-off-by: Pete Delaney  <piet.delaney@imgtec.com>
Signed-off-by: Chao-Ying Fu  <chao-ying.fu@imgtec.com>
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
2013-07-17 14:23:29 -07:00
Elliott Hughes
e35d6c28df am 40e7a878: Merge "Prevent the madvise(MADV_MERGEABLE) mmap hack from affecting errno."
* commit '40e7a87864fee75f7af2caf8e1972d0d764135cd':
  Prevent the madvise(MADV_MERGEABLE) mmap hack from affecting errno.
2013-07-17 13:22:39 -07:00
Elliott Hughes
107cdd406b Prevent the madvise(MADV_MERGEABLE) mmap hack from affecting errno.
Bug: 9889616
Change-Id: I4a7323e0ae5aeb5cbe0da1b2bc7501d83b3a2aa4
2013-07-17 13:12:26 -07:00
Elliott Hughes
f384be3b5c am 59ed029b: Merge "Upgrade to tzcode2013d."
* commit '59ed029b286a1564f635377296e4f088e0fd2afa':
  Upgrade to tzcode2013d.
2013-07-15 10:11:04 -07:00
Elliott Hughes
ce4783ce76 Upgrade to tzcode2013d.
Well, kinda... localtime.c still contains a bunch of Android-specific
hacks, as does strftime.c. But the other files are now exactly the same
as upstream.

This catches up with several years of bug fixes, and fixes most of the
compiler warnings that were in this code. (Just two remain.)

Bug: 1744909
Change-Id: I2ddfecb6fd408c847397c17afb0fff859e27feef
2013-07-12 17:52:44 -07:00
Elliott Hughes
731f7c2d0e am 9d476716: Merge "Add <sys/statvfs.h>."
* commit '9d476716c2bd7bc5a018a71e121257c35e965058':
  Add <sys/statvfs.h>.
2013-07-09 13:44:57 -07:00
Elliott Hughes
06040fd75c Add <sys/statvfs.h>.
Bug: 2512019
Change-Id: I6e7fd3fa281977cc4bc270481a95416b5b2dc351
2013-07-09 13:25:03 -07:00
Colin Cross
146d79c22a am fbec57d4: Merge changes Ib496e818,I074204e9
* commit 'fbec57d46c42460b2381484d1610ff21922d162e':
  bionic: add compatibility mode for properties
  bionic: use the size of the file to determine property area size
2013-06-25 17:08:48 -07:00
Colin Cross
5e9a086145 bionic: add compatibility mode for properties
Allow a new bionic to work with an old init property area by supporting
the old format.

(cherry picked from commit ad76c85b9c)

Change-Id: Ib496e818a62a5834d40c71eb4745783d998be893
2013-06-25 16:52:40 -07:00
Elliott Hughes
db6dd600d2 am b116bf76: Merge "Switch to current upstream getopt_long."
* commit 'b116bf76286178a7d552c4d0a72b79212c8c93d1':
  Switch to current upstream getopt_long.
2013-06-25 15:58:53 -07:00
Elliott Hughes
d278b828fe Switch to current upstream getopt_long.
Change-Id: I4c646dcb8be9e88dd54d069a03bbc5fbfd92de03
2013-06-25 14:56:17 -07:00
Elliott Hughes
5f4d2df2fc am 55189a0f: Merge "Switch to current upstream stdio makebuf.c and setvbuf.c."
* commit '55189a0fbd26cfd84939d9d3a42a1800a63bd2c5':
  Switch to current upstream stdio makebuf.c and setvbuf.c.
2013-06-12 15:58:41 -07:00
Elliott Hughes
677ee56477 Switch to current upstream stdio makebuf.c and setvbuf.c.
Change-Id: I4761b5e94459815520f01062eef39abf62af621f
2013-06-12 15:24:15 -07:00
Elliott Hughes
3da47942d3 am 944ea1a3: Merge "Clean up abort."
* commit '944ea1a32018c44d6cb55c9454e670b0e152da6d':
  Clean up abort.
2013-06-12 14:58:32 -07:00
Elliott Hughes
61e699a133 Clean up abort.
* A dlmalloc usage error shouldn't call abort(3) because we want to
  cause a SIGSEGV by writing the address dlmalloc didn't like to an
  address the kernel won't like, so that debuggerd will dump the
  memory around the address that upset dlmalloc.

* Switch to the simpler FreeBSD/NetBSD style of registering stdio
  cleanup. Hopefully this will let us simplify more of the stdio
  implementation.

* Clear the stdio cleanup handler before we abort because of a dlmalloc
  corruption error. This fixes the reported bug, where we'd hang inside
  dlmalloc because the stdio cleanup reentered dlmalloc.

Bug: 9301265
Change-Id: Ief31b389455d6876e5a68f0f5429567d37277dbc
2013-06-12 14:14:53 -07:00
Elliott Hughes
6bcf71c9ac am 2fbc9dda: Merge "bionic/x86: Optimization for string routines"
* commit '2fbc9dda345486005569be4ec586c6aae9d51650':
  bionic/x86: Optimization for string routines
2013-06-07 17:47:33 -07:00
Liubov Dmitrieva
0a490665a3 bionic/x86: Optimization for string routines
Optimized strcpy, strcat,
strncpy, strncat, strlcpy, strlcat,
memchr, memrchr, strchr, strrchr, index,
strnlen, strlen, wcslen, wmemcmp, wcscmp,
wcschr, wcsrchr, wcscpy, wcscat

Change-Id: I82b29132edf9a2e144e0bb3ee4ff5217df8d2a6d
Signed-off-by: Liubov Dmitrieva <liubov.dmitrieva@intel.com>
2013-05-31 13:37:03 +04:00
Nick Kralevich
4f614a7036 am e4ac8feb: Merge "libc: cleanup strchr"
* commit 'e4ac8feb58ed1f963db9a1f32fa74a06a1f594f2':
  libc: cleanup strchr
2013-05-02 14:25:42 -07:00
Nick Kralevich
4f40e511b0 libc: cleanup strchr
Move strchr to a .cpp file, and change to bionic directory.

Change-Id: I64ade7df326c0a9a714aca4caf5647b6833b1c97
2013-05-02 13:58:03 -07:00
Elliott Hughes
cf4a53020d am b3c8c4d8: Merge "Switch to current FreeBSD qsort."
* commit 'b3c8c4d8654894cdc72d32bde84a520ccda4d8f3':
  Switch to current FreeBSD qsort.
2013-04-12 12:30:22 -07:00
Elliott Hughes
0b25f633a2 Switch to current FreeBSD qsort.
Change-Id: Ic46cd0b663dc5fa78c99dd38db0bfe849a25e789
2013-04-11 18:08:34 -07:00
Elliott Hughes
5fe62e50f6 am ed36d95f: Merge "Start moving to current FreeBSD stdio."
* commit 'ed36d95fac5881f78a601e2932f51edfd27c6ba6':
  Start moving to current FreeBSD stdio.
2013-04-11 14:24:37 -07:00
Elliott Hughes
6b05c8e280 Start moving to current FreeBSD stdio.
This only touches the easy stuff.

Change-Id: Iecee57f1681dba5c56bff59f0e9a89811a71f0ca
2013-04-11 13:55:01 -07:00
Elliott Hughes
76db50ddc9 am b632857a: Merge "Add missing include and function prototype for sched_getaffinity."
* commit 'b632857a50a1fd2b759316d07ace6c36f6f418cf':
  Add missing include and function prototype for sched_getaffinity.
2013-04-10 17:56:22 -07:00
Kito Cheng
4ca685e36e Add missing include and function prototype for sched_getaffinity.
Change-Id: I649633c8d074def5d05bd0c8b92fb680d9d11d51
2013-04-10 17:44:29 -07:00
Kito Cheng
9b84824dfd Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a
- eventfd.cpp and eventfd.s will output to the same file when building libc.a
   out/target/product/*/obj/STATIC_LIBRARIES/libc_intermediates/WHOLE/libc_common_objs/eventfd.o
 - And then `eventfd` will undefined when statically linked to libc.

Also add a unit test.

(cherry-pick of 8baa929d5d3bcf63381cf78ba76168c80c303f5e.)

Change-Id: Icd0eb0f4ce0511fb9ec00a504d491afd47d744d3
2013-04-03 11:14:20 -07:00
Kito Cheng
8baa929d5d Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a
- eventfd.cpp and eventfd.s will output to the same file when building libc.a
   out/target/product/*/obj/STATIC_LIBRARIES/libc_intermediates/WHOLE/libc_common_objs/eventfd.o
 - And then `eventfd` will undefined when statically linked to libc.

Also add a unit test.

Change-Id: Ib310ade3256712ca617a90539e8eb07459c98505
2013-04-03 11:10:37 -07:00
Elliott Hughes
b826ebf41e am 85598626: am 34895c1b: Merge "Replace unnecessary ARM uses of <sys/linux-syscalls.h> with <asm/unistd.h>."
* commit '85598626f4ca7914d996371ce0471ab154aa7585':
  Replace unnecessary ARM uses of <sys/linux-syscalls.h> with <asm/unistd.h>.
2013-03-22 11:11:34 -07:00
Elliott Hughes
8794ece296 Replace unnecessary ARM uses of <sys/linux-syscalls.h> with <asm/unistd.h>.
For some reason, socketcalls.c was only being compiled for ARM, where
it makes no sense. For x86 we generate stubs for the socket functions
that use __NR_socketcall directly.

Change-Id: I84181e6183fae2314ae3ed862276eba82ad21e8e
2013-03-21 23:07:11 -07:00
Elliott Hughes
c9edc07977 am 39e2a408: am 6eb978c9: Merge "Expose wait4 as wait4 rather than __wait4."
* commit '39e2a408a64bd24fb0fe7f5eb444b55af1160480':
  Expose wait4 as wait4 rather than __wait4.
2013-03-21 16:19:29 -07:00
Elliott Hughes
17a8b0db63 Expose wait4 as wait4 rather than __wait4.
This helps strace(1) compile with one fewer hack.

Change-Id: I5296d0cfec5546709cda990abd705ad33d7c4626
2013-03-21 16:14:06 -07:00
Elliott Hughes
12ea800566 am 5f829205: am c1416647: Merge "Clean up internal libc logging."
* commit '5f8292050fc07f4bf9e70f37a807ad028e3cfc87':
  Clean up internal libc logging.
2013-03-15 16:36:37 -07:00
Elliott Hughes
8f2a5a0b40 Clean up internal libc logging.
We only need one logging API, and I prefer the one that does no
allocation and is thus safe to use in any context.

Also use O_CLOEXEC when opening the /dev/log files.

Move everything logging-related into one header file.

Change-Id: Ic1e3ea8e9b910dc29df351bff6c0aa4db26fbb58
2013-03-15 16:12:58 -07:00
Christopher Ferris
306a353825 Remove unused arm defines.
The defines HAVE_32_BYTE_CACHE_LINES and ARCH_ARM_USE_NON_NEON_MEMCPY
are not used by any code. The previous memcpy code that used these
has been split into different architecture versions to avoid the need
for them.

Bug: 8005082

Merge from internal master.

(cherry-picked from commit 6e1a5cf31b)

Change-Id: Ib18fc3f4131b21cdbd19b9dde7697ac25d066fcf
2013-03-14 15:32:18 -07:00
Christopher Ferris
04954a43b3 Break bionic implementations into arch versions.
Move arch specific code for arm, mips, x86 into separate
makefiles.
In addition, add different arm cpu versions of memcpy/memset.

Bug: 8005082

Merge from internal master (acdde8c1cf).

Change-Id: I04f3d0715104fab618e1abf7cf8f7eec9bec79df
2013-03-12 14:06:08 -07:00
Elliott Hughes
0a2ee4750a am ad7c275e: am c9f80814: Merge "Upgrade to current NetBSD popen/pclose."
* commit 'ad7c275e45088e1f13656b97dabbe911fff83664':
  Upgrade to current NetBSD popen/pclose.
2013-03-07 01:04:52 +00:00
Elliott Hughes
6b3f49a537 Upgrade to current NetBSD popen/pclose.
This gets us back to using vfork now our ARM vfork assembler stub is
fixed, and adds the missing thread safety for the 'pidlist'.

Bug: 5335385
Change-Id: Ib08bfa65b2cb9fa695717aae629ea14816bf988d
2013-03-06 16:20:55 -08:00
Elliott Hughes
9c0c056bed am 6b1aa1b1: am db794197: Merge "Fix debug malloc."
* commit '6b1aa1b16bc2cf8ba17e33fca4ffc399368b356c':
  Fix debug malloc.
2013-03-06 23:24:59 +00:00
Elliott Hughes
642331b5dd Fix debug malloc.
This was broken by the change to use AT_RANDOM for the stack guards.

Bug: 7959813
Bug: 8330764
Change-Id: I791900092b72a9a900f16585237fa7ad82aaed9f
2013-03-06 15:03:53 -08:00
Elliott Hughes
c96ad9bcd2 am 7b69ac53: am cf9a9604: Merge "Switch to upstream-freebsd for the unmolested wchar code."
* commit '7b69ac535abca0e7867524e68f5a3581cc367de8':
  Switch to upstream-freebsd for the unmolested wchar code.
2013-03-05 20:28:28 +00:00
Elliott Hughes
81e0f35acc am 2125c155: am d392e044: Merge "Move realpath.c to upstream-freebsd."
* commit '2125c15506cbe9e4062d72ebb723d164e9c01c1f':
  Move realpath.c to upstream-freebsd.
2013-03-04 23:56:56 +00:00
Elliott Hughes
eb93ebffba Switch to upstream-freebsd for the unmolested wchar code.
Change-Id: I87b4d76ff8da04109ae53638eec4f11629798960
2013-03-01 18:35:56 -08:00
Elliott Hughes
f0777843c0 Move realpath.c to upstream-freebsd.
This is actually a slightly newer upstream version than the one I
originally pulled. Hopefully now it's in upstream-freebsd it will
be easier to track upstream, though I still need to sit down and
write the necessary scripts at some point.

Bug: 5110679
Change-Id: I87e563f0f95aa8e68b45578e2a8f448bbf827a33
2013-03-01 17:11:39 -08:00
Christopher Ferris
947b3ab02b Remove unused arm defines. DO NOT MERGE
The defines HAVE_32_BYTE_CACHE_LINES and ARCH_ARM_USE_NON_NEON_MEMCPY
are not used by any code. The previous memcpy code that used these
has been split into different architecture versions to avoid the need
for them.

Bug: 8005082

(cherry picked from commit 6e1a5cf31b)

Change-Id: I69654d47db1458136782b5504290f620e924ee75
2013-03-01 16:54:56 -08:00
Christopher Ferris
7c83a1ed81 Break bionic implementations into arch versions. DO NOT MERGE
Move arch specific code for arm, mips, x86 into separate
makefiles.
In addition, add different arm cpu versions of memcpy/memset.

Bug: 8005082

(cherry picked from commit acdde8c1cf)

Change-Id: I0108d432af9f6283ae99adfc92a3399e5ab3e31d
2013-02-28 17:45:16 -08:00
Elliott Hughes
aa13eaa934 am d9cb6988: am 406968b2: am c0e9ddd0: Merge "Reimplement scandir(3)."
* commit 'd9cb69881a062c615a8009be0a70270c70eb35da':
  Reimplement scandir(3).
2013-02-25 22:58:44 +00:00
Elliott Hughes
701bec2af3 Reimplement scandir(3).
The old scandir implementation didn't take into account the varying
size of directory entries, and didn't correctly clean up on its
error exits.

Bug: 7339844
Change-Id: Ib40e3564709752241a3119a496cbb2192e3f9abe
2013-02-25 13:14:31 -08:00
Elliott Hughes
5593d50c72 am eeecff72: Merge "Fix pthreads functions that should return ESRCH."
* commit 'eeecff7293efd6becf3b07b8d24cada3d820c894':
  Fix pthreads functions that should return ESRCH.
2013-02-19 13:46:37 -08:00
Elliott Hughes
9d23e04c43 Fix pthreads functions that should return ESRCH.
imgtec pointed out that pthread_kill(3) was broken, but most of the
other functions that ought to return ESRCH for invalid/exited threads
were equally broken.

Change-Id: I96347f6195549aee0c72dc39063e6c5d06d2e01f
2013-02-19 12:21:41 -08:00
Elliott Hughes
4174337525 am 7f67f78a: Merge "dalvik is big enough and ugly enough to handle System.arraycopy itself."
* commit '7f67f78ad5c3da689997edd8fbb5afb6e5fc6355':
  dalvik is big enough and ugly enough to handle System.arraycopy itself.
2013-02-15 17:00:58 -08:00
Elliott Hughes
081318e355 dalvik is big enough and ugly enough to handle System.arraycopy itself.
Change-Id: I4b54a15ea101c0c6bab06cfb11e4178f5a57fc05
2013-02-15 14:27:52 -08:00
Elliott Hughes
56a007c157 am 0a2cb815: Merge "Simplify __stack_chk_fail, and fix it so we get debuggerd stack traces."
# Via Elliott Hughes (1) and Gerrit Code Review (1)
* commit '0a2cb815974ea96af664fa966079966a08916722':
  Simplify __stack_chk_fail, and fix it so we get debuggerd stack traces.
2013-02-14 15:59:15 -08:00
Elliott Hughes
fb7eb5e07f Simplify __stack_chk_fail, and fix it so we get debuggerd stack traces.
Bug: 2487269
Change-Id: Iec5e470fc22cd9108404f634a9d4baa2c7b7f58f
2013-02-14 14:37:34 -08:00
Elliott Hughes
7331af73f2 am c2d26ce7: Merge "Turn on -Werror for ssp.cpp."
# Via Elliott Hughes (1) and Gerrit Code Review (1)
* commit 'c2d26ce7452e69b9492cd28b7c0271866798658b':
  Turn on -Werror for ssp.cpp.
2013-02-14 11:23:48 -08:00
Elliott Hughes
dc5ec07158 Turn on -Werror for ssp.cpp.
libc_bionic.a is already compiled -Werror, but this one file gets
compiled into its own library because it needs to be compiled with
-fno-stack-protector.

Change-Id: I273c535ab5c73ccaccbcf793fda1f788a2589abe
2013-02-14 11:15:58 -08:00
Elliott Hughes
2346559cb4 am 6b97c7dc: Merge "ffs was not being built for x86."
# Via Elliott Hughes (1) and Gerrit Code Review (1)
* commit '6b97c7dc0376577276abbdacc52e5cc11cf8a7fd':
  ffs was not being built for x86.
2013-02-13 17:08:07 -08:00
Elliott Hughes
d2547040a1 ffs was not being built for x86.
Change-Id: I53e92273664a4d0a13536c2fa1aeb87e1f3cf4e8
2013-02-13 16:31:52 -08:00
Elliott Hughes
2db16ea38e am 3002d64b: Merge "Everyone has a TLS register."
# Via Elliott Hughes (1) and Gerrit Code Review (1)
* commit '3002d64bcd4644456803dd0547d20b39e14be02c':
  Everyone has a TLS register.
2013-02-13 08:11:24 -08:00
Elliott Hughes
91a9925998 Everyone has a TLS register.
Change-Id: Id7cdf67087aa7d5074c9c59b7e595bc391d9f146
2013-02-12 21:56:42 -08:00
Elliott Hughes
bc35693e6b am 07f7e62a: Merge "Clean up pthread_create."
# Via Elliott Hughes (1) and Gerrit Code Review (1)
* commit '07f7e62a259d13208d6186670d3748e339690127':
  Clean up pthread_create.
2013-02-12 18:20:10 -08:00
Elliott Hughes
4b4a882428 Clean up pthread_create.
Bug: 3461078
Change-Id: I082122a86d7692cd58f4145539241be026258ee0
2013-02-12 17:15:59 -08:00
Elliott Hughes
78715fca0b am 558a8b1d: Merge "Revert "Revert "More pthreads cleanup."""
# Via Elliott Hughes (1) and Gerrit Code Review (1)
* commit '558a8b1d3b31300941af78232f2f7f4cb4e933b9':
  Revert "Revert "More pthreads cleanup.""
2013-02-12 16:23:24 -08:00
Elliott Hughes
3e898476c7 Revert "Revert "More pthreads cleanup.""
This reverts commit 6f94de3ca4

(Doesn't try to increase the number of TLS slots; that leads to
an inability to boot. Adds more tests.)

Change-Id: Ia7d25ba3995219ed6e686463dbba80c95cc831ca
2013-02-12 15:27:18 -08:00
Elliott Hughes
191f880bdf am bfa199ab: am fcaf4e9f: Merge "Revert "More pthreads cleanup.""
# Via Gerrit Code Review (2) and Android Git Automerger (1)
* commit 'bfa199ab4019a7de9b95cd3db86c4d7176438803':
  Revert "More pthreads cleanup."
2013-02-11 22:20:39 -08:00
Elliott Hughes
fcaf4e9f9b Merge "Revert "More pthreads cleanup."" 2013-02-12 06:07:32 +00:00
Elliott Hughes
6f94de3ca4 Revert "More pthreads cleanup."
This reverts commit 2a1bb4e646

Change-Id: Ia443d0748015c8e9fc3121e40e68258616767b51
2013-02-12 06:06:22 +00:00
Elliott Hughes
23731e841a am a2a9817f: am 85f491f9: Merge "More pthreads cleanup."
# Via Android Git Automerger (1) and others
* commit 'a2a9817f4c08d1f56d90f02ed13f531e8093f8e8':
  More pthreads cleanup.
2013-02-11 18:39:32 -08:00
Elliott Hughes
85f491f96d Merge "More pthreads cleanup." 2013-02-12 02:33:08 +00:00
Elliott Hughes
13478d856a am 605cc293: am 83bf28e6: Merge "Fix MIPS build."
# Via Android Git Automerger (1) and others
* commit '605cc29358c9a6d575d097fd4b78a483c9dbf89e':
  Fix MIPS build.
2013-02-11 18:23:17 -08:00
Elliott Hughes
ba342c11ad Fix MIPS build.
Change-Id: I4863f21f3c2fd597ea36cb7096fc72db808643a3
2013-02-11 18:06:23 -08:00
Elliott Hughes
5bb4f54b4d am 6b73d13f: am 2d3e7233: Merge "Revert "Revert "Pull the pthread_key_t functions out of pthread.c."""
# Via Android Git Automerger (1) and others
* commit '6b73d13fa414afeecba6718bf724e8ac922bac39':
  Revert "Revert "Pull the pthread_key_t functions out of pthread.c.""
2013-02-11 17:34:32 -08:00
Elliott Hughes
1b21249d5a am e4b08318: am 8397cdba: Merge "Revert "Pull the pthread_key_t functions out of pthread.c.""
# Via Gerrit Code Review (2) and Android Git Automerger (1)
* commit 'e4b08318c13fac774b233a5459427563d2983f79':
  Revert "Pull the pthread_key_t functions out of pthread.c."
2013-02-11 17:34:30 -08:00
Elliott Hughes
376bce0097 am 024246ec: am 09e89c3c: Merge "Pull the pthread_key_t functions out of pthread.c."
# Via Android Git Automerger (1) and others
* commit '024246ec274e30bb4a24468d8319620534e13b34':
  Pull the pthread_key_t functions out of pthread.c.
2013-02-11 17:34:29 -08:00
Elliott Hughes
2a1bb4e646 More pthreads cleanup.
POSIX says pthread_create returns EAGAIN, not ENOMEM.

Also pull pthread_attr_t functions into their own file.

Also pull pthread_setname_np into its own file.

Also remove unnecessary #includes from pthread_key.cpp.

Also account for those pthread keys used internally by bionic,
so they don't count against the number of keys available to user
code. (They do with glibc, but glibc's limit is the much more
generous 1024.)

Also factor out the common errno-restoring idiom to reduce gotos.

Bug: 6702535
Change-Id: I555e66efffcf2c1b5a2873569e91489156efca42
2013-02-11 14:56:39 -08:00
Elliott Hughes
44b53ad681 Revert "Revert "Pull the pthread_key_t functions out of pthread.c.""
This reverts commit 6260553d48

(Removing the accidental libm/Android.mk change.)

Change-Id: I6cddd9857c31facc05636e8221505b3d2344cb75
2013-02-11 12:20:33 -08:00
Elliott Hughes
6260553d48 Revert "Pull the pthread_key_t functions out of pthread.c."
This reverts commit ad59322ae4

somehow my unfinished libm/Android.mk change got into here.

Change-Id: I46be626c5269d60fb1ced9862f2ebaa380b4e0af
2013-02-11 20:18:16 +00:00
Elliott Hughes
ad59322ae4 Pull the pthread_key_t functions out of pthread.c.
This was originally motivated by noticing that we were setting the
wrong bits for the well-known tls entries. That was a harmless bug
because none of the well-known tls entries has a destructor, but
it's best not to leave land mines lying around.

Also add some missing POSIX constants, a new test, and fix
pthread_key_create's return value when we hit the limit.

Change-Id: Ife26ea2f4b40865308e8410ec803b20bcc3e0ed1
2013-02-11 12:00:48 -08:00
Elliott Hughes
389ebfa16f am 6f67cd22: am 2f41531f: Merge "Clean up the argc/argv/envp/auxv handling."
# Via Android Git Automerger (1) and others
* commit '6f67cd224e6ffdfa2619849eb4b9b2ff6c1e2c59':
  Clean up the argc/argv/envp/auxv handling.
2013-02-07 14:45:24 -08:00
Elliott Hughes
42b2c6a5ee Clean up the argc/argv/envp/auxv handling.
There's now only one place where we deal with this stuff, it only needs to
be parsed once by the dynamic linker (rather than by each recipient), and it's
now easier for us to get hold of auxv data early on.

Change-Id: I6314224257c736547aac2e2a650e66f2ea53bef5
2013-02-07 11:44:21 -08:00
Elliott Hughes
6dd470d4d0 am df8c72e5: am d7ff139f: Merge "Remove bogus extra alignment from sbrk."
# Via Android Git Automerger (1) and others
* commit 'df8c72e510ae9d0a9970a31555ea51ea0c8f19ca':
  Remove bogus extra alignment from sbrk.
2013-02-05 17:14:50 -08:00
Elliott Hughes
428f5567be Remove bogus extra alignment from sbrk.
Bug: https://code.google.com/p/android/issues/detail?id=37349
Change-Id: I970c7b6be7bb7fbe6bbbe2c332f05816aeb0e09f
2013-02-05 16:10:59 -08:00
Elliott Hughes
7f0976ef0e am 5f79f75b: am 57edf36c: am 8d6302cd: Merge "Our strcoll(3) is no different from NetBSD\'s, so take exactly theirs."
* commit '5f79f75ba6241ca9cab42e69a68d66d1ca28e031':
  Our strcoll(3) is no different from NetBSD's, so take exactly theirs.
2013-01-22 15:36:26 -08:00
Elliott Hughes
774cef56ee am ad551eaa: am 5f7b6b83: am 547eba0a: Merge "Avoid overflow in memccpy."
* commit 'ad551eaa0429bf5085f2901c5d367e8a54b7ed16':
  Avoid overflow in memccpy.
2013-01-22 15:23:53 -08:00
Elliott Hughes
2b47307012 Our strcoll(3) is no different from NetBSD's, so take exactly theirs.
Change-Id: I45251047202a229f9175735ecc23c0ebcda71e8d
2013-01-22 15:10:19 -08:00
Elliott Hughes
c51cd764a2 Avoid overflow in memccpy.
Just take the upstream NetBSD code.

Bug: http://code.google.com/p/android/issues/detail?id=43078
Change-Id: Ibbbde9d00e8bc6a09c9503aab2b04b4e3d1f98b0
2013-01-22 14:41:23 -08:00
Elliott Hughes
16f7b78fd1 am 4cd5703b: am 75b64a1b: am ca483765: Merge "Fix the duplication in the debugging code."
* commit '4cd5703b9eef30a32271819503808576666e1601':
  Fix the duplication in the debugging code.
2013-01-22 10:05:19 -08:00
Elliott Hughes
1e980b6bc8 Fix the duplication in the debugging code.
We had two copies of the backtrace code, and two copies of the
libcorkscrew /proc/pid/maps code. This patch gets us down to one.

We also had hacks so we could log in the malloc debugging code.
This patch pulls the non-allocating "printf" code out of the
dynamic linker so everyone can share.

This patch also makes the leak diagnostics easier to read, and
makes it possible to paste them directly into the 'stack' tool (by
using relative PCs).

This patch also fixes the stdio standard stream leak that was
causing a leak warning every time tf_daemon ran.

Bug: 7291287
Change-Id: I66e4083ac2c5606c8d2737cb45c8ac8a32c7cfe8
2013-01-18 22:20:06 -08:00
Nick Kralevich
8ffe08c86b am fdd6dfa8: am 2c5153b0: libc: add getauxval()
* commit 'fdd6dfa863ea73251b5d59990e239854c31ecee3':
  libc: add getauxval()
2013-01-11 17:04:04 -08:00
Nick Kralevich
2c5153b043 libc: add getauxval()
Add support for getauxval().  This method allows a program an easy way
to retrieve information from the kernel auxiliary vector, and will
hopefully replace other clumsy ways of accessing this same information.

This particular function was also added to glibc in glibc 2.16.
See the following URLs for more details.

  * http://lwn.net/Articles/519085/
  * http://www.gnu.org/software/libc/manual/html_node/Auxiliary-Vector.html

This change is a prerequisite for bug 7959813.

Bug: http://code.google.com/p/android/issues/detail?id=38441
Change-Id: Iba19d899df334bddc6f4899077ece2fc87564ea8
2013-01-11 16:44:15 -08:00
Elliott Hughes
73dd37d8fe am 34c7a3c2: am 0d3700d9: Merge "Only have one copy of the kernel_sigset_t hack, and add more tests."
* commit '34c7a3c2b0ec50a749e25bd786e670025a6f1c5b':
  Only have one copy of the kernel_sigset_t hack, and add more tests.
2013-01-11 10:54:25 -08:00
Elliott Hughes
7e29f81163 am 4ff6fa97: am 2bbb8fac: Merge "Add signalfd call to bionic"
* commit '4ff6fa97e7cf247e17600cf0d64911c1579df841':
  Add signalfd call to bionic
2013-01-11 10:54:02 -08:00
Elliott Hughes
c5d028fc91 Only have one copy of the kernel_sigset_t hack, and add more tests.
Change-Id: I377522fcba6fb4b5fd2754ab15b091014bd7c16f
2013-01-10 14:42:14 -08:00
Rom Lemarchand
a4b2dc016f Add signalfd call to bionic
Add signalfd() call to bionic.

Adding the signalfd call was done in 3 steps:
- add signalfd4 system call (function name and syscall
  number) to libc/SYSCALLS.TXT
- generate all necessary headers by calling
  libc/tools/gensyscalls.py. This patch is adding
  the generated files since the build system
  does not call gensyscalls.py.
- create the signalfd wrapper in signalfd.cpp and add
  the function prototype to sys/signalfd.h

(cherry-pick of 0c11611c11, modified to
work with older versions of GCC still in use on some branches.)

Change-Id: I4c6c3f12199559af8be63f93a5336851b7e63355
2013-01-10 13:14:46 -08:00
Elliott Hughes
19dd1567a0 Revert "Add signalfd call to bionic"
This reverts commit 0c11611c11

Change-Id: I1a2beae7ed66ec995fdf6c96c53c35598ac6cde0
2013-01-10 10:47:58 -08:00
Rom Lemarchand
0c11611c11 Add signalfd call to bionic
Add signalfd() call to bionic.

Adding the signalfd call was done in 3 steps:
- add signalfd4 system call (function name and syscall
  number) to libc/SYSCALLS.TXT
- generate all necessary headers by calling
  libc/tools/gensyscalls.py. This patch is adding
  the generated files since the build system
  does not call gensyscalls.py.
- create the signalfd wrapper in signalfd.cpp and add
  the function prototype to sys/signalfd.h

Change-Id: I7ee1d3e60d5d3e1c73d9820e07d23b9ce6e1a5ab
2013-01-10 10:25:42 -08:00
Elliott Hughes
e9d6575e10 am 1287d106: am fb62558b: Merge "Define _POSIX_MONOTONIC_CLOCK and implement sysconf(_SC_MONOTONIC_CLOCK)."
* commit '1287d106ed235e7366912bc7ab09df532848dd7a':
  Define _POSIX_MONOTONIC_CLOCK and implement sysconf(_SC_MONOTONIC_CLOCK).
2013-01-02 16:35:08 -08:00
Elliott Hughes
a55f63083f Define _POSIX_MONOTONIC_CLOCK and implement sysconf(_SC_MONOTONIC_CLOCK).
Bug: http://code.google.com/p/android/issues/detail?id=39680
Change-Id: I11cf10a66f9d305868a725f04f581099fb88bbfc
2013-01-02 14:23:43 -08:00
Elliott Hughes
42d7a26d23 am f822e7f6: am 0521ff82: Merge "Use pthread_kill() in raise()"
* commit 'f822e7f68eec30bb175ccb46cd379f4a060b6c74':
  Use pthread_kill() in raise()
2012-12-10 11:42:06 -08:00
Chris Dearman
d8a5a6f513 Use pthread_kill() in raise()
raise() should use pthread_kill() in a pthreads environment.
For bionic this means it should always be used.

Change-Id: Ic679272b664d2b8a7068b628fb83a9f7395c441f
2012-12-10 11:20:57 -08:00
Elliott Hughes
dcb8209409 am 7beaa502: am 16c61f08: Merge "Reduce the exposure of the __set_errno implementation detail."
* commit '7beaa5024f083431ca74ee73b01f5ad1e5b4198f':
  Reduce the exposure of the __set_errno implementation detail.
2012-11-30 14:46:50 -08:00
Elliott Hughes
4a9e837840 Reduce the exposure of the __set_errno implementation detail.
Change-Id: I395e1b46a9491e34fc53e71853e932ea90b3d1cc
2012-11-30 12:05:18 -08:00
Elliott Hughes
2e51dc444f am 4835e6ef: am 97b70b2b: Merge "Replace .S version of x86 crtfiles with .c version"
* commit '4835e6ef519fc941651bbc13909cff971a6ec81b':
  Replace .S version of x86 crtfiles with .c version
2012-11-30 10:16:06 -08:00
Pavel Chupin
20c4a3a8ee Replace .S version of x86 crtfiles with .c version
This patch replaces .S versions of x86 crtfiles with .c which are much
easier to support. Some of the files are matching .c version of Arm
crtfiles. x86 files required some cleanup anyway and this cleanup actually
led to matching Arm files.

I didn't change anything to share the same crt*.c between x86 and Arm. I
prefer to keep them separate for a while in case any change is required
for one of the arch, but it's good thing to do in the following patches.

Change-Id: Ibcf033f8d15aa5b10c05c879fd4b79a64dfc70f3
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2012-11-30 17:41:25 +04:00
Elliott Hughes
c7358ee57c am 743a273e: am 1f21ece4: Merge "Clean up the <libgen.h> implementation a little, bring in tests."
* commit '743a273e40e49c199d79462338fc606ae12c999f':
  Clean up the <libgen.h> implementation a little, bring in tests.
2012-10-30 10:11:44 -07:00
Elliott Hughes
d4834a217e am 40e467ec: am 33c4a3ad: Merge "libc: Fix alphasort() signature (and implementation)."
* commit '40e467ec668b59be25491bd44bf348a884d6a68d':
  libc: Fix alphasort() signature (and implementation).
2012-10-30 10:11:41 -07:00
Elliott Hughes
96b52e104a am a67cedb5: am 9e783963: Merge "Clean up the implementation of the <dirent.h> functions."
* commit 'a67cedb52cb57f116a545482bddb979d995fd634':
  Clean up the implementation of the <dirent.h> functions.
2012-10-30 10:11:39 -07:00
Elliott Hughes
58b575485c Clean up the <libgen.h> implementation a little, bring in tests.
Most of these tests were in system/extras, but I've added more to cover other
cases explicitly mentioned by POSIX.

Change-Id: I5e8d77e4179028d77306935cceadbb505515dcde
2012-10-29 14:27:10 -07:00
David 'Digit' Turner
c30396f5f2 libc: Fix alphasort() signature (and implementation).
The declaration for alphasort() in <dirent.h> used the deprecated:

  int alphasort(const void*, const void*);

while both Posix and GLibc use instead:

  int alphasort(const struct dirent** a, const struct dirent** b);

See: http://pubs.opengroup.org/onlinepubs/9699919799/functions/alphasort.html

This patch does the following:

- Update the declaration to match Posix/GLibc
- Get rid of the upstream BSD code which isn't compatible with the new
  signature.
- Implement a new trivial alphasort() with the right signature, and
  ensure that it uses strcoll() instead of strcmp().
- Remove Bionic-specific #ifdef .. #else .. #endif block in
  dirent_test.cpp which uses alphasort().

Even through strcoll() currently uses strcmp(), this does the right
thing in the case where we decide to update strcoll() to properly
implement locale-specific ordered comparison.

Change-Id: I4fd45604d8a940aaf2eb0ecd7d73e2f11c9bca96
2012-10-29 07:44:27 -07:00
Elliott Hughes
063cfb2084 Clean up the implementation of the <dirent.h> functions.
Change-Id: I3c647cc9588525afc41fee90ee468d58cd13503a
2012-10-26 16:42:06 -07:00
Elliott Hughes
0f96dd8dcb am df7f24f3: am 7b68e3f7: Merge "Per-thread -fstack-protector guards for x86."
* commit 'df7f24f310ee3ceb1dc9413d59d5a8816eb584ef':
  Per-thread -fstack-protector guards for x86.
2012-10-25 12:23:56 -07:00
Elliott Hughes
ad88a08631 Per-thread -fstack-protector guards for x86.
Based on a pair of patches from Intel:

  https://android-review.googlesource.com/#/c/43909/
  https://android-review.googlesource.com/#/c/44903/

For x86, this patch supports _both_ the global that ARM/MIPS use
and the per-thread TLS entry (%gs:20) that GCC uses by default. This
lets us support binaries built with any x86 toolchain (right now,
the NDK is emitting x86 code that uses the global).

I've also extended the original tests to cover ARM/MIPS too, and
be a little more thorough for x86.

Change-Id: I02f279a80c6b626aecad449771dec91df235ad01
2012-10-25 12:04:03 -07:00
Elliott Hughes
4cdc426207 am 60c7ac26: am d0f2b7e7: Merge "More upstream NetBSD upgrades."
* commit '60c7ac262241588f7942ca068f33d706c8fe5cc4':
  More upstream NetBSD upgrades.
2012-10-23 17:29:47 -07:00
Elliott Hughes
ab44f52202 More upstream NetBSD upgrades.
Change-Id: Idb781d37de3b05585271d7d258ecffd5ba87d0b8
2012-10-23 16:05:09 -07:00
Elliott Hughes
217e616772 am 45f07555: am e3dbe1e3: Merge "Upgrade more functions to the current upstream NetBSD copy."
* commit '45f075556b26cfe91b1b7e1299b54f0328a06acb':
  Upgrade more functions to the current upstream NetBSD copy.
2012-10-23 13:58:25 -07:00
Elliott Hughes
e8bcca3a2c Upgrade more functions to the current upstream NetBSD copy.
Change-Id: Ie0b3f8b3fccef28609eb210434413ebd51d6ef45
2012-10-23 12:29:53 -07:00
Elliott Hughes
1d212fa6eb am 4280143d: am fb93e6a5: Merge "Move setlocale(3) and the wchar stubs over to .cpp."
* commit '4280143d371eae2123a5d8c4d8779db159ecd1e2':
  Move setlocale(3) and the wchar stubs over to .cpp.
2012-10-22 18:08:54 -07:00
Elliott Hughes
29c7f0b4d1 Move setlocale(3) and the wchar stubs over to .cpp.
Also separate out the C++ files so we can use -Werror on them. I'd
rather wait for LOCAL_CPPFLAGS to be in AOSP, but this also lets us
see which files still need to be sorted into one bucket or the other.

Change-Id: I6acc1f7c043935c70a3b089f705d218b9aaaba0a
2012-10-22 17:05:27 -07:00
Elliott Hughes
8b8cc88d39 am 75f33adc: am 4e457759: Merge "Move the FORTIFY_SOURCE helpers over to .cpp."
* commit '75f33adcb1f845ae121eb5508b120aaaa9f7a217':
  Move the FORTIFY_SOURCE helpers over to .cpp.
2012-10-22 16:00:03 -07:00
Elliott Hughes
4035b7a321 Move the FORTIFY_SOURCE helpers over to .cpp.
Change-Id: Ib5067d51b983cac7760c975becce7fe2408ead04
2012-10-22 15:32:01 -07:00
Elliott Hughes
c0e8400361 am 79c6a8d2: am ca7466d2: Merge "Make bionic\'s dependency on the tzdata explicit."
* commit '79c6a8d2b163e40eb6f19bbf8f59eb85fb7996e6':
  Make bionic's dependency on the tzdata explicit.
2012-10-18 13:40:19 -07:00
Elliott Hughes
914d8d4cff Make bionic's dependency on the tzdata explicit.
Also stop building the obsolete three files, now bionic and libcore
both use the new single file.

Bug: 7012465
Change-Id: I1b9b49af7382c57b6cb8820c2275e6d4044b2bb6
2012-10-18 12:23:34 -07:00
Elliott Hughes
f0a9cd7847 am 92e6de6f: am b95ad82f: am 95a2a7f3: Merge "Fix MIPS build."
* commit '92e6de6f940fee6362dd306ad77c6d7bfa56e4cb':
  Fix MIPS build.
2012-10-02 11:34:14 -07:00
Elliott Hughes
857fed50cb Fix MIPS build.
ARM and x86 have custom memcpy implementations, but MIPS relies on the generic
one, which I recently moved.

Change-Id: I9e49243f63b27a4123f2c6623d6286ec82d333c7
2012-10-02 11:20:07 -07:00
Elliott Hughes
6cdf8dd025 am 80a29832: am 90172541: am b98204a9: Merge "Move non-upstream code into the libc/bionic directory."
* commit '80a298327299aa28b564941f90818911023ae544':
  Move non-upstream code into the libc/bionic directory.
2012-10-02 09:28:31 -07:00
Elliott Hughes
a89864a20b Move non-upstream code into the libc/bionic directory.
I'll need at least one more pass, because there's some upstream code
lurking in libc/bionic, but this is still a step in the right direction.

Change-Id: I55927315972da8327ae01c5240ed587db17e8462
2012-10-01 17:35:49 -07:00
Elliott Hughes
b5d5173139 am a54d08a7: am a428bc12: am fe712e6c: Merge "Upgrade seed48 too."
* commit 'a54d08a7c15e15f24d94ca6fb97329134d4441a2':
  Upgrade seed48 too.
2012-10-01 14:48:57 -07:00
Elliott Hughes
b28c547aa4 am 6ed5bc12: am b650111a: am cd195eba: Merge "Upgrade to the current NetBSD rand implementation."
* commit '6ed5bc12dac544004f8e79b6393b2a8e260a7cc1':
  Upgrade to the current NetBSD rand implementation.
2012-10-01 14:16:53 -07:00
Elliott Hughes
31a1060a5a Upgrade seed48 too.
Missed this in 774c7f54ff.

Change-Id: Ic24fd67f003d0e2d192cfb08f96f63024ca817eb
2012-10-01 14:14:21 -07:00
Elliott Hughes
774c7f54ff Upgrade to the current NetBSD rand implementation.
Also add basic unit tests.

Change-Id: I7fc7ef61d47c1e8fdf8b8eff67a635220c3afd56
2012-10-01 13:53:41 -07:00
Elliott Hughes
2e223d208f am fb1e192e: am 72b08af3: am f9163dd1: Merge "Add getdelim(3) and getline(3) to bionic"
* commit 'fb1e192e12fb4047bf5f01ccf0fd4e5644743adb':
  Add getdelim(3) and getline(3) to bionic
2012-09-28 09:57:11 -07:00
Irina Tirdea
eac9eb462e Add getdelim(3) and getline(3) to bionic
Some userspace programs (e.g. perf) need getline.

Changes:
() add getdelim.c, getline.c from NetBSD (http://netbsd.org/) under the
NetBSD Foundation's (TNF) license ("2 clause" Berkeley-style license).
() add stub for reentrant.h header that is needed by getdelim.c
() add tests for getdelim(3) and getline(3).
() update NOTICE file.

Change-Id: I22ed82dd5904b9d7a3695535c04f502be3c27c5d
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
2012-09-27 11:38:57 -07:00
Elliott Hughes
0a2d31838f am 66569e3d: am a48d5e5f: am 855dde44: Merge "Fix tmpfile(3)."
* commit '66569e3d53643fe4682091c4e11c25449e9b7fdc':
  Fix tmpfile(3).
2012-09-26 12:21:02 -07:00
Elliott Hughes
855dde4426 Merge "Fix tmpfile(3)." 2012-09-26 12:04:59 -07:00
Elliott Hughes
91875dcd6e Fix tmpfile(3).
This could be better, but at least now it works.

Change-Id: I88b7cf3f7ce8e5fa0b3fe678b7d1679a68ffffc9
2012-09-26 12:02:17 -07:00
Nick Kralevich
0147bd2f78 am 06abf4ed: am 5989ed5c: am 25937d36: Merge "FORTIFY_SOURCE: add umask check"
* commit '06abf4edbf4b6d10ee82369ed48b8145a94ba1aa':
  FORTIFY_SOURCE: add umask check
2012-09-26 11:15:38 -07:00
Nick Kralevich
cd587701c8 FORTIFY_SOURCE: add umask check
Verify that the call to umask makes sense. While this wouldn't
have detected bug 7094213 (because the low order bits were all zero),
it might detect other similar bugs.

References: https://code.google.com/p/android-source-browsing/source/detail?r=acba45cc4b1f98f67fcdeda2f7c13ed57659b92a&repo=platform--libcore

Change-Id: I966a531d6b3cf8e1c5eacd69bd3cbec475b5fa58
2012-09-26 10:19:31 -07:00
Elliott Hughes
62466a55bf am 7e9d6d8a: am b2af8b68: am 66a97ea9: am 4e9d953a: Merge "libc: add ftw / nftw functions"
* commit '7e9d6d8abba781992b1f55f36e02b2baae368d07':
  libc: add ftw / nftw functions
2012-09-14 10:28:47 -07:00
Elliott Hughes
6a163a1bf1 am c9829a2b: am 155a70b9: am de9db8f7: am fa36875d: Merge "Make strerror(3) and strsignal(3) thread-safe, and add psignal(3) and psiginfo(3)."
* commit 'c9829a2b6fb70f2eb0fc6a21f48546c66d9724c7':
  Make strerror(3) and strsignal(3) thread-safe, and add psignal(3) and psiginfo(3).
2012-09-14 10:28:04 -07:00
Nick Kralevich
5e58ea07d4 libc: add ftw / nftw functions
Please see "man 3 ftw" for a description of the
ftw / nftw functions.

This code is taken directly from netbsd unmodified.

Change-Id: Ia4879ac57212b424adf5281b5e92858e216d0f14
2012-09-13 16:54:57 -07:00
Irina Tirdea
b5f053b5a7 Make strerror(3) and strsignal(3) thread-safe, and add psignal(3) and psiginfo(3).
Change-Id: I426109db25e907980d6cb3a7a695796e45783b78
2012-09-13 15:18:21 -07:00
Elliott Hughes
ce061964f7 am c005a55c: am 478f8ff3: am b2550dd4: am 4a9b7c69: Merge "Add libdl into libc_malloc_debug_leak build"
* commit 'c005a55c74105c4eed8e2b0ba68ce0bfd67ccffe':
  Add libdl into libc_malloc_debug_leak build
2012-09-13 14:12:02 -07:00
Pavel Chupin
e007775f4b Add libdl into libc_malloc_debug_leak build
Otherwise libc_malloc_debug_leak.so is failed to load runtime in x86
case

Change-Id: I8207ce06d1ec17b233f4e4fcfdd2b161673b4fa8
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2012-09-13 12:03:06 +04:00
Elliott Hughes
20599f5c9e am eeabbaee: am f50b99f4: am e8b4d67a: am 59726bed: Merge "Rename crtstart variables as crtbegin, to match reality."
* commit 'eeabbaee88202a459ec381edc45c0995bdcfa3c8':
  Rename crtstart variables as crtbegin, to match reality.
2012-09-10 17:15:10 -07:00
Ying Wang
62fd0b699a am 33d552a4: am e3738414: am f9920563: am 67546bf2: Merge "Generate header dependency makefiles for the crt*.o"
* commit '33d552a4d1c766aeb99c71060aa091e7aafaaac9':
  Generate header dependency makefiles for the crt*.o
2012-09-10 17:14:10 -07:00
Elliott Hughes
12949e5d39 Rename crtstart variables as crtbegin, to match reality.
No functional change, but it's confusing that the variable
names don't match the filenames.

Change-Id: I7109f917797be2f056e69fddb92e4a7306281813
2012-09-10 11:16:12 -07:00
Ying Wang
cf464878ef Generate header dependency makefiles for the crt*.o
Bug: 7127743
Change-Id: I606e5f7cd2b513f855a1fefd2b001abd365fc854
2012-09-07 17:13:37 -07:00
Elliott Hughes
ec0d2a86b7 am 340ff83f: am ac3e35cd: am a76f2eca: am 26f2e4a1: Merge "ARM: make CRT_LEGACY_WORKAROUND work as intended"
* commit '340ff83f9878a478cfa4b5aaaf4260f96304c416':
  ARM: make CRT_LEGACY_WORKAROUND work as intended
2012-09-05 10:06:25 -07:00
Elliott Hughes
26f2e4a163 Merge "ARM: make CRT_LEGACY_WORKAROUND work as intended" 2012-09-05 09:43:35 -07:00
Elliott Hughes
5fe555ecac am b3732862: am 8900e2de: am e5b85f45: am 0d7177c0: Merge "Clean up warnings in the malloc_debug_* files."
* commit 'b37328627be403b9c2a2896765a7bc7a357cb073':
  Clean up warnings in the malloc_debug_* files.
2012-08-29 13:23:34 -07:00
Elliott Hughes
c4d1fecc10 Clean up warnings in the malloc_debug_* files.
Also clean up cpplint.py-detected lint.

Change-Id: Ia18e89c4c6878764f8d7ed34b8247e7a8d8fe88b
2012-08-29 12:08:13 -07:00
Ian Rogers
31abfc3a98 am 1df8fe33: am f71fa083: Merge "Revert "Revert "Upgrade to dlmalloc 2.8.5.""" into jb-mr1-dev
* commit '1df8fe33d59df1be3b1d33db033e379a32416a68':
  Revert "Revert "Upgrade to dlmalloc 2.8.5.""
2012-08-29 08:57:49 -07:00
Ian Rogers
2c344d3631 Revert "Revert "Upgrade to dlmalloc 2.8.5.""
This reverts commit f72ee26927.
2012-08-28 15:53:10 -07:00
Ard Biesheuvel
f3cfcd869d ARM: make CRT_LEGACY_WORKAROUND work as intended
To properly support legacy ARM shared libraries, libc.so needs
to export the symbols __dso_handle and atexit, even though
these are now supplied by the crt startup code.

This patch reshuffles the existing CRT_LEGACY_WORKAROUND
conditionally compiled code slightly so it works as the
original author likely intended.

Change-Id: Id6c0e94dc65b7928324a5f0bad7eba6eb2f464b9
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
2012-08-28 10:27:02 +02:00
Nick Kralevich
b46a1d8890 am dd5d865d: am 81af404b: am e8198b97: am 26facba2: Merge "hardening: remove pointless ARM __get_pc() function"
* commit 'dd5d865d92c21105d28dd931d56c2f5e2f4df275':
  hardening: remove pointless ARM __get_pc() function
2012-08-23 12:37:19 -07:00
Nick Kralevich
81af404b63 am e8198b97: am 26facba2: Merge "hardening: remove pointless ARM __get_pc() function"
* commit 'e8198b97c369292a3ea97e5a2009bfba8229ddb5':
  hardening: remove pointless ARM __get_pc() function
2012-08-23 12:34:21 -07:00
Brian Carlstrom
2bdfdfbf09 am 4a56211b: am f72ee269: Revert "Upgrade to dlmalloc 2.8.5."
* commit '4a56211b0b30757c8a5d64a59976a3a97d300a18':
  Revert "Upgrade to dlmalloc 2.8.5."
2012-08-22 13:56:16 -07:00
Brian Carlstrom
f72ee26927 Revert "Upgrade to dlmalloc 2.8.5."
This reverts commit 999089181e.
2012-08-22 12:07:33 -07:00
Ard Biesheuvel
404e28ff8c hardening: remove pointless ARM __get_pc() function
Useful if you're trying to defeat ASLR, otherwise not
so much ...

Change-Id: I17ebb50bb490a3967db9c3038f049adafe2b8ea7
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
2012-08-22 20:38:54 +02:00
Brian Carlstrom
d03266b2b7 am 94c82633: am 76f60e2e: am fe87596a: am c37dcd3d: Merge "Upgrade to dlmalloc 2.8.5."
* commit '94c82633c72acae0eb7a3390167b35eb3008b4ff':
  Upgrade to dlmalloc 2.8.5.
2012-08-20 16:36:05 -07:00
Ian Rogers
999089181e Upgrade to dlmalloc 2.8.5.
Move dlmalloc code to upstream-dlmalloc to make pulling upstream changes
easier.
Declare pvalloc and malloc_usable_size routines present in malloc.h but with
missing implementations. Remove other functions from malloc.h that have
no implementation nor use in Android.

Change-Id: Ia6472ec6cbebc9ad1ef99f4669de9d33fcc2efb4
2012-08-20 14:12:20 -07:00
Elliott Hughes
4b027b381f am 12911624: am a7d8f3d5: am c80ca54f: am 60ef95e1: Merge "Enhance getcwd(3) to handle NULL like glibc."
* commit '129116241022d51ca915ef1d6b94d131a3f5569f':
  Enhance getcwd(3) to handle NULL like glibc.
2012-08-16 17:09:35 -07:00
Elliott Hughes
04a83a48ed Enhance getcwd(3) to handle NULL like glibc.
Bug: http://code.google.com/p/android/issues/detail?id=36085
Change-Id: I960a1b585887eb66176c61d29c5c61c239a4003f
2012-08-16 15:59:12 -07:00
Elliott Hughes
26145cfc18 am 949d6faa: am a626bbdb: am 4af9141c: am ae728099: Merge "enable clone system call for x86"
* commit '949d6faa96e25170293d2a9ebe6f76cc91b77a6e':
  enable clone system call for x86
2012-08-15 17:26:44 -07:00
Jin Wei
22d366cc09 enable clone system call for x86
Add __bionic_clone function for x86, which will be
used for clone system call.

Change-Id: I889dc9bf4b7ebb4358476e17e6f3233e26491f4d
Signed-off-by: Jin Wei <wei.a.jin@intel.com>
Signed-off-by: Xiaokang Qin <xiaokang.qin@intel.com>
Signed-off-by: Beare, Bruce J <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 51414
2012-08-15 17:04:50 -07:00
Elliott Hughes
0681b2e477 am f53c75e5: am 2e3756b4: am 9b3bbcda: am fe43c768: Merge "Switch to the current NetBSD regex implementation."
* commit 'f53c75e513cb088d712badc32b89a8792a329d63':
  Switch to the current NetBSD regex implementation.
2012-08-15 16:03:03 -07:00
Elliott Hughes
cc213f871b Switch to the current NetBSD regex implementation.
Change-Id: If32b28dd85d6a7ab8957ab81d19fa4c0de9499d5
2012-08-15 15:39:11 -07:00
Elliott Hughes
a10b277de2 am bfcd5525: am b6d6ec53: am 370a7094: am c50e0197: Merge "Switch to upstream NetBSD tdelete/tfind/tsearch."
* commit 'bfcd55250058e927e0c6d0b94337c89fc2d86fa2':
  Switch to upstream NetBSD tdelete/tfind/tsearch.
2012-08-14 12:21:20 -07:00
Elliott Hughes
409302f0f9 Switch to upstream NetBSD tdelete/tfind/tsearch.
tdestroy is a GNU extension, so that stays.

Change-Id: Iedebaff25ea7e92b1ab1dd4440da12b67b99aa40
2012-08-13 17:41:49 -07:00
Elliott Hughes
d52075bd97 am 2bc1cade: am 93a9d534: am d544bdfa: am 54655eaf: Merge "Fix nice..."
* commit '2bc1cadeff4b7d41c889b8f1b965028ec575bed6':
  Fix nice...
2012-08-13 17:16:55 -07:00
Elliott Hughes
3d2d448af1 Fix nice...
...by switching to the NetBSD implementation.

Change-Id: I562b27b237a24ded95804035cc322c7bff12ff59
2012-08-13 16:38:29 -07:00
Elliott Hughes
50b4523380 am aa29740c: am 69fc1522: am aa6c8994: am b66bc514: Merge "Clean up warnings in stubs.cpp."
* commit 'aa29740ce252113071f96872b7b99c8528bd1637':
  Clean up warnings in stubs.cpp.
2012-08-13 16:28:44 -07:00
Elliott Hughes
66c033868f am c64c1b49: am ad8ff472: am c1eb7619: am 440e417d: Merge "Add dependencies on all the makefiles."
* commit 'c64c1b49fd5c51b1b6e87d88b233d23fa172d372':
  Add dependencies on all the makefiles.
2012-08-13 16:10:31 -07:00
Elliott Hughes
de727caee2 Clean up warnings in stubs.cpp.
Switch to C++ to get extra warnings, and format the code Google style.

Change-Id: Ifc0131bf297a6ee8a8a6b8d049a02518b0b1a4b7
2012-08-13 16:10:19 -07:00
Elliott Hughes
ae5c64413b Add dependencies on all the makefiles.
This should help prevent broken builds next time I'm messing with
assembler/compiler/linker flags...

Change-Id: I30f15a3ce3c3f3c60cad7bc59aaba9f42d792224
2012-08-13 14:06:05 -07:00
Elliott Hughes
259f4a1503 am 7261264c: am 2a22a69e: am 877dc946: am 072a7e6c: Merge "MIPS support to the libc Makefile"
* commit '7261264c3a336bfb6e52241c2ba80679cbba68c8':
  MIPS support to the libc Makefile
2012-08-11 15:19:34 -07:00
Ying Wang
c97c5fc788 Split out LOCAL_ASFLAGS.
Bug: 6967574
Change-Id: I5be50d582c1cb8075039b06292cf0745a996c3c4
2012-08-11 14:23:19 -07:00
Raghu Gandham
a4c7933b49 MIPS support to the libc Makefile
Change-Id: Ia1f3f545ca61a5abb235e99046cb3cdaf24d4205
2012-08-10 17:24:02 -07:00
Elliott Hughes
f8b3a920a8 Revert "Revert "Switch to NetBSD's strxfrm(3).""
This reverts commit 8793e7c7d2,
and fixes the build by building upstream NetBSD source as a
separate library that's then swallowed whole into libc_common.

Change-Id: I6c9317d8c48b5ccaf85a7b185bc07fb31176ff97
2012-08-10 12:10:10 -07:00
Elliott Hughes
8793e7c7d2 Revert "Switch to NetBSD's strxfrm(3)."
This reverts commit be1d78b0dc

Change-Id: I11a95db474796f3da004f27652b081d5ba4ec9b4
2012-08-10 11:36:17 -07:00
Elliott Hughes
be1d78b0dc Switch to NetBSD's strxfrm(3).
There were two bugs in our implementation. Intel found one, but another
remainined, and tracking upstream is the way forward for functions where
we add no value.

Change-Id: Ida9bac0293fb2c4cbc942b1e0515ee0477c6538b
2012-08-10 11:03:02 -07:00
Elliott Hughes
76be660aae Clean up libc/Android.mk a bit after the crtbrand changes.
Change-Id: Icfb95fffe70967418cd93da8cbeae22dcd68f8c9
2012-08-08 14:07:37 -07:00
Jean-Baptiste Queru
7e248be764 Merge "Add a .note.android.ident section to Android ELF binaries." 2012-08-08 13:44:27 -07:00
Raghu Gandham
405b8029a6 MIPS support for libc.
Change-Id: I2864dea04b3faf2d919165dcaa600af5b16c41c8
Signed-off-by: Chris Dearman <chris@mips.com>
Signed-off-by: Raghu Gandham <raghu@mips.com>
2012-08-02 16:07:26 -07:00
Michael Hope
ea8fad11d9 Add a .note.android.ident section to Android ELF binaries.
This allows debugging tools to know they are working with Android
binaries and adapt accordingly.

Signed-off-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Signed-off-by: Michael Hope <michael.hope@linaro.org>

Change-Id: Ic906992fcad61c028bb765821637a3e1333bf52b
2012-07-31 16:18:22 +12:00
Shih-wei Liao
fc0725ec5c Install crt(begin|end)_so.o to target library path.
BUG=6886348.

Change-Id: I176b2c4963d9731b06d10d4e0b92c010a0006b59
2012-07-28 00:33:28 -07:00
Nick Kralevich
260bf8cfe0 FORTIFY_SOURCE: strlen check.
This test is designed to detect code such as:

int main() {
  char buf[10];
  memcpy(buf, "1234567890", sizeof(buf));
  size_t len = strlen(buf); // segfault here with _FORTIFY_SOURCE
  printf("%d\n", len);
  return 0;
}

or anytime strlen reads beyond an object boundary. This should
help address memory leakage vulnerabilities and make other
unrelated vulnerabilities harder to exploit.

Change-Id: I354b425be7bef4713c85f6bab0e9738445e00182
2012-07-13 13:49:59 -07:00
Nick Kralevich
6334c662ca Don't use -fstack-protector on ssp.c
libc's stack protector initialization routine (__guard_setup)
is in bionic/ssp.c. This code deliberately modifies the stack
canary.  This code should never be compiled with -fstack-protector-all
otherwise it will crash (mismatched canary value).

Force bionic/ssp.c to be compiled with -fno-stack-protector

Change-Id: Ib95a5736e4bafe1a460d6b4e522ca660b417d8d6
2012-07-10 10:51:41 -07:00
Nick Kralevich
965dbc6405 FORTIFY_SOURCE: add fgets support.
Change-Id: I8c3410a90c71a3336c4ac8581618fa9330edf5e3
2012-07-09 09:57:18 -07:00
Nick Kralevich
8df49ad246 FORTIFY_SOURCE: add strlcpy / strlcat support
Add strlcpy / strlcat support to FORTIFY_SOURCE. This allows
us to do consistency checks on to ensure we don't overflow buffers
when the compiler is able to tell us the size of the buffer we're
dealing with.

Unlike previous changes, this change DOES NOT use the compiler's
builtin support. Instead, we do everything the compiler would
normally do.

Change-Id: I47c099a911382452eafd711f8e9bfe7c2d0a0d22
2012-06-14 12:52:42 -07:00
Nick Kralevich
9b549c39c9 FORTIFY_SOURCE: add sprintf / vsprintf support
sprintf FORTIFY_SOURCE protections are not available
on clang.

Also add various __attribute__s to stdio functions.

Change-Id: I936d1f9e55fe53a68885c4524b7b59e68fed218d
2012-06-13 09:14:30 -07:00
Nick Kralevich
cffdf6693f FORTIFY_SOURCE: add snprintf, vsnprintf
Add _FORTIFY_SOURCE support for snprintf, vsnprintf

At this time, we opt out of these protections for clang, as clang
does not implement __builtin_va_arg_pack().

http://clang.llvm.org/docs/UsersManual.html#c_unimpl_gcc

Change-Id: I73ebe5ec8dad1dca8898a76d6afb693a25f75375
2012-06-11 16:46:16 -07:00
Nick Kralevich
76656afc6d _FORTIFY_SOURCE: check for integer overflows
Ensure that strcat / strncat check for integer overflows
when computing the length of the resulting string.

Change-Id: Ib806ad33a0d3b50876f384bc17787a28f0dddc37
2012-06-08 20:18:19 -07:00
Nick Kralevich
71a18dd435 _FORTIFY_SOURCE: add memset / bzero support
Add _FORTIFY_SOURCE support for the following functions:

* memset
* bzero

Move the __BIONIC_FORTIFY_INLINE definition to cdefs.h so it
can be used from multiple header files.

Change-Id: Iead4d5e35de6ec97786d58ee12573f9b11135bb7
2012-06-07 14:19:52 -07:00
Elliott Hughes
158ad015c2 am 3069270d: am c2bba24d: Merge "Give the timer_create SIGEV_THREAD helper threads sensible names."
* commit '3069270d8641c7bb57aa308d8f90b4d2dcbf66fc':
  Give the timer_create SIGEV_THREAD helper threads sensible names.
2012-06-06 11:37:25 -07:00
Elliott Hughes
3069270d86 am c2bba24d: Merge "Give the timer_create SIGEV_THREAD helper threads sensible names."
* commit 'c2bba24d0a6b906f00d7b9f20ac9d32d63bb2e9d':
  Give the timer_create SIGEV_THREAD helper threads sensible names.
2012-06-06 11:35:32 -07:00
Elliott Hughes
470631ed79 Give the timer_create SIGEV_THREAD helper threads sensible names.
Bug: 6609676
Change-Id: I286b197c75beee4d9930b0973f2d7dd47c14e91c
2012-06-06 10:32:56 -07:00
Nick Kralevich
204c6e5ff3 Merge "arm: rewrite crtbegin* as C files." 2012-06-06 08:54:22 -07:00
Nick Kralevich
0a2301598c libc: implement some FORTIFY_SOURCE functions
Add initial support for -D_FORTIFY_SOURCE to bionic for the
following functions:

* memcpy
* memmove
* strcpy
* strcat
* strncpy
* strncat

This change adds a new version of the above functions which passes
the size of the destination buffer to __builtin___*_chk.

If the compiler can determine, at compile time, that the destination
buffer is large enough, or the destination buffer can point to an object
of unknown size, then the check call is bypassed.

If the compiler can't make a compile time decision, then it calls
the __*_chk() function, which does a runtime buffer size check

These options are only enabled if the code is compiled with
-D_FORTIFY_SOURCE=1 or 2, and only when optimizations are enabled.

Please see
* http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
* http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html

for additional details on FORTIFY_SOURCE.

Testing: Compiled the entire Android tree with -D_FORTIFY_SOURCE=1,
and verified that everything appears to be working properly.
Also created a test buffer overflow, and verified that it was
caught by this change.

Change-Id: I4fddb445bafe92b16845b22458d72e6dedd24fbc
2012-06-05 15:44:31 -07:00
Iliyan Malchev
31431f454a am 252a5c85: resolved conflicts for merge of e1dd3c28 to jb-dev-plus-aosp
* commit '252a5c854a08e89fc7337ea679220161fe4ea98f':
  bionic: import heaptracker as chk_malloc
2012-06-02 08:35:07 -07:00
Iliyan Malchev
252a5c854a resolved conflicts for merge of e1dd3c28 to jb-dev-plus-aosp
Change-Id: I58b9c13d20771aa39b703ec05cbff8aeaad38fe8
2012-06-02 08:14:36 -07:00
Iliyan Malchev
e1dd3c287b bionic: import heaptracker as chk_malloc
This patch is a rewrite of libc.debug.malloc = 10 (chk_malloc).  It provides
the same features as the original (poison freed memory, detect heap overruns
and underruns), except that it provides more debugging information whenever it
detects a problem.

In addition to the original features, the new chk_malloc() implementation
detects multiple frees within a given range of the last N allocations, N being
configurable via the system property libc.debug.malloc.backlog.

Finally, this patch keeps track of all outstanding memory allocations.  On
program exit, we walk that list and report each outstanding allocation.

(There is support (not enabled) for a scanner thread periodically walks over
the list of outstanding allocations as well as the backlog of recently-freed
allocations, checking for heap-usage errors.)

Feature overview:

  1) memory leaks
  2) multiple frees
  3) use after free
  4) overrun

Implementation:

-- for each allocation, there is a:
  1) stack trace at the time the allocation is made
  2) if the memory is freed, there is also a stack trace at the point
  3) a front and rear guard (fence)
  4) the stack traces are kept together with the allocation

-- the following lists and maintained

  1) all outstanding memory allocations
  3) a backlog of allocations what are freed; when you call free(), instead of
     actually freed, the allocation is moved to this backlog;
  4) when the backlog of allocations gets full, the oldest entry gets evicted
     from it; at that point, the allocation is checked for overruns or
     use-after-free errors, and then actually freed.
  5) when the program exits, the list of outstanding allocations and the
     backlog are inspected for errors, then freed;

To use this, set the following system properties before running the process or
processes you want to inspect:

libc.malloc.debug.backlog # defaults to 100
libc.malloc.debug 10

When a problem is detected, you will see the following on logcat for a multiple
free:

E/libc    ( 7233): +++ ALLOCATION 0x404b9278 SIZE 10 BYTES MULTIPLY FREED!
E/libc    ( 7233): +++ ALLOCATION 0x404b9278 SIZE 10 ALLOCATED HERE:
E/libc    ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc    ( 7233):      #00  pc 0000c35a  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #01  pc 0000c658  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #02  pc 00016d80  /system/lib/libc.so
E/libc    ( 7233):      #03  pc 4009647c  /system/bin/malloctest
E/libc    ( 7233):      #04  pc 00016f24  /system/lib/libc.so
E/libc    ( 7233): +++ ALLOCATION 0x404b9278 SIZE 10 FIRST FREED HERE:
E/libc    ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc    ( 7233):      #00  pc 0000c35a  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #01  pc 0000c7d2  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #02  pc 00016d94  /system/lib/libc.so
E/libc    ( 7233):      #03  pc 40096490  /system/bin/malloctest
E/libc    ( 7233):      #04  pc 00016f24  /system/lib/libc.so
E/libc    ( 7233): +++ ALLOCATION 0x404b9278 SIZE 10 NOW BEING FREED HERE:
E/libc    ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc    ( 7233):      #00  pc 0000c35a  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #01  pc 0000c6ac  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #02  pc 00016d94  /system/lib/libc.so
E/libc    ( 7233):      #03  pc 400964a0  /system/bin/malloctest
E/libc    ( 7233):      #04  pc 00016f24  /system/lib/libc.so

The following for a heap overrun and underrun:

E/libc    ( 7233): +++ REAR GUARD MISMATCH [10, 11)
E/libc    ( 7233): +++ ALLOCATION 0x404b9198 SIZE 10 HAS A CORRUPTED REAR GUARD
E/libc    ( 7233): +++ ALLOCATION 0x404b9198 SIZE 10 ALLOCATED HERE:
E/libc    ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc    ( 7233):      #00  pc 0000c35a  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #01  pc 0000c658  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #02  pc 00016d80  /system/lib/libc.so
E/libc    ( 7233):      #03  pc 40096438  /system/bin/malloctest
E/libc    ( 7233):      #04  pc 00016f24  /system/lib/libc.so
E/libc    ( 7233): +++ ALLOCATION 0x404b9198 SIZE 10 FREED HERE:
E/libc    ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc    ( 7233):      #00  pc 0000c35a  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #01  pc 0000c7d2  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #02  pc 00016d94  /system/lib/libc.so
E/libc    ( 7233):      #03  pc 40096462  /system/bin/malloctest
E/libc    ( 7233):      #04  pc 00016f24  /system/lib/libc.so
E/libc    ( 7233): +++ ALLOCATION 0x404b9358 SIZE 10 HAS A CORRUPTED FRONT GUARD
E/libc    ( 7233): +++ ALLOCATION 0x404b9358 SIZE 10 ALLOCATED HERE:
E/libc    ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc    ( 7233):      #00  pc 0000c35a  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #01  pc 0000c658  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #02  pc 00016d80  /system/lib/libc.so
E/libc    ( 7233):      #03  pc 400964ba  /system/bin/malloctest
E/libc    ( 7233):      #04  pc 00016f24  /system/lib/libc.so
E/libc    ( 7233): +++ ALLOCATION 0x404b9358 SIZE 10 FREED HERE:
E/libc    ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc    ( 7233):      #00  pc 0000c35a  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #01  pc 0000c7d2  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #02  pc 00016d94  /system/lib/libc.so
E/libc    ( 7233):      #03  pc 400964e4  /system/bin/malloctest
E/libc    ( 7233):      #04  pc 00016f24  /system/lib/libc.so

The following for a memory leak:

E/libc    ( 7233): +++ THERE ARE 1 LEAKED ALLOCATIONS
E/libc    ( 7233): +++ DELETING 4096 BYTES OF LEAKED MEMORY AT 0x404b95e8 (1 REMAINING)
E/libc    ( 7233): +++ ALLOCATION 0x404b95e8 SIZE 4096 ALLOCATED HERE:
E/libc    ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc    ( 7233):      #00  pc 0000c35a  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #01  pc 0000c658  /system/lib/libc_malloc_debug_leak.so
E/libc    ( 7233):      #02  pc 00016d80  /system/lib/libc.so
E/libc    ( 7233):      #03  pc 0001bc94  /system/lib/libc.so
E/libc    ( 7233):      #04  pc 0001edf6  /system/lib/libc.so
E/libc    ( 7233):      #05  pc 0001b80a  /system/lib/libc.so
E/libc    ( 7233):      #06  pc 0001c086  /system/lib/libc.so
E/libc    ( 7233):      #07  pc 40096402  /system/bin/malloctest
E/libc    ( 7233):      #08  pc 00016f24  /system/lib/libc.so

Change-Id: Ic440e9d05a01e2ea86b25e8998714e88bc2d16e0
Signed-off-by: Iliyan Malchev <malchev@google.com>
2012-06-01 15:54:34 -07:00
Nick Kralevich
9d40326830 arm: rewrite crtbegin* as C files.
Rewrite
 crtbegin.S     -> crtbegin.c
 crtbegin_so.S  -> crtbegin_so.c

This change allows us to generate PIC code without relying
on text relocations.

As a consequence of this rewrite, also rewrite
  __dso_handle.S    -> __dso_handle.c
  __dso_handle_so.S -> __dso_handle_so.c
  atexit.S          -> atexit.c

In crtbegin.c _start, place the __PREINIT_ARRAY__, __INIT_ARRAY__,
__FINI_ARRAY__, and __CTOR_LIST__ variables onto the stack, instead of
passing a pointer to the text section of the binary.

This change appears sorta wonky, as I attempted to preserve,
as much as possible, the structure of the original assembly.
As a result, you have C files including other C files, and other
programming uglyness.

Result: This change reduces the number of files with text-relocations
from 315 to 19 on my Android build.

Before:
  $ scanelf -aR $OUT/system | grep TEXTREL | wc -l
  315

After:
  $ scanelf -aR $OUT/system | grep TEXTREL | wc -l
  19

Change-Id: Ib9f98107c0eeabcb606e1ddc7ed7fc4eba01c9c4
2012-06-01 14:41:27 -07:00
Nick Kralevich
83a73d1afe crtbegin: eliminate duplicate code
crtbegin_dynamic and crtbegin_static are essentially identical,
minus a few trivial differences (comments and whitespace).

Eliminate duplicates.

Change-Id: Ic9fae6bc9695004974493b53bfc07cd3bb904480
2012-05-30 11:45:12 -07:00
Ying Wang
fc9e525fe0 Rename the misleading var name TARGET_OUT_STATIC_LIBRARIES
TARGET_OUT_STATIC_LIBRARIES is actually the same as
TARGET_OUT_INTERMEDIATE_LIBRARIES.

Change-Id: I11ac35256031d461d20156cd4c19ed7eae781d22
2012-05-15 15:15:11 -07:00
Iliyan Malchev
83a38b8c44 am 8034415d: resolved conflicts for merge of 08e72d01 to jb-dev-plus-aosp
* commit '8034415ddd8404f8788199ed993af89692235dc5':
  bionic: add support for non-NEON memcpy() on NEON SoCs
2012-05-10 09:24:46 -07:00
Iliyan Malchev
8034415ddd resolved conflicts for merge of 08e72d01 to jb-dev-plus-aosp
Change-Id: If00e354a5953ed54b31963d4f8ea77e1603c321e
2012-05-10 09:19:59 -07:00
Prajakta Gudadhe
08e72d0161 bionic: add support for non-NEON memcpy() on NEON SoCs
Some SoCs that support NEON nevertheless perform better with a non-NEON than a
NEON memcpy().  This patch adds build variable ARCH_ARM_USE_NON_NEON_MEMCPY,
which can be set in BoardConfig.mk.  When ARCH_ARM_USE_NON_NEON_MEMCPY is
defined, we compile in the non-NEON optimized memcpy() even if the SoC supports
NEON.

Change-Id: Ia0e5bee6bad5880ffc5ff8f34a1382d567546cf9
2012-05-09 13:34:31 -07:00
Elliott Hughes
fd8bd2c432 am 58a00b49: am 7eb1cc23: Merge "bionic: allow the board to customize MALLOC_ALIGNMENT"
* commit '58a00b4977b6fa073a8f56d94d741b1e4cb49856':
  bionic: allow the board to customize MALLOC_ALIGNMENT
2012-05-09 12:56:15 -07:00
Elliott Hughes
58a00b4977 am 7eb1cc23: Merge "bionic: allow the board to customize MALLOC_ALIGNMENT"
* commit '7eb1cc23f8976a2062ba0cf92f030216a8e64e60':
  bionic: allow the board to customize MALLOC_ALIGNMENT
2012-05-09 12:53:16 -07:00
Jack Ren
2fd81ef71c bionic: allow the board to customize MALLOC_ALIGNMENT
Currently the dlmalloc allocates the memory with 8-byte alignment.
According to the com.aurorasoftworks.quadrant.ui.professional benchmark data:
We can get much better memory performance if we change it to be 16-byte aligned.
For example, On Nexus-S:
8-byte aligned :
    1378 1070  1142 1665 1765  1163 1179  1263  1404 avg: 1336.555555556
16-byte aligned:
    1691 1731  1780 1691 1671  1678 1802  1758  1780 avg: 1731.333333333
                                                    gain: 29.53%

That patch provides flexibity to customize the MALLOC_ALIGNMENT from the
board config.The macro MALLOC_ALIGNMENT defaults to 8.
To change it, please define BOARD_MALLOC_ALIGNMENT in the BoardConfig.mk:
BOARD_MALLOC_ALIGNMENT := <whatever>

Change-Id: I8da0376944a0bbcef1d0fc026bfb6d9125db9739
Signed-off-by: Jin Wei <wei.a.jin@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Signed-off-by: Beare, Bruce J <bruce.j.beare@intel.com>
2012-05-09 09:52:22 -07:00
Ben Cheng
da0d8534f1 am 08b51e2c: Implement the "abort" stub in assembly for ARM.
* commit '08b51e2c091d036c124259ae59eb7be6bbe346af':
  Implement the "abort" stub in assembly for ARM.
2012-05-09 01:48:40 -07:00
Ben Cheng
eda7be454d Implement the "abort" stub in assembly for ARM.
So that we can always get the full stack trace regardless of gcc's handling
of the "noreturn" attribute associated with abort().

(Cherry pick of Id264a5167e7cabbf11515fbc48f5469c527e34d4.)

Bug: 6455193

Conflicts:

	libc/Android.mk

Change-Id: I568fc5303fd1d747075ca933355f914122f94dac
2012-05-08 14:47:20 -07:00
Ben Cheng
08b51e2c09 Implement the "abort" stub in assembly for ARM.
So that we can always get the full stack trace regardless of gcc's handling
of the "noreturn" attribute associated with abort().

[cherry-picked from master]

BUG:6455193
Change-Id: I0102355f5bf20e636d3feab9d1424495f38e39e2
2012-05-08 14:39:35 -07:00
Ben Cheng
12cbf0605e Merge "Implement the "abort" stub in assembly for ARM." 2012-05-08 14:01:22 -07:00
Ben Cheng
017f438534 Implement the "abort" stub in assembly for ARM.
So that we can always get the full stack trace regardless of gcc's handling
of the "noreturn" attribute associated with abort().

BUG:6455193
Change-Id: Id264a5167e7cabbf11515fbc48f5469c527e34d4
2012-05-08 13:43:12 -07:00