Commit graph

2377 commits

Author SHA1 Message Date
Xiaokang Qin
9c3449ecd9 bionic: linker: Need update the map->l_addr for execution.
Currently, linker doesn't update the map->l_addr for execution.
Which could break the Unwind_Backtrace with PT_GNU_EH_FRAME enabled
in new toolchain.

Change-Id: Ifbd853134da64a962f7e4c4105e56a3f20def1b2
Author: Fengwei Yin <fengwei.yin@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 57077
2012-09-13 18:09:20 +08:00
Elliott Hughes
7593fa8eb7 Merge "Update the kernel headers to match external/kernel-headers." 2012-09-12 15:56:11 -07:00
Elliott Hughes
86ec05acc9 Update the kernel headers to match external/kernel-headers.
Note that the Linux kernel handed over responsibility for most of the
socket constants to glibc some time ago. Someone had updated our
external/kernel-headers file but not regenerated the bionic headers,
so this change copies the missing stuff from the old bionic <linux/socket.h>
into <sys/socket.h>. This is what glibc does.

I've hacked a few of the other files to #include <sys/socket.h> for
backward compatibility, but even so this requires numerous other
changes to switch people over from direct inclusion of <linux/...> headers.

Change-Id: I0e4af64e631d3cef911a31d90f2f806e058278a0
2012-09-12 12:30:22 -07:00
Elliott Hughes
666d06fee9 Merge "Backwards and forwards compatibility for an upcoming <sys/socket.h> change." 2012-09-12 10:51:48 -07:00
Elliott Hughes
0d207ba624 Backwards and forwards compatibility for an upcoming <sys/socket.h> change.
Change-Id: Iba58077a1f057a968eb2283ebba259975925ff4c
2012-09-12 10:51:05 -07:00
Elliott Hughes
cc8668f261 Merge "[MIPS] Check error status from pipe system call" 2012-09-11 16:38:43 -07:00
KwongYuan Wong
b03bc56b79 [MIPS] Check error status from pipe system call
Change-Id: Iaaea0e826c2678aa7f6fad9d46b16302a4d3b876
2012-09-11 16:38:04 -07:00
Elliott Hughes
59726beda5 Merge "Rename crtstart variables as crtbegin, to match reality." 2012-09-10 11:52:12 -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
67546bf209 Merge "Generate header dependency makefiles for the crt*.o" 2012-09-10 09:48:46 -07:00
Elliott Hughes
f1d57e1668 Merge "Add more pthreads tests." 2012-09-07 18:30:18 -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
4d014e15b4 Add more pthreads tests.
Someone reported a bug if pthread_detach is called while a pthread_join is
already in progress, but I'm unable to reproduce it. Keep the tests I wrote,
though.

Change-Id: I3d71450bbbb5345f2cb213dc56310ec020d528cc
2012-09-07 16:47:54 -07:00
Elliott Hughes
d10309c36b Merge "Rename __dso_handle_so.c to __dso_handle_so.h" 2012-09-07 10:59:20 -07:00
Elliott Hughes
691ef3c80b Merge "Add mlockall and munlockall for Google TV." 2012-09-07 10:51:49 -07:00
Andrew Hsieh
048569be54 Rename __dso_handle_so.c to __dso_handle_so.h
Also chang libc/arch-arm/bionic/crtbegin_so.c to include it
as a header.

Change-Id: Ib91b0b8caf5c8b936425aa8a4fc1a229b2b27929
2012-09-07 12:49:41 +08:00
Ian Rogers
e8f815473b Merge "Fix build warning of initialization but no use." 2012-09-06 11:41:52 -07:00
Elliott Hughes
1ad05db9ce Add mlockall and munlockall for Google TV.
Change-Id: I10e961d701e74aab07211ec7975f61167e387853
2012-09-06 11:24:45 -07:00
Elliott Hughes
6e3b0f2d2e Merge "Don't corrupt the thread list in static executables." 2012-09-06 10:31:52 -07:00
Ian Rogers
09f76cdd9b Fix build warning of initialization but no use.
first_run is only used with LOCK_AT_FORK, however, care needs to be
taken with the #if to avoid compiler warnings when LOCK_AT_FORK isn't
being used.

Change-Id: I6bcfac2ab8732c91607f4a1bcd7c0019f29c2eec
2012-09-06 09:59:13 -07:00
Elliott Hughes
bfeab1bbe7 Don't corrupt the thread list in static executables.
Several previous changes conspired to make a mess of the thread list
in static binaries. This was most obvious when trying to call
pthread_key_delete(3) on the main thread.

Bug: http://code.google.com/p/android/issues/detail?id=36893
Change-Id: I2a2f553114d8fb40533c481252b410c10656da2e
2012-09-05 17:47:37 -07:00
Elliott Hughes
ff4608ae0c Merge "Add missing dependencies." 2012-09-05 14:46:15 -07:00
Elliott Hughes
2e8f4345df Add missing dependencies.
Change-Id: I53c1cfb59ac7a89952a8d6b906b2b9e16a66624f
2012-09-05 14:27:17 -07:00
Elliott Hughes
b2c5bd543d Merge "ARM: warn about atexit() calls from legacy shared libraries" 2012-09-05 10:18:43 -07:00
Elliott Hughes
26f2e4a163 Merge "ARM: make CRT_LEGACY_WORKAROUND work as intended" 2012-09-05 09:43:35 -07:00
Ian Rogers
82978cae4e Merge "Avoid malloc lock while calling pthread_atfork." 2012-09-05 07:41:32 -07:00
Elliott Hughes
be19a36717 Merge "termios: add tcdrain" 2012-09-04 17:52:40 -07:00
Elliott Hughes
5ff2347130 Merge "Add getsid system call to bionic" 2012-09-04 16:36:27 -07:00
Elliott Hughes
e03ab93699 Merge "Add missing MALLOC_FAILURE_ACTION calls to dlmalloc." 2012-09-04 15:51:55 -07:00
Elliott Hughes
63deae5e4f Add missing MALLOC_FAILURE_ACTION calls to dlmalloc.
Without these, sometimes malloc(3) returns NULL without setting errno.

Change-Id: I4708c3f675bf2c878ddcaf012fde7848b255826b
2012-09-04 15:42:23 -07:00
Elliott Hughes
1db615b4ae Merge "bionic: Fix TINY_ANDROID build" 2012-09-04 13:42:57 -07:00
Benoit Goby
5ac9eee1d3 bionic: Fix TINY_ANDROID build
(cherry-pick of 545d5dbbcb0dc9e44323c4f2e687a3aace75a483.)

Change-Id: Ifc91e84ffed5a3a287accabd7f08b02752688db6
2012-09-04 13:36:54 -07:00
Vitaly Wool
954923858b termios: add tcdrain
Change-Id: I05c0007f7bcc6ef5295c32f86fafbf1ad31e07fa
2012-09-04 14:11:28 +02:00
Irina Tirdea
1ad10a566e Add getsid system call to bionic
Add getsid() system call to bionic for
all architectures. This is needed for various tools
(e.g. perf).

Adding the getsid system call was done in 3 steps:
() add getsid 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.
() add the system call signature to libc/include/unistd.h

Change-Id: Id69a257e13ec02e1a44085a6b217a3f19ab025b1
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
2012-09-03 01:38:34 +03:00
Kirill Artamonov
3e2d2936b0 Avoid malloc lock while calling pthread_atfork.
Expecting the memory in a forked child process to be sane wrt threading
is a bad idea. An example of a problem is when the parent process has
the malloc lock and a child process is forked. The malloc lock in the
child will appear locked by a thread that doesn't exist.

This change aims to make bionic more compatible with glibc by reseting
the malloc lock in the child forked process, as well as holding it
during the fork. This is a feature in dlmalloc 2.8.6 called
LOCK_AT_FORK. In general this feature isn't necessary as a forked
process will then exec. Some bad applications rely on being able to use
features like malloc before the exec and having multiple threads running
in the parent program. This isn't a problem with glibc and this patch
makes it not a problem for bionic.

Unfortunately for use in bionic, LOCK_AT_FORK has an issue as internally
it uses pthread_atfork that in bionic uses malloc. This leads to the
LOCK_AT_FORK initialization deadlocking with pthread_atfork's call to
malloc due to the malloc lock. This change moves the pthread_atfork logic
in LOCK_AT_FORK to be called without the malloc lock held.

Change-Id: Id68175a564a6abb936ee4488b44d9479f7311f69
2012-08-31 11:11:40 -07:00
Ian Rogers
6fe901ef38 Merge "Upgrade to dlmalloc 2.8.6." 2012-08-31 08:42:41 -07:00
Ian Rogers
c6d95add30 Upgrade to dlmalloc 2.8.6.
This fixes a bug and enables the use of MORECORE_CONTIGUOUS.

Change-Id: Ia7c5d32bdc46e99b3ecb92ee94d1f702c4385d5d
2012-08-29 18:18:29 -07:00
Elliott Hughes
8b4e8a937b Merge "Improve the dynamic linker diagnostics." 2012-08-29 13:56:40 -07:00
Nick Kralevich
17d9be8ad7 Merge "disable _FORTIFY_SOURCE under clang" 2012-08-29 13:54:49 -07:00
Elliott Hughes
e9b6fc6f82 Improve the dynamic linker diagnostics.
Lose the pid, only show the name of the function (not its whole signature),
and include the name of the library we failed to load. (I hadn't noticed
that the library name was missing before because in Java we add that into
the UnsatisfiedLinkError detail message.)

The new output looks like this:

  Cannot load library: soinfo_relocate(linker.cpp:968): cannot locate symbol "__libc_malloc_default_dispatch" referenced by "libc_malloc_debug_leak.so"...

Change-Id: I3bb5c9780d9aaf3a9e4418ea55bc98122a81f80f
2012-08-29 13:10:54 -07:00
Elliott Hughes
0d7177c0d4 Merge "Clean up warnings in the malloc_debug_* files." 2012-08-29 13:08:50 -07:00
Nick Kralevich
829c089f83 disable _FORTIFY_SOURCE under clang
Clang and _FORTIFY_SOURCE are just plain incompatible with
each other.  First of all, clang doesn't understand the
__attribute__((gnu_inline)) header. Second of all,
Clang doesn't have support for __builtin_va_arg_pack()
and __builtin_va_arg_pack_len() (see
http://clang.llvm.org/docs/UsersManual.html#c_unimpl_gcc)

Until we can resolve these issues, don't even try using
_FORTIFY_SOURCE under clang.

Change-Id: I81c2b8073bb3276fa9a4a6b93c427b641038356a
2012-08-29 12:47:41 -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
Nick Kralevich
069c64cdf2 Merge "ARM: make sure __on_dlclose() actually gets called" 2012-08-28 13:04:22 -07:00
Nick Kralevich
e026b1d89a Merge "ARM: remove dummy entries from .so init_array/fini_array" 2012-08-28 12:49:46 -07:00
Nick Kralevich
ad18073897 Merge "linker: Fix ARM_R_COPY relocations" 2012-08-28 12:48:01 -07:00
Nick Kralevich
d39c3abd5a linker: Fix ARM_R_COPY relocations
Per http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044d/IHI0044D_aaelf.pdf
Section 4.7.1.10, ARM_R_COPY relocations are only suppose to reference shared
libraries, not the executable itself.  When resolving an R_ARM_COPY symbol,
ensure we don't look in our own symbol.

This partially addresses
http://code.google.com/p/android/issues/detail?id=28598 .  After this
patch, the printfs generated by the test program are:

global = 0x42 (0x401c7000)
global = 0x42 (0x11000)

before, the output was:

global = 0x42 (0x40071000)
global = 0x0 (0x11000)

I'm still not very happy with this patch, but I think it's an improvement
over where we were at before.

This change was modeled after https://android-review.googlesource.com/38871

Change-Id: Id7ad921e58395e76a36875bcc742ec5eeba53f08
2012-08-28 11:48:32 -07:00
Nick Kralevich
c410a9613a Merge "libc: remove ctors/dtors sections" 2012-08-28 10:20:27 -07:00
Ard Biesheuvel
144c291866 ARM: warn about atexit() calls from legacy shared libraries
Legacy ARM shared libraries use this generic version of atexit(),
which queues exit functions for invocation at program exit, at
which time the library may have been dlclose()'d, causing the
program to crash.

Change-Id: I41ae153c23268daa65ede7fb8966fc3e9caec369
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
2012-08-28 11:23:06 +02: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