glibc/sysdeps
H.J. Lu 086df229ee i386: Add <startup.h> [BZ #21913]
On Linux/i386, there are 3 ways to make a system call:

1. call *%gs:SYSINFO_OFFSET.  This requires TLS initialization.
2. call *_dl_sysinfo.  This requires relocation of _dl_sysinfo.
3. int $0x80.  This is slower than #2 and #3, but works everywhere.

When an object file is compiled with PIC, #1 is prefered since it is
faster than #3 and doesn't require relocation of _dl_sysinfo.  For
dynamic executables, ld.so initializes TLS.  However, for static
executables, before TLS is initialized by __libc_setup_tls, #3 should
be used for system calls.

This patch adds <startup.h> which defines _startup_fatal and defaults
it to __libc_fatal.  It replaces __libc_fatal with _startup_fatal in
static executables where it is called before __libc_setup_tls is called.
This header file is included in all files containing functions which are
called before __libc_setup_tls is called.  On Linux/i386, when PIE is
enabled by default, _startup_fatal is turned into ABORT_INSTRUCTION and
I386_USE_SYSENTER is defined to 0 so that "int $0x80" is used for system
calls before __libc_setup_tls is called.

Tested on i686 and x86-64.  Without this patch, all statically-linked
tests will fail on i686 when the compiler defaults to -fPIE.

	[BZ #21913]
	* csu/libc-tls.c: Include <startup.h> first.
	(__libc_setup_tls): Call _startup_fatal instead of __libc_fatal.
	* elf/dl-tunables.c: Include <startup.h> first.
	* include/libc-symbols.h (BUILD_PIE_DEFAULT): New.
	* sysdeps/generic/startup.h: New file.
	* sysdeps/unix/sysv/linux/i386/startup.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/brk.c [BUILD_PIE_DEFAULT != 0]
	(I386_USE_SYSENTER): New.  Defined to 0.
2017-08-08 08:43:15 -07:00
..
aarch64 tunables, aarch64: New tunable to override cpu 2017-06-30 22:58:39 +05:30
alpha Update Alpha libm-test-ulps 2017-07-27 14:21:28 -03:00
arm [ARM] Fix ld.so crash when built using Binutils 2.29 2017-07-13 15:48:41 +01:00
generic i386: Add <startup.h> [BZ #21913] 2017-08-08 08:43:15 -07:00
gnu Regenerate sysdeps/gnu/errlist.c. 2017-06-04 15:27:14 -04:00
hppa Remove extra semicolons in struct pthread_mutex (bug 21804) 2017-07-24 12:22:05 +02:00
i386 i686: Implement IFUNC selectors in C 2017-08-04 13:29:38 -07:00
ia64 float128: Add signbit alternative for old compilers 2017-06-30 18:34:29 -03:00
ieee754 Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
init_array Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
m68k Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
mach [hurd]: Add __libc_init_secure stub 2017-08-02 23:29:57 +02:00
microblaze Update Microblaze libm-test-ulps 2017-07-28 09:19:40 -03:00
mips Rename struct ucontext tag (bug 21457). 2017-06-26 22:03:58 +00:00
nios2 Update Nios II ULPs file. 2017-07-28 03:54:35 -07:00
nptl Remove extra semicolons in struct pthread_mutex (bug 21804) 2017-07-24 12:22:05 +02:00
posix posix: Set p{read,write}v2 to return ENOTSUP (BZ#21780) 2017-08-08 09:59:46 -03:00
powerpc tst-tlsopt-powerpc as a shared lib 2017-08-03 15:39:21 +09:30
pthread Single threaded stdio optimization 2017-07-04 16:05:12 +01:00
s390 Require binutils 2.25 or later to build glibc. 2017-06-28 11:31:50 +00:00
sh PowerPC64 ELFv2 PPC64_OPT_LOCALENTRY 2017-06-14 10:47:25 +09:30
sparc Update sparc ulps 2017-07-19 15:56:02 -03:00
tile PowerPC64 ELFv2 PPC64_OPT_LOCALENTRY 2017-06-14 10:47:25 +09:30
unix i386: Add <startup.h> [BZ #21913] 2017-08-08 08:43:15 -07:00
wordsize-32 Build divdi3 only for architecture that required it 2017-04-06 15:14:34 -03:00
wordsize-64 Add missing header files throughout the testsuite. 2017-02-16 17:33:18 -05:00
x86 x86: Remove assembly versions of HAS_CPU_FEATURE/HAS_ARCH_FEATURE 2017-08-04 13:38:20 -07:00
x86_64 x86-64: Add FMA multiarch functions to libm 2017-08-07 08:20:56 -07:00