glibc/csu
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
..
Makefile Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Versions Remove unused %include lines from Versions files. 2014-02-22 00:58:54 -08:00
abi-note.S Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
check_fds.c Assume that O_NOFOLLOW is always defined 2017-04-13 21:28:18 +02:00
dso_handle.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
elf-init.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
errno-loc.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
errno.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
gmon-start.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
init-first.c getopt: remove USE_NONOPTION_FLAGS 2017-04-07 07:45:53 -04:00
init.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
libc-start.c powerpc: Fix float128 IFUNC relocations [BZ #21707] 2017-07-17 17:49:26 -03:00
libc-tls.c i386: Add <startup.h> [BZ #21913] 2017-08-08 08:43:15 -07:00
start.c More fallout from supporting only ELF 2012-01-08 00:45:01 -05:00
sysdep.c Moved to csu/errno-loc.c. 2005-12-14 15:06:39 +00:00
version.c Update copyright dates not handled by scripts/update-copyrights. 2017-01-01 00:26:24 +00:00