Commit graph

18 commits

Author SHA1 Message Date
Josh Gao
b6453c52ac Only initialize the global stack protector once.
Before, dynamic executables would initialize the global stack protector
twice, once for the linker, and once for the executable. This worked
because the result was the same for both initializations, because it
used getauxval(AT_RANDOM), which won't be the case once arc4random gets
used for it.

Bug: http://b/29622562
Change-Id: I7718b1ba8ee8fac7127ab2360cb1088e510fef5c
Test: ran the stack protector tests on angler (32/64bit, static/dynamic)
2016-06-30 12:58:32 -07:00
Yabin Cui
ca48274298 Revert "Revert "Make sem_wait able to return errno EINTR for sdk > 23.""
This reverts commit 6d51085202.
And add missing bionic_sdk_version.h.

Change-Id: I24cc738b1fd1d26234c52afbc787f5b3c4a9c9cb
2016-01-25 17:39:18 -08:00
Dan Albert
6d51085202 Revert "Make sem_wait able to return errno EINTR for sdk > 23."
Broke the build. There's no such file as bionic_sdk_version.h anywhere in the tree.

This reverts commit 892b61d340.

Change-Id: Iec3f4588edfb1d1524bb5f16451fd05dc6ebe44a
2016-01-26 00:20:06 +00:00
Yabin Cui
892b61d340 Make sem_wait able to return errno EINTR for sdk > 23.
Posix standards says sem_wait is interruptible by the delivery
of a signal. To keep compatiblity with old apps, only fix that
in newer sdk versions.

Bug: 26743454

Change-Id: I924cbb436658e3e0f397c922d866ece99b8241a3
2016-01-25 13:44:39 -08:00
Elliott Hughes
42d949ff9d Defend against -fstack-protector in libc startup.
Exactly which functions get a stack protector is up to the compiler, so
let's separate the code that sets up the environment stack protection
requires and explicitly build it with -fno-stack-protector.

Bug: http://b/26276517
Change-Id: I8719e23ead1f1e81715c32c1335da868f68369b5
2016-01-06 20:06:08 -08:00
Josh Gao
93c0f5ee00 Move VDSO pointers to a shared globals struct.
Change-Id: I01cbc9cf0917dc1fac52d9205bda2c68529d12ef
2015-10-09 15:59:04 -07:00
Elliott Hughes
afab3ffcce Move PAGE_MASK into <sys/user.h>.
I'm removing the TODO on the assumption that being compatible with glibc
is more useful than BSD. The new internal "bionic_page.h" header factors
out some duplication between libc and the linker.

Bug: http://b/22735893
Change-Id: I4aec4dcba5886fb6f6b9290a8f85660643261321
2015-07-28 14:58:37 -07:00
Elliott Hughes
d29486343a Use a less misleading name for the code that sets up the main thread.
Change-Id: I50c1b0a3b633cf8bc40a6bd86f12adb6b91e2888
2015-07-21 11:57:09 -07:00
Elliott Hughes
1801db3d3f Statically linked executables should honor AT_SECURE.
Bug: http://b/19647373
Change-Id: I10e7682d9cec26a523f1a3597ca5326c3ca42ebe
2015-06-09 20:10:25 -07:00
Dmitriy Ivanov
4b41555ba5 Revert "Register __libc_fini as early as possible."
This reverts commit e880c736d6.

Change-Id: Ide83e442eb5dbfef5298a15bc602c3fe1dda1862
2014-09-04 21:54:34 +00:00
Dmitriy Ivanov
e880c736d6 Register __libc_fini as early as possible.
We want __libc_fini to be called after all the destructors.

Bug: 14611536
Change-Id: Ibb83a94436795ec178fd605fa531ac29608f4a3e
2014-09-03 15:27:29 -07:00
Dmitriy Ivanov
53c3c271dc Upstream atexit
Change-Id: Ia454a2181b5058ed9783dc02b6b1805d0e4d2715
2014-07-14 12:05:16 -07:00
Elliott Hughes
d286796fce Turn on -Wunused and fix the mistakes it uncovers.
Change-Id: I023d2d8b547fbc21d4124bb7510d42b06a0dc501
2014-06-03 15:22:34 -07:00
Elliott Hughes
0266ae5f88 Switch <elf.h> over to linux uapi under the covers.
Remove the linker's reliance on BSD cruft and use the glibc-style
ElfW macro. (Other code too, but the linker contains the majority
of the code that needs to work for Elf32 and Elf64.)

All platforms need dl_iterate_phdr_static, so it doesn't make sense
to have that part of the per-architecture configuration.

Bug: 12476126
Change-Id: I1d7f918f1303a392794a6cd8b3512ff56bd6e487
2014-02-10 18:22:24 -08: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
c620059479 Remove 32-bit assumptions from the ELF code.
Change-Id: I2c1f3d34c33685799aade8866eec44479ff9f963
2013-09-30 18:43:46 -07:00
Elliott Hughes
d3920b3a99 Switch to using AT_RANDOM for the stack guards.
Bug: 7959813
Change-Id: I8db4b8912ba649bfe668c6f22aa44690ddd401a2
2013-02-08 11:16:13 -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
Renamed from libc/bionic/libc_init_static.c (Browse further)