OSDN Git Service

android-x86/bionic.git
9 years agoLook into ld_preloads before current library
Dmitriy Ivanov [Fri, 29 Aug 2014 17:15:25 +0000 (10:15 -0700)]
Look into ld_preloads before current library

 Change lookup order during relocation so that
 ld_preloads always precede caller (unless caller
 is main executable).

 Asan needs this change in order to intercept libc->libc
 calls.

Bug: 15432753
Change-Id: If69aa16efe59aa35bb30e96feb83d08f1efbec86

9 years agoHave pthread_attr_getstack for the main thread report RLIMIT_STACK...
Elliott Hughes [Wed, 27 Aug 2014 22:32:01 +0000 (15:32 -0700)]
Have pthread_attr_getstack for the main thread report RLIMIT_STACK...

...rather than just what's already mapped in. This seems somewhat
contrary to POSIX's "All pages within the stack described by stackaddr
and stacksize shall be both readable and writable by the thread", but
it's what glibc does.

Bug: 17111575

(cherry picked from commit 9e4ffa7032eaab308876b8e3da86b05c3c613878)

Change-Id: I73f219a569917b2e4546c09436d7ef5231facc07

9 years agoMerge "Fix pthread_getattr_np for the main thread." into lmp-dev
Elliott Hughes [Wed, 27 Aug 2014 23:49:56 +0000 (23:49 +0000)]
Merge "Fix pthread_getattr_np for the main thread." into lmp-dev

9 years agoMerge "Replace snprintf calls in linker." into lmp-dev
Christopher Ferris [Wed, 27 Aug 2014 22:42:11 +0000 (22:42 +0000)]
Merge "Replace snprintf calls in linker." into lmp-dev

9 years agoReplace snprintf calls in linker.
Christopher Ferris [Wed, 27 Aug 2014 03:48:11 +0000 (20:48 -0700)]
Replace snprintf calls in linker.

When enabling debug malloc, the snprintf calls in the linker fails to
update the buffer.

The problem is that snprintf makes a call to pthread_getspecific that
returns a valid pointer, but the data it points to is zero. This should
never happen and causes the snprintf to stop and do nothing.

Temporarily replace snprintf with a different implementation to work
around this issue.

Bug: 16874447
Bug: 17302493
Change-Id: I7a500f28adf153150cf2812fae745ff41f1c48d3

9 years agoMerge "call uselocale() before freelocale() to make sure that g_local_key has a valid...
Elliott Hughes [Wed, 27 Aug 2014 17:25:23 +0000 (17:25 +0000)]
Merge "call uselocale() before freelocale() to make sure that g_local_key has a valid locale." into lmp-dev

9 years agocall uselocale() before freelocale() to make sure that g_local_key has a valid locale.
Wally Yau [Tue, 26 Aug 2014 16:47:23 +0000 (09:47 -0700)]
call uselocale() before freelocale() to make sure that g_local_key has a valid locale.

For tests that call uselocale(), the locale is stored in the
g_userlocale_key thread-specific key. If freelocale() is called later,
then g_uselocal_key points to a deleted pointer. CTS eventually calls
vfprintf to print the result, which calls MB_CUR_MAX and MB_CUR_MAX
accesses the deleted locale stored in g_uselocale_key, causing unpredictable
errors.

Fixed the tests by calling uselocale() with the old locale before
calling freelocale.

Bug: 17299565
Change-Id: I87efa2a9b16999a11d587f68d3aeedcbe6ac8a2c

9 years agoUse the default unwind code.
Christopher Ferris [Tue, 26 Aug 2014 22:47:42 +0000 (15:47 -0700)]
Use the default unwind code.

This speeds up the debug malloc code by using the original unwinding code.
The only catch is that it has to link in the libc++ arm unwind code or
there will be crashes when attempting to unwind through libc++ compiled
code.

Bug: 16874447
Change-Id: Ifdbbcbd4137d668b25cf3c2bd59535e06ebfa5a7

9 years agoFix pthread_getattr_np for the main thread.
Elliott Hughes [Tue, 26 Aug 2014 00:26:50 +0000 (17:26 -0700)]
Fix pthread_getattr_np for the main thread.

On most architectures the kernel subtracts a random offset to the stack
pointer in create_elf_tables by calling arch_align_stack before writing
the auxval table and so on. On all but x86 this doesn't cause a problem
because the random offset is less than a page, but on x86 it's up to two
pages. This means that our old technique of rounding the stack pointer
doesn't work. (Our old implementation of that technique was wrong too.)

It's also incorrect to assume that the main thread's stack base and size
are constant. Likewise to assume that the main thread has a guard page.
The main thread is not like other threads.

This patch switches to reading /proc/self/maps (and checking RLIMIT_STACK)
whenever we're asked.

Bug: 17111575
Signed-off-by: Fengwei Yin <fengwei.yin@intel.com>
(cherry picked from commit 57b7a6110e7e8b446fc23cce4765ff625ee0a105)

Change-Id: I87e679ee1c0db8092f2d1221c8e7c1461545c5a4

9 years agoFix unistd.getpid_caching_and_clone.
Elliott Hughes [Fri, 22 Aug 2014 02:23:53 +0000 (19:23 -0700)]
Fix unistd.getpid_caching_and_clone.

This test only works if you're root (strictly: if you have permission to
CLONE_NEWNS), so it's useful to us when we're doing ad hoc testing (since
that's usually done as root), but it's not useful as part of CTS or when
running the tests on the host.

Bug: 16705621
Bug: 17170200
Change-Id: Ia92c871b15f7e45fc174bb59bc95540fd00ae745

9 years agoFix some 32-bit-isms in <stdio.h>.
Elliott Hughes [Wed, 20 Aug 2014 19:14:21 +0000 (12:14 -0700)]
Fix some 32-bit-isms in <stdio.h>.

Bug: 17157793
Change-Id: I8290e240b92e5617f4c12c0eacad6e622e677b6a

9 years agoExpose android_set_abort_message().
Dan Albert [Mon, 18 Aug 2014 21:37:42 +0000 (14:37 -0700)]
Expose android_set_abort_message().

Removes the leading underscores from __android_set_abort_message() and
moves its declaration into a public header file.

Bug: 17059126
Change-Id: I470c79db47ec783ea7a54b800f8b78ecbe7479ab
(cherry picked from commit ce6b1abbb1da797e716d8ec03da4e3b6304fd11d)
(cherry picked from commit 3a25ab952befbe908f6df45805683ebe3bf65863)

9 years agoMerge "Revert "Add support for protected local symbol lookup."" into lmp-dev
Dmitriy Ivanov [Tue, 19 Aug 2014 12:14:39 +0000 (12:14 +0000)]
Merge "Revert "Add support for protected local symbol lookup."" into lmp-dev

9 years agoRevert "Add support for protected local symbol lookup."
Dmitriy Ivanov [Mon, 18 Aug 2014 22:08:51 +0000 (15:08 -0700)]
Revert "Add support for protected local symbol lookup."

This reverts commit d97e9f546ea195686a78e539315b273393609b9e.

Bug: 17107521
Change-Id: I2b81ce2b5a4a2d166133a2626e49d81b6aef3672

9 years agoHide C++ stuff in libc. Put it back in libstdc++.
Dan Albert [Fri, 15 Aug 2014 21:20:04 +0000 (14:20 -0700)]
Hide C++ stuff in libc. Put it back in libstdc++.

Bug: 17062445
Change-Id: I027b186719654c2865b08c3fa83f90fa00c1e838
(cherry picked from commit fd5ee9aebc0a43c7f36a0778c7f416b39ddb870e)

9 years agoMerge "Fix leak_realloc, copy entire allocation." into lmp-dev
Christopher Ferris [Mon, 18 Aug 2014 18:57:39 +0000 (18:57 +0000)]
Merge "Fix leak_realloc, copy entire allocation." into lmp-dev

9 years agoFix leak_realloc, copy entire allocation.
Christopher Ferris [Sat, 16 Aug 2014 01:42:58 +0000 (18:42 -0700)]
Fix leak_realloc, copy entire allocation.

Bug: 16874447
Change-Id: Ie54a73fd75529961195fa5173d9116d0ae897b03

9 years agoMerge "Keep symbols for linker" into lmp-dev
Dmitriy Ivanov [Fri, 15 Aug 2014 21:29:48 +0000 (21:29 +0000)]
Merge "Keep symbols for linker" into lmp-dev

9 years agoKeep symbols for linker
Dmitriy Ivanov [Thu, 14 Aug 2014 22:46:36 +0000 (15:46 -0700)]
Keep symbols for linker

Bug: 17011146

(cherry picked from commit ad5e8b50737144833233d47fe04deb3fa0284df2)

Change-Id: Ib1d3f8d6d38af98586658e01ed1ec79d2c5b4d42

9 years agoHave stdatomic.h punt to C++ atomic when possible
Hans Boehm [Thu, 14 Aug 2014 22:26:03 +0000 (15:26 -0700)]
Have stdatomic.h punt to C++ atomic when possible

This is an alternate, somewhat simpler, fix that makes it safe to
include both <atomic> and <stdatomic.h> from C++ code in either order.
It means that C code consistently uses one implementation of atomics
and C++ another.  We still have to make sure that those two
implementations interoperate correctly at runtime; in particular,
any flavor of atomic object needs to be represented exactly like the
underlying type, with the proper alignment constraint.

Bug:17007799
Change-Id: Iffcfc5220d8fa150f89dd083a121b24d23f268fc
(cherry picked from commit 019d3958118b7dc3ec8444ad2accca50c268b737)

9 years agoMerge "Change name of MB_CUR_MAX implementation function." into lmp-dev
Dan Albert [Fri, 15 Aug 2014 01:14:19 +0000 (01:14 +0000)]
Merge "Change name of MB_CUR_MAX implementation function." into lmp-dev

9 years agoChange name of MB_CUR_MAX implementation function.
Dan Albert [Thu, 14 Aug 2014 20:56:51 +0000 (13:56 -0700)]
Change name of MB_CUR_MAX implementation function.

Glibc calls theirs __ctype_get_mb_cur_max. Make ours match to cut down
on differences between bionic and glibc.

Bug: 11156955
Change-Id: Ib7231f01aa9676dff30aea0af25d597bfe07bc73

9 years agoMerge "Move mtctxres.c to libc_dns.a." into lmp-dev
Dan Albert [Fri, 15 Aug 2014 01:14:13 +0000 (01:14 +0000)]
Merge "Move mtctxres.c to libc_dns.a." into lmp-dev

9 years agoMove mtctxres.c to libc_dns.a.
Dan Albert [Thu, 14 Aug 2014 22:43:25 +0000 (15:43 -0700)]
Move mtctxres.c to libc_dns.a.

Has the effect of making ___mtctxres hidden.

Bug: 11156955
Change-Id: I5aa5f49344ad5ecb33f48737430561b329bcbb0d
(cherry picked from commit 891ec7a6e46e60d7dfa1cf229e14a8e8634e272b)

9 years agoMerge "malloc_usable_size returns the original size." into lmp-dev
Christopher Ferris [Thu, 14 Aug 2014 21:43:11 +0000 (21:43 +0000)]
Merge "malloc_usable_size returns the original size." into lmp-dev

9 years agomalloc_usable_size returns the original size.
Christopher Ferris [Thu, 14 Aug 2014 19:48:04 +0000 (12:48 -0700)]
malloc_usable_size returns the original size.

Bug: 16874447
Change-Id: Ie3ce683fd1f58b837b8ea91dc798e561b8593356

9 years agoLabel pages mapped by linker_allocator
Dmitriy Ivanov [Fri, 8 Aug 2014 23:57:15 +0000 (16:57 -0700)]
Label pages mapped by linker_allocator

(cherry picked from commit 51a22a12ab370933a35463f5c81223132ec64dcb)

Bug: 17013324
Change-Id: I345c9d0fecc29d3626c5be01cc3c0ed1583ac361

9 years agoOptimize symbol lookup
Dmitriy Ivanov [Wed, 13 Aug 2014 04:02:13 +0000 (21:02 -0700)]
Optimize symbol lookup

 Do not run symbol lookup on already visited soinfos
 Not taking into account already visited libraries
 dramatically slows down dlsym in cases when there
 are multiple occurrences of a large library in
 dependency tree.

Bug: 16977077

(cherry picked from commit 042426ba6375f5c145379e598486ec6d675533c9)

Change-Id: I69d59e395e8112f119343e8a4d72fe31cd449f31

9 years agoHide __libc_malloc_dispatch.
Dan Albert [Tue, 12 Aug 2014 23:21:26 +0000 (16:21 -0700)]
Hide __libc_malloc_dispatch.

Now that -Bsymbolic is fixed, we can hide __libc_malloc_dispatch without
breaking ASAN.

Bug: 11156955
Change-Id: Ia2fc9b046a74e666b33aa6c6c5435f70a63b8021

9 years agoFix our x86 PIC_PROLOGUE.
Elliott Hughes [Sun, 10 Aug 2014 01:45:55 +0000 (18:45 -0700)]
Fix our x86 PIC_PROLOGUE.

The old definition only worked for functions that didn't use numbered
local labels. Upstream uses '666' not only as some kind of BSD in-joke,
but also because there's little likelihood of any function having
labels that high.

There's a wider question about whether we actually want to go via the
PLT at all in this code, but that's a question for another day.

Bug: 16906712
Change-Id: I3cd8ecc448b33f942bb6e783931808ef39091489

9 years agoMerge "Make __set_errno hidden in asm." into lmp-dev
Dan Albert [Sat, 9 Aug 2014 06:45:48 +0000 (06:45 +0000)]
Merge "Make __set_errno hidden in asm." into lmp-dev

9 years agoMake __set_errno hidden in asm.
Dan Albert [Fri, 8 Aug 2014 22:19:20 +0000 (15:19 -0700)]
Make __set_errno hidden in asm.

This fixes the build after the -Bsymbolic change.

Bug: 16853291
Change-Id: I989c9fec3c32e0289ea257a3bd2b7fd2709b6ce2
(cherry picked from commit bc9f9f25bf1247a6a638a2a2df8441bdd9fabad7)

9 years agoAdd a way to disable backtracing in malloc debug.
Christopher Ferris [Thu, 7 Aug 2014 23:21:21 +0000 (16:21 -0700)]
Add a way to disable backtracing in malloc debug.

The property libc.debug.malloc.nobacktrace set to non-zero disables
getting backtracing when using mode 1 or mode 10.

Bug: 16874447

Change-Id: I7650ba9f4385b5110b743cab01e877fc69545b3c

9 years agoAndroid is all-PIC/PIE.
Elliott Hughes [Thu, 7 Aug 2014 17:51:32 +0000 (10:51 -0700)]
Android is all-PIC/PIE.

Clean up the x86/x86_64 assembler. The motivator (other than reducing
confusion) was that asm.h incorrectly checked PIC rather than __PIC__.

Bug: 16823325

(cherry picked from commit 6b6364a7fc7c3ba37ee907776a29bdc8c9793db9)

Change-Id: I89ca57fa0eb34a36de6cb11ea85f71054fce709d

9 years agoMerge "Do a second key cleanup in pthread_exit." into lmp-dev
Christopher Ferris [Thu, 7 Aug 2014 00:52:19 +0000 (00:52 +0000)]
Merge "Do a second key cleanup in pthread_exit." into lmp-dev

9 years agoDo a second key cleanup in pthread_exit.
Christopher Ferris [Wed, 6 Aug 2014 21:15:01 +0000 (14:15 -0700)]
Do a second key cleanup in pthread_exit.

During pthread_exit, the keys are cleaned. Unfortunately, a call to
free occurs after the cleanup and the memory for some of the keys
is recreated when using jemalloc. The solution is to do the key
cleanup twice.

Also, modify the pthread_detach__leak test to be less flaky
when run on a jemalloc system.

Bug: 16513133
Change-Id: Ic17e8344bdc1ba053c4f5b6d827a4c19c57860c1

9 years agoMerge "Upgrade bionic to tzdata2014f." into lmp-dev
Elliott Hughes [Thu, 7 Aug 2014 00:36:48 +0000 (00:36 +0000)]
Merge "Upgrade bionic to tzdata2014f." into lmp-dev

9 years agoMerge "Fix the tzdata update tools." into lmp-dev
Elliott Hughes [Thu, 7 Aug 2014 00:29:43 +0000 (00:29 +0000)]
Merge "Fix the tzdata update tools." into lmp-dev

9 years agoFix the tzdata update tools.
Elliott Hughes [Wed, 6 Aug 2014 22:23:11 +0000 (15:23 -0700)]
Fix the tzdata update tools.

The recent libcore ZoneInfo changes mean that we can no longer
compile libcore's ZoneInfo against the RI. Luckily, the field in
our data file that we needed ZoneInfo for isn't actually used.
This change removes our dependence on libcore.

I've left the field in to avoid a file format change. We can remove
the field if/when we next have a real need to bump the file format.

Bug: 16168653
Change-Id: Iedad2252c2b49f4d8bb2c7d9078b39b622444ca7

9 years agoUpgrade bionic to tzdata2014f.
Elliott Hughes [Wed, 6 Aug 2014 22:26:13 +0000 (15:26 -0700)]
Upgrade bionic to tzdata2014f.

From the release notes:

  Changes affecting future time stamps

    Russia will subtract an hour from most of its time zones on
    2014-10-26 at 02:00 local time.  (Thanks to Alexander Krivenyshev.)
    There are a few exceptions: Magadan Oblast (Asia/Magadan) and
    Zabaykalsky Krai are subtracting two hours; conversely, Chukotka
    Autonomous Okrug (Asia/Anadyr), Kamchatka Krai (Asia/Kamchatka),
    Kemerovo Oblast (Asia/Novokuznetsk), and the Samara Oblast and the
    Udmurt Republic (Europe/Samara) are not changing their clocks.  The
    changed zones are Europe/Kaliningrad, Europe/Moscow,
    Europe/Simferopol, Europe/Volgograd, Asia/Yekaterinburg, Asia/Omsk,
    Asia/Novosibirsk, Asia/Krasnoyarsk, Asia/Irkutsk, Asia/Yakutsk,
    Asia/Vladivostok, Asia/Khandyga, Asia/Sakhalin, and Asia/Ust-Nera;
    Asia/Magadan will have two hours subtracted; and Asia/Novokuznetsk's
    time zone abbreviation is affected, but not its UTC offset.  Two
    zones are added: Asia/Chita (split from Asia/Yakutsk, and also with
    two hours subtracted) and Asia/Srednekolymsk (split from
    Asia/Magadan, but with only one hour subtracted).  (Thanks to Tim
    Parenti for much of the above.)

  Changes affecting past time stamps

    China's five zones have been simplified to two, since the post-1970
    differences in the other three seem to have been imaginary.  The
    zones Asia/Harbin, Asia/Chongqing, and Asia/Kashgar have been
    removed; backwards-compatibility links still work, albeit with
    different behaviors for time stamps before May 1980.  Asia/Urumqi's
    1980 transition to UTC+8 has been removed, so that it is now at
    UTC+6 and not UTC+8.  (Thanks to Luther Ma and to Alois Treindl;
    Treindl sent helpful translations of two papers by Guo Qingsheng.)

    Some zones have been turned into links, when they differed from
    existing zones only for older UTC offsets where the data were likely
    invented.  These changes affect UTC offsets in pre-1970 time stamps
    only.  This is similar to the change in release 2013e, except this
    time for western Africa.  The affected zones are: Africa/Bamako,
    Africa/Banjul, Africa/Conakry, Africa/Dakar, Africa/Freetown,
    Africa/Lome, Africa/Nouakchott, Africa/Ouagadougou, Africa/Sao_Tome,
    and Atlantic/St_Helena.  This also affects the
    backwards-compatibility link Africa/Timbuktu.  (Thanks to Alan
    Barrett, Stephen Colebourne, Tim Parenti, and David Patte for
    reporting problems in earlier versions of this change.)

    Asia/Shanghai's pre-standard-time UT offset has been changed from
    8:05:57 to 8:05:43, the location of Xujiahui Observatory.  Its
    transition to standard time has been changed from 1928 to 1901.

    Asia/Taipei switched to JWST on 1896-01-01, then to JST on
    1937-10-01, then to CST on 1945-09-21 at 01:00, and did not observe
    DST in 1945.  In 1946 it observed DST from 05-15 through 09-30; in
    1947 from 04-15 through 10-31; and in 1979 from 07-01 through 09-30.
    (Thanks to Yu-Cheng Chuang.)

    Asia/Riyadh's transition to standard time is now 1947-03-14, not
    1950.

    Europe/Helsinki's 1942 fall-back transition was 10-04 at 01:00, not
    10-03 at 00:00.  (Thanks to Konstantin Hyppönen.)

    Pacific/Pago_Pago has been changed from UTC-11:30 to UTC-11 for the
    period from 1911 to 1950.

    Pacific/Chatham has been changed to New Zealand standard time plus
    45 minutes for the period before 1957, reflecting a 1956 remark in
    the New Zealand parliament.

    Europe/Budapest has several pre-1946 corrections: in 1918 the
    transition out of DST was on 09-16, not 09-29; in 1919 it was on
    11-24, not 09-15; in 1945 it was on 11-01, not 11-03; in 1941 the
    transition to DST was 04-08 not 04-06 at 02:00; and there was no DST
    in 1920.

    Africa/Accra is now assumed to have observed DST from 1920 through
    1935.

    Time in Russia before 1927 or so has been corrected by a few seconds
    in the following zones: Europe/Moscow, Asia/Irkutsk, Asia/Tbilisi,
    Asia/Tashkent, Asia/Vladivostok, Asia/Yekaterinburg,
    Europe/Helsinki, and Europe/Riga.  Also, Moscow's location has been
    changed to its Kilometer 0 point.  (Thanks to Vladimir Karpinsky for
    the Moscow changes.)

Bug: 16168653
Change-Id: I23827254bcf50dd07a2192ed34b02224d73e07a0

9 years agoMerge "Proper MB_CUR_MAX." into lmp-dev
Dan Albert [Wed, 6 Aug 2014 21:09:52 +0000 (21:09 +0000)]
Merge "Proper MB_CUR_MAX." into lmp-dev

9 years agoProper MB_CUR_MAX.
Dan Albert [Wed, 30 Jul 2014 17:53:48 +0000 (10:53 -0700)]
Proper MB_CUR_MAX.

Previously this was hard coded to 4. This is only the case for UTF-8
locales.

As a side effect, this properly reports C.UTF-8 as the default locale
instead of C.

Change-Id: I7c73cc8fe6ffac61d211cd5f75287e36de06f4fc
(cherry picked from commit 1aec7c1a35b2d03038b194967d5ebdc8e2c24b80)

9 years agoMerge "Fix mbsrtowcs(3) src param for finished string." into lmp-dev
Dan Albert [Wed, 6 Aug 2014 21:09:35 +0000 (21:09 +0000)]
Merge "Fix mbsrtowcs(3) src param for finished string." into lmp-dev

9 years agoFix mbsrtowcs(3) src param for finished string.
Dan Albert [Thu, 31 Jul 2014 18:31:03 +0000 (11:31 -0700)]
Fix mbsrtowcs(3) src param for finished string.

A mistake I made while cleaning this up the first time through.
mbstrtowcs(3) sets the src param to null if it finishes the string.

Change-Id: I6263646e25d9537043b7025fd1dd6ae195f365e2
(cherry picked from commit b6cc8e00cd562bd0f81fe44a6bc646540a862f32)

9 years agoFixes build.
Dan Albert [Tue, 5 Aug 2014 21:46:03 +0000 (14:46 -0700)]
Fixes build.

This change somehow went missing from the vfork change.

Change-Id: I807a2072080eac20601c694e85ba5723220289d8
(cherry picked from commit 9eae8405e8f70e489f2fe350a0212ab8114cbd17)

9 years agoRevert "Replaces vfork() implementation with fork()"
Dan Albert [Tue, 5 Aug 2014 20:53:31 +0000 (20:53 +0000)]
Revert "Replaces vfork() implementation with fork()"

We're getting cold feet on this one... let's put it back.

This reverts commit 210331d9762037afb9b5ed8413079c6f65872df9.

Change-Id: I6b0d3c2b1dbf7f1dc9566979a91b7504c2189269
(cherry picked from commit 6a918870bab1a55a5f57dd7954abd9a8a27c1bc2)

9 years agoMerge "Workaround b/16818336 which fails build under aggressive inlining." into lmp-dev
Elliott Hughes [Wed, 6 Aug 2014 18:43:19 +0000 (18:43 +0000)]
Merge "Workaround b/16818336 which fails build under aggressive inlining." into lmp-dev

9 years agoWorkaround b/16818336 which fails build under aggressive inlining.
Dehao Chen [Tue, 5 Aug 2014 22:23:00 +0000 (15:23 -0700)]
Workaround b/16818336 which fails build under aggressive inlining.

Change-Id: Ifcd596714c427a2ec39502b9c0af9082ded91884

9 years agoMerge "Revert most of "Cleanup: Delete dead code."" into lmp-dev
Paul Jensen [Wed, 6 Aug 2014 18:32:02 +0000 (18:32 +0000)]
Merge "Revert most of "Cleanup: Delete dead code."" into lmp-dev

9 years agoExplain how wcswcs ended up in ndk_cruft.cpp.
Elliott Hughes [Wed, 6 Aug 2014 17:47:33 +0000 (10:47 -0700)]
Explain how wcswcs ended up in ndk_cruft.cpp.

(cherry picked from commit 1628eb1d43008c52b00ec98d10c4fd9e8b6fc7c5)

Change-Id: I335b35038781d0426b3647727e6c4f22c83e187b

9 years agoRevert most of "Cleanup: Delete dead code."
Paul Jensen [Wed, 6 Aug 2014 17:34:22 +0000 (17:34 +0000)]
Revert most of "Cleanup: Delete dead code."

This reverts most of commit 2582f02a01cd56c56a4e6c9de4444a6ec937cc37.
The DNS cache flushing code needs to be called when routes change.

Change-Id: I5b04121bc428cc6a2e136b6c3269c395bfb4981f
bug:16549455

9 years agoRevert "Revert "Fix dlsym(3) to do breadth first search.""
Dmitriy Ivanov [Mon, 4 Aug 2014 23:39:22 +0000 (23:39 +0000)]
Revert "Revert "Fix dlsym(3) to do breadth first search.""

This reverts commit 1b1966d9448e979d1503a3d8843708bfa8880dc6.

Change-Id: I05d6d3481aaf8f3e260d2e5e950248519a1d347f

9 years agoRevert "Fix dlsym(3) to do breadth first search."
Dmitriy Ivanov [Mon, 4 Aug 2014 15:21:16 +0000 (15:21 +0000)]
Revert "Fix dlsym(3) to do breadth first search."

This reverts commit 422106a24d620af4be58e8d92a2e9b7b6167b72d.

Change-Id: I9e26a6933d10eb30438b521450f2010997ca5aee

9 years agoFix memchr with a zero length.
Christopher Ferris [Wed, 30 Jul 2014 23:06:56 +0000 (16:06 -0700)]
Fix memchr with a zero length.

The memchr implementation for 64 bit fails if these conditions occur:

- The buffer is 32 byte aligned.
- The buffer contains the character in the first byte.
- The count sent in is zero.

The function should return NULL, but it's not.

Bug: 16676625

(cherry picked from commit e03e1eac0b7682884b6628df1305d34299680cb4)

Change-Id: Ie4cca2c445127a0936ee2b96651a8e7204fbaffd

9 years agoImplement <sys/fsuid.h>.
Elliott Hughes [Wed, 30 Jul 2014 22:05:09 +0000 (15:05 -0700)]
Implement <sys/fsuid.h>.

(cherry picked from commit 79310994d2b3826a10598f7e7795acb5edb42a20)

Change-Id: I47688273691e5c95e5e9302eba254ccaaaad40ca

9 years ago[MIPSR6] Use C-coded string ops on mips32r6/mips64r6
Duane Sand [Thu, 10 Jul 2014 22:24:27 +0000 (15:24 -0700)]
[MIPSR6] Use C-coded string ops on mips32r6/mips64r6

The existing assembler code uses deprecated lwl/lwr/swl/swr ops.
Replacing those with misalignment-forgiving lw/sw ops may
involve careful performance tuning.

(cherry picked from commit bc5a3ec6df66d2456667ddf1d6dfaf623552169d)

Change-Id: I35167da27f2d406339b7f24b4a1fb270c87bc12e

9 years agoOnly wipe TLS for user-supplied stacks.
Elliott Hughes [Wed, 30 Jul 2014 21:48:10 +0000 (14:48 -0700)]
Only wipe TLS for user-supplied stacks.

Bug: 16667988

(cherry picked from commit 40a521744825b6060960c296d5fb3da4c6593d94)

Change-Id: I7550fa47b76e643323aa3e2a53529e393c829e47

9 years agoUse libunwindbacktrace for debug malloc code.
Christopher Ferris [Fri, 25 Jul 2014 00:52:23 +0000 (17:52 -0700)]
Use libunwindbacktrace for debug malloc code.

Create a method of disabling the debug allocation code paths so that
it's possible to use the libunwindbacktrace library without any
modifications.

Use this path to create and destroy the maps for the process. It's not
stricly necessary in the init code since the symbols are not modified
until after the initialize calls.

Also, remove the debug_XXX source files that doesn't need to be in libc.so.

Fix the maps reading code since it was completely broken for 64 bit.

Bug: 16408686

(cherry picked from commit 861c0ef37bcfcae56d88572cb01c18bcfe1faded)

Change-Id: I04445f0cf9a1e85172b64d57df92eb7939ce2332

9 years agoRemove declarations for things that don't exist.
Elliott Hughes [Tue, 29 Jul 2014 23:43:55 +0000 (16:43 -0700)]
Remove declarations for things that don't exist.

The <grp.h> ones prevent gdb from building out of the box.

(cherry picked from commit f4c1a36a4500bc7f12e3065be3da4e8669ee011d)

Change-Id: I6958f2f1731de8c03df20b383decd414b78100aa

9 years agoMerge "Revert "Added a bionic systrace class and tracing to pthread_mutex.cpp.""...
Elliott Hughes [Tue, 29 Jul 2014 23:52:37 +0000 (23:52 +0000)]
Merge "Revert "Added a bionic systrace class and tracing to pthread_mutex.cpp."" into lmp-dev

9 years agoRevert "Added a bionic systrace class and tracing to pthread_mutex.cpp."
Elliott Hughes [Tue, 29 Jul 2014 23:52:29 +0000 (23:52 +0000)]
Revert "Added a bionic systrace class and tracing to pthread_mutex.cpp."

This reverts commit a09fe118b1a5eb876ddaa2620965c4a8fb8b007c.

Change-Id: Ia2eb07b57a25dc2ac76fecc0925efb2bed998156

9 years agoMerge "en_US.UTF-8 is also supported." into lmp-dev
Dan Albert [Tue, 29 Jul 2014 22:42:19 +0000 (22:42 +0000)]
Merge "en_US.UTF-8 is also supported." into lmp-dev

9 years agoen_US.UTF-8 is also supported.
Dan Albert [Fri, 25 Jul 2014 18:24:03 +0000 (11:24 -0700)]
en_US.UTF-8 is also supported.

Change-Id: Ic35fad3596dc5e24ee8ae35543a274a471f27bb2
(cherry picked from commit 1abb8bd21d64c2bd21258469b688483f821974d5)

9 years agoThere is no _MIN for unsigned types.
Dan Albert [Tue, 22 Jul 2014 00:16:30 +0000 (17:16 -0700)]
There is no _MIN for unsigned types.

Change-Id: I49c38e51197b750210bdbf28c9cf6db30452a206
(cherry picked from commit ee7f1b5946dffa3aa95394b8cf6f15527f1068eb)

9 years agoFix mbsrtowcs(3)'s handling of len parameter.
Dan Albert [Sun, 20 Jul 2014 18:51:26 +0000 (11:51 -0700)]
Fix mbsrtowcs(3)'s handling of len parameter.

The len parameter is a _maximum_ length. The previous code was treating
it as an exact length, causing the following typical call to fail:

    mbsrtowcs(out, &in, sizeof(out), state); // sizeof(out) > strlen(in)

Change-Id: I48e474fd54ea5f122bc168a4d74bfe08704f28cc
(cherry picked from commit 6b55ba54eff4657cffe053b71e1c9cce2944a8a9)

9 years ago__libc_fatal should print a newline to stderr.
Dan Albert [Sun, 20 Jul 2014 18:49:46 +0000 (11:49 -0700)]
__libc_fatal should print a newline to stderr.

Change-Id: I088dc880d7488a65beac8cda95f530f3db41f112
(cherry picked from commit 97e31dedf056b07bcfcd46c49b60bf0798c60843)

9 years agoFix linkage of grantpt(3).
Elliott Hughes [Sat, 26 Jul 2014 00:24:00 +0000 (17:24 -0700)]
Fix linkage of grantpt(3).

Also clean up the implementation of all the pty functions, add tests,
and fix the stub implementations of ttyname(3) and ttyname_r(3).

Bug: https://code.google.com/p/android/issues/detail?id=58888

(cherry picked from commit 4916706cfe590eb06c9b5bd4bd402ce056034d51)

Change-Id: I5cb7a1c17b156456e4c4818e65f256eb8d045424

9 years agoAdded a bionic systrace class and tracing to pthread_mutex.cpp.
Brigid Smith [Mon, 21 Jul 2014 22:38:06 +0000 (15:38 -0700)]
Added a bionic systrace class and tracing to pthread_mutex.cpp.

bionic_systrace.h contains an implementation of tracing that
can be used with systrace.py and its associated viewer.  pthread_mutex
now uses this tracing to track pthread_mutex contention, which can be
enabled by using the "bionic" command line option to systrace.

Bug: 15116468

(cherry picked from commit a406ee6d5f616192e9a13afad6ac6a9969814fc1)

Change-Id: Ic98fc303689fe9384974150d0d258c50806a55e4

9 years agoFix mips/mips64 build
Dmitriy Ivanov [Tue, 29 Jul 2014 00:53:29 +0000 (17:53 -0700)]
Fix mips/mips64 build

 Add _start entry label to mips/mips64 linker begin.S

(cherry picked from commit ed485347189e3dfe04a38207c416bdd8c8fac4bc)

Change-Id: Id1b6bb3258f3bfbe3b7ec9491a977f56e44bed14

9 years agoFix 'adb shell /system/bin/linker' crash
Dmitriy Ivanov [Mon, 28 Jul 2014 22:05:51 +0000 (15:05 -0700)]
Fix 'adb shell /system/bin/linker' crash

Bug: https://code.google.com/p/android/issues/detail?id=63174

(cherry picked from commit efe13832dccf2cec2898b89ca4418a6aac29d3eb)

Change-Id: I43629e4a14870f67abc2dd5ff2e3040c47b2168d

9 years agoRevert "Add a hack to <stdlib.h> until we can fix libvpx."
Elliott Hughes [Mon, 28 Jul 2014 23:16:38 +0000 (16:16 -0700)]
Revert "Add a hack to <stdlib.h> until we can fix libvpx."

This reverts commit 3fb5097a7eec40404760c304b36c8b657b374cab.
libvpx is now fixed.

Bug: 15598056
Change-Id: Icca974e667f92206505f484bd291726eb0150f68

9 years agosyscall(3)'s return type should be long.
Elliott Hughes [Mon, 28 Jul 2014 19:24:22 +0000 (12:24 -0700)]
syscall(3)'s return type should be long.

This doesn't require us to change any of the syscall implementations
because (a) the LP32 ones have sizeof(int) == sizeof(long) anyway,
which is how we never noticed this bug before and (b) the LP64 ones
all use a 64-bit register for the result (and for the syscall number
too).

Bug: https://code.google.com/p/android/issues/detail?id=73952
Bug: 16568314

(cherry picked from commit 21972b61ec0572395c5684eebc6cc7b3a4c9e3be)

Change-Id: Ifbc424be29e5650ec72a24df25dd35f24fdd5b3c

9 years agoUse vsnprintf(3) in syslog(3).
Elliott Hughes [Sat, 26 Jul 2014 03:31:47 +0000 (20:31 -0700)]
Use vsnprintf(3) in syslog(3).

It seemed like a clever trick to use the internal log message formatting
code in syslog(3), but on reflection that means you can't (for example)
format floating point numbers. This patch switches us over to using good
old vsnprintf(3), even though that requires us to jump through a few hoops.

There's no obvious way to unit test this, so I wrote a little program and
ran that.

Bug: 14292866
Change-Id: I9c83500ba9cbb209b6f496067a91bf69434eeef5

9 years agoRemove localtime_tz and strftime_tz.
Elliott Hughes [Fri, 25 Jul 2014 22:50:31 +0000 (15:50 -0700)]
Remove localtime_tz and strftime_tz.

This also brings our copy of strftime.c much closer to upstream, though
we still have several GNU extensions and hacks to deal with Android32's
broken time_t.

Bug: 15765976

(cherry picked from commit 39d903aea901cd29a4eef3a82c2dbda59b5bc292)

Change-Id: Ie278d3e976b7adc77bad5ce795dd4899cfbf3648

9 years agoStart hiding "private/bionic_time.h".
Elliott Hughes [Fri, 25 Jul 2014 18:55:59 +0000 (11:55 -0700)]
Start hiding "private/bionic_time.h".

Bug: 15765976

(cherry picked from commit 905e6d58aaf515bf237e62078f8a321920fe4c6b)

Change-Id: Ic7435308e8b521886f42ac7bf59531924921ea67

9 years agoMerge "There is no _MIN for unsigned types." into lmp-dev
Dan Albert [Tue, 29 Jul 2014 22:42:15 +0000 (22:42 +0000)]
Merge "There is no _MIN for unsigned types." into lmp-dev

9 years agoMerge "Fix mbsrtowcs(3)'s handling of len parameter." into lmp-dev
Dan Albert [Tue, 29 Jul 2014 22:42:11 +0000 (22:42 +0000)]
Merge "Fix mbsrtowcs(3)'s handling of len parameter." into lmp-dev

9 years agoMerge "__libc_fatal should print a newline to stderr." into lmp-dev
Dan Albert [Tue, 29 Jul 2014 22:42:05 +0000 (22:42 +0000)]
Merge "__libc_fatal should print a newline to stderr." into lmp-dev

9 years agoFix dlsym(3) to do breadth first search.
Dmitriy Ivanov [Tue, 29 Jul 2014 00:32:20 +0000 (17:32 -0700)]
Fix dlsym(3) to do breadth first search.

  dlsym(3) with handle != RTLD_DEFAULT|RTLD_NEXT performs
  breadth first search through the dependency tree.

Bug: 16653281

(cherry picked from commit aa0f2bdbc22d4b7aec5d3f8f5f01eaeaa13414c2)

Change-Id: I0ba8c2034ab341f8a279cdb4e2e7e47f1aef7897

9 years agoFix global variable initialization for linker
Dmitriy Ivanov [Thu, 24 Jul 2014 22:33:25 +0000 (15:33 -0700)]
Fix global variable initialization for linker

 Linker now calls init functions for itself.

(cherry picked from commit 4151ea73b75e274d1ff80b42d9d457a783208516)

Change-Id: I3300fe22de8ad8466a5b1c2d551429769a42852d

9 years ago[MIPS] Fix atomic_is_lock_free test for mips32.
Raghu Gandham [Thu, 24 Jul 2014 22:56:51 +0000 (15:56 -0700)]
[MIPS] Fix atomic_is_lock_free test for mips32.
On 32-bit MIPS, 64-bit atomic ops are achieved through locks.
So allow the test to fail for atomic_intmax_t on 32-bit MIPS.

(cherry picked from commit f1837377d215a6eda294b6ac7552b226deee91ce)

Change-Id: I973d999c31c9ab89b5a7b709beff6486b93408f2

9 years agoImplement twalk(3), add unit tests.
Elliott Hughes [Wed, 23 Jul 2014 23:02:26 +0000 (16:02 -0700)]
Implement twalk(3), add unit tests.

I've also added insque(3) and remque(3) (from NetBSD because the OpenBSD
ones are currently broken for non-circular lists).

I've not added the three hash table functions that should be in this header
because they operate on a single global hash table and thus aren't likely
to be useful.

Bug: https://code.google.com/p/android/issues/detail?id=73719

(cherry picked from commit 3e424d0a241f8ae5194514dabc4ad899f5a5416d)

Change-Id: I5882a6b48c80fea8ac6b9c27e7b9de10b202b4ff

9 years ago[MIPS] Drop soft-fp targets
Duane Sand [Thu, 24 Jul 2014 17:56:54 +0000 (10:56 -0700)]
[MIPS] Drop soft-fp targets

(cherry picked from commit ba23bd0a409bb0e43c57dabee96b2ae52481d5b7)

Change-Id: Ica09192c2760d38ceebc14e23a5d3ba94c20764c

9 years ago[MIPSR6] setjmp supports mips32r6 and FP64A/FPXX reg models
Duane Sand [Mon, 14 Jul 2014 22:30:14 +0000 (15:30 -0700)]
[MIPSR6] setjmp supports mips32r6 and FP64A/FPXX reg models

Save and restore floating point registers via 64-bit
load/stores when possible.  Use assembler's builtin macro
ops to generate pairs of 32-bit load/stores on Mips I cpus.

Some cpus or FR modes have only 16 even-numbered dp fp regs.
This is exposed by _MIPS_FPSET, defined by existing compilers.

(cherry picked from commit dd37251c473e1483faba0fd5aaf30e7a55582e8a)

Change-Id: Ibd43653701a363a77af85121d3cbd229d132a06a

9 years agoHACK: Disable syslog going to android log.
Christopher Ferris [Thu, 24 Jul 2014 01:05:58 +0000 (18:05 -0700)]
HACK: Disable syslog going to android log.

Bug: 14292866

Change-Id: I3adc448dbacfeecd32508ddccf27be3aa653e466

9 years agodebuggerd: if PR_GET_DUMPABLE=0, don't ask for dumping
Nick Kralevich [Wed, 23 Jul 2014 20:56:23 +0000 (13:56 -0700)]
debuggerd: if PR_GET_DUMPABLE=0, don't ask for dumping

PR_GET_DUMPABLE is used by an application to indicate whether or
not core dumps / PTRACE_ATTACH should work.

Security sensitive applications often set PR_SET_DUMPABLE to 0 to
disable core dumps, to avoid leaking sensitive memory to persistent
storage. Similarly, they also set PR_SET_DUMPABLE to zero to prevent
PTRACE_ATTACH from working, again to avoid leaking the contents
of sensitive memory.

Honor PR_GET_DUMPABLE when connecting to debuggerd. If an application
has said it doesn't want its memory dumped, then we shouldn't
ask debuggerd to dump memory on its behalf.

FORTIFY_SOURCE tests: Modify the fortify_source tests to set
PR_SET_DUMPABLE=0. This reduces the total runtime of
/data/nativetest/bionic-unit-tests/bionic-unit-tests32 from approx
53 seconds to 25 seconds. There's no need to connect to debuggerd
when running these tests.

Bug: 16513137

(cherry picked from commit be0e43b77676338fd5e6a82c9cc2b6302d579de2)

Change-Id: I6e1a9bce564e94fc19893d639b15f38c549cabfa

9 years agoHACK: remove %m support from printf.
Colin Cross [Wed, 23 Jul 2014 21:43:44 +0000 (14:43 -0700)]
HACK: remove %m support from printf.

The change that added this support causes a cpu hard lock on one
device.  This code clearly isn't at fault, but disabling it to
unblock until we can find a real fix.

Bug: 16484311
Change-Id: I33834dc49d959ae403b10d2c7cad12ae2950f772

9 years agoFix belated review comments on syslog change.
Elliott Hughes [Wed, 23 Jul 2014 18:38:38 +0000 (11:38 -0700)]
Fix belated review comments on syslog change.

Bug: 14292866

(cherry picked from commit afe6360627ef3f0e9bc8f45535fbfae3354f3ae0)

Change-Id: I8e3cc6b37b2539e51a27261ffb5d6e58266ce11d

9 years agoFix generate-NOTICE to cope better with BSD __COPYRIGHT macros.
Elliott Hughes [Wed, 23 Jul 2014 18:10:48 +0000 (11:10 -0700)]
Fix generate-NOTICE to cope better with BSD __COPYRIGHT macros.

(cherry picked from commit 5d2f86f36341b76f84770d8966d7686a59555ae9)

Change-Id: Iddf22c8d9ff7a4d1205d37bb58c6235af681d795

9 years agoFix a couple of bugs in generate-NOTICE and regenerate the NOTICE files.
Elliott Hughes [Wed, 23 Jul 2014 04:24:47 +0000 (21:24 -0700)]
Fix a couple of bugs in generate-NOTICE and regenerate the NOTICE files.

(cherry picked from commit 3758a244cf758046b40f630a11aed41e68c9cfc2)

Change-Id: I6ffb83b4a7b7746b095205c664cf025a72ead179

9 years agoRemove the unused swab.S.
Elliott Hughes [Wed, 23 Jul 2014 03:21:31 +0000 (20:21 -0700)]
Remove the unused swab.S.

(cherry picked from commit ca70453e84a88405d30f64d603f9a9b5f53f1243)

Change-Id: I4dc13de0bdeb7abb3bd47b0397546ad7d1f11d49

9 years ago[MIPS] Allow united mipsel and mips64el gcc toolchain
Duane Sand [Wed, 16 Jul 2014 19:29:34 +0000 (12:29 -0700)]
[MIPS] Allow united mipsel and mips64el gcc toolchain

Explicitly tell 32-bit links that they are doing 32-bit links.
This is needed when using united 32-bit and 64-bit toolchains.
This is harmless when using older separate 32-only toolchains.

(cherry picked from commit f541650828f75b3dab22c9c0caab845be78b80fc)

Change-Id: I8df0ee7d36c6409458e18bea4e0e8b132edf77dc

9 years agoCleanup: Delete dead code.
Sreeram Ramachandran [Sun, 20 Jul 2014 21:10:45 +0000 (14:10 -0700)]
Cleanup: Delete dead code.

Bug: 15413389
Change-Id: I315468832ef18ffc84174e54774ab63b86d284dc

9 years agoUse upstream OpenBSD's arc4random.
Elliott Hughes [Fri, 18 Jul 2014 22:57:41 +0000 (15:57 -0700)]
Use upstream OpenBSD's arc4random.

The getentropy_linux.c is lightly modified to build on Android, but we're now
completely in sync with upstream OpenBSD's arc4random implementation.

(cherry picked from commit 2b67d7dee09852789d9ac7d8972ed6cdb2c18430)

Change-Id: Icc939b5fa2fcac3e15ff93735d2d34f67e9bb149

9 years agoRewrite syslog(3) to use Android logging.
Elliott Hughes [Mon, 21 Jul 2014 23:35:24 +0000 (16:35 -0700)]
Rewrite syslog(3) to use Android logging.

Since we don't have syslogd on Android and you can't run one on a non-rooted
device, it's more useful if syslog output just goes to the regular Android
logging system.

Bug: 14292866

(cherry picked from commit 3ad8ecb64e9dd5614169232b84a93eb3b8aa32d7)

Change-Id: I3038855ca4f22532bf6d2c45d3f8028b866975f9

10 years agoDefine atomic_charN_t only if charN_t is supported.
Hans Boehm [Wed, 16 Jul 2014 18:33:48 +0000 (11:33 -0700)]
Define atomic_charN_t only if charN_t is supported.

Some platform code is apparently compiled with switches that do
not support char16_t and char32_t.  This caused stdatomic.h to fail
to compile.  This CL makes stdatomic.h usable in those environments.

(cherry picked from commit 8b002362d996859ebfc8588d6859a9a79203dc27)
Change-Id: Ie5a17f20b8b545c97128d00605b4eabd2a6bfe3e

10 years agoMake sure not to construct illegal property names.
Christopher Ferris [Wed, 16 Jul 2014 02:09:07 +0000 (19:09 -0700)]
Make sure not to construct illegal property names.

(cherry picked from commit 53531ccebbaf103d80516ff74874482ca3ee31fc)

Change-Id: I7e988c335ef32b61b2ac34f34509274623dbed69

10 years agoMerge "Clean up some misinformation around prctl." into lmp-dev
Elliott Hughes [Fri, 18 Jul 2014 23:58:18 +0000 (23:58 +0000)]
Merge "Clean up some misinformation around prctl." into lmp-dev

10 years agoClean up some misinformation around prctl.
Elliott Hughes [Fri, 18 Jul 2014 22:55:41 +0000 (15:55 -0700)]
Clean up some misinformation around prctl.

prctl shouldn't be in <unistd.h>.

(cherry picked from commit 9c07aee83b4ebbf2dba8e23d6896683187b9724e)

Change-Id: I70cda886fbf4d58d82dc70adaa981506ebff9949

10 years agoRemove SIOCKILLADDR from <sys/socket.h>.
Elliott Hughes [Fri, 18 Jul 2014 00:10:02 +0000 (17:10 -0700)]
Remove SIOCKILLADDR from <sys/socket.h>.

(cherry picked from commit 8a3d1ca183e19d849728318fe8b0d36856fa000f)

Change-Id: Idb5cc4cff3ece7fa8740db12a19438d1a1c9a6a8