diff mbox series

i386: Remove support for GCC versions before 5 from <sysdep.h>

Message ID 87ftt8bgzh.fsf@oldenburg2.str.redhat.com
State New
Headers show
Series i386: Remove support for GCC versions before 5 from <sysdep.h> | expand

Commit Message

Florian Weimer Jan. 31, 2019, 10:27 p.m. UTC
Tested on i386.

2019-01-31  Florian Weimer  <fweimer@redhat.com>

	i386: Remove support for GCC versions before 5 from <sysdep.h>.
	* sysdeps/unix/sysv/linux/i386/sysdep.h [!OPTIMIZE_FOR_GCC_5]
	(bpushl, bpopl, struct libc_do_syscall_args, INTERNAL_SYSCALL_MAIN_6)
	(INTERNAL_SYSCALL_MAIN_INLINE, INTERNAL_SYSCALL_NCS)
	(check_consistency): Remove.
	* elf/dl-load.c (_dl_map_object_from_fd): Remove call to
	check_consistency.
	* sysdeps/unix/sysv/linux/dl-execstack.c
	(_dl_make_stack_executable): Likewise.

Comments

Joseph Myers Jan. 31, 2019, 11:49 p.m. UTC | #1
On Thu, 31 Jan 2019, Florian Weimer wrote:

> Tested on i386.

Has profiling libc and building with -fno-omit-frame-pointer been tested 
(since the comment on OPTIMIZE_FOR_GCC_5 suggests it's also relevant for 
those cases)?
Florian Weimer Feb. 1, 2019, 1:12 p.m. UTC | #2
* Joseph Myers:

> On Thu, 31 Jan 2019, Florian Weimer wrote:
>
>> Tested on i386.
>
> Has profiling libc and building with -fno-omit-frame-pointer been tested 
> (since the comment on OPTIMIZE_FOR_GCC_5 suggests it's also relevant for 
> those cases)?

Ouch, thanks for catching that.  Somehow I managed not look at the
actual macro definition.  It is still needed for profiling builds.

What about the patch below instead?  I tested it on i386 with and
without profiling.

Thanks,
Florian
---

i386: Use more descriptive name for OPTIMIZE_FOR_GCC_5 macro

It is now called I386_USE_EBP_IN_ASM_CONSTRAINTS.

Remove GCC version checks for GCC 5.  CAN_USE_REGISTER_ASM_EBP is
always defined, so remove it (along with the configure check).

2019-02-01  Florian Weimer  <fweimer@redhat.com>

	i386: Update macro selection for the use of %ebp in asm constraints.
	* sysdeps/unix/sysv/linux/i386/sysdep.h
	(OPTIMIZE_FOR_GCC_5): Remove.
	(I386_USE_EBP_IN_ASM_CONSTRAINTS): Define based on PROF.  Use
	throughout the file instead of OPTIMIZE_FOR_GCC_5.
	(check_consistency): Remove.
	* elf/dl-load.c (_dl_map_object_from_fd): Remove call to
	check_consistency.
	* sysdeps/unix/sysv/linux/dl-execstack.c
	(_dl_make_stack_executable): Likewise.
	* config.h (CAN_USE_REGISTER_ASM_EBP): Remove.
	* sysdeps/unix/sysv/linux/i386/configure.ac: Remove check for
	CAN_USE_REGISTER_ASM_EBP.
	* sysdeps/unix/sysv/linux/i386/configure: Regenerate.
	* sysdeps/unix/sysv/linux/i386/libc-do-syscall.S: Use
	I386_USE_EBP_IN_ASM_CONSTRAINTS instead of OPTIMIZE_FOR_GCC_5.

diff --git a/config.h.in b/config.h.in
index f059ec0435..761e8a0942 100644
--- a/config.h.in
+++ b/config.h.in
@@ -255,8 +255,4 @@
 /* Define if static PIE is enabled.  */
 #define ENABLE_STATIC_PIE 0
 
-/* Some compiler options may now allow to use ebp in __asm__ (used mainly
-   in i386 6 argument syscall issue).  */
-#define CAN_USE_REGISTER_ASM_EBP 0
-
 #endif
diff --git a/elf/dl-load.c b/elf/dl-load.c
index f972524421..80c23446ba 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1281,10 +1281,6 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
 #endif
 	__stack_prot |= PROT_READ|PROT_WRITE|PROT_EXEC;
 
-#ifdef check_consistency
-      check_consistency ();
-#endif
-
       errval = (*GL(dl_make_stack_executable_hook)) (stack_endp);
       if (errval)
 	{
diff --git a/sysdeps/unix/sysv/linux/dl-execstack.c b/sysdeps/unix/sysv/linux/dl-execstack.c
index ac1aa72f3b..28f3bd90e0 100644
--- a/sysdeps/unix/sysv/linux/dl-execstack.c
+++ b/sysdeps/unix/sysv/linux/dl-execstack.c
@@ -50,10 +50,6 @@ _dl_make_stack_executable (void **stack_endp)
   GL(dl_stack_flags) |= PF_X;
 
  out:
-#ifdef check_consistency
-  check_consistency ();
-#endif
-
   return result;
 }
 rtld_hidden_def (_dl_make_stack_executable)
diff --git a/sysdeps/unix/sysv/linux/i386/configure b/sysdeps/unix/sysv/linux/i386/configure
index 0327590486..f119e62fc3 100644
--- a/sysdeps/unix/sysv/linux/i386/configure
+++ b/sysdeps/unix/sysv/linux/i386/configure
@@ -1,44 +1,5 @@
 # This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
  # Local configure fragment for sysdeps/unix/sysv/linux/i386.
 
-# Check if CFLAGS allows compiler to use ebp register in inline assembly.
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler flags allows ebp in inline assembly" >&5
-$as_echo_n "checking if compiler flags allows ebp in inline assembly... " >&6; }
-if ${libc_cv_can_use_register_asm_ebp+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-    void foo (int i)
-    {
-      register int reg asm ("ebp") = i;
-      asm ("# %0" : : "r" (reg));
-    }
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  libc_cv_can_use_register_asm_ebp=yes
-else
-  libc_cv_can_use_register_asm_ebp=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_can_use_register_asm_ebp" >&5
-$as_echo "$libc_cv_can_use_register_asm_ebp" >&6; }
-if test $libc_cv_can_use_register_asm_ebp = yes; then
-  $as_echo "#define CAN_USE_REGISTER_ASM_EBP 1" >>confdefs.h
-
-fi
-
 libc_cv_gcc_unwind_find_fde=yes
 ldd_rewrite_script=sysdeps/unix/sysv/linux/ldd-rewrite.sed
diff --git a/sysdeps/unix/sysv/linux/i386/configure.ac b/sysdeps/unix/sysv/linux/i386/configure.ac
index 9e980784bb..64ab2cc2c8 100644
--- a/sysdeps/unix/sysv/linux/i386/configure.ac
+++ b/sysdeps/unix/sysv/linux/i386/configure.ac
@@ -1,22 +1,5 @@
 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 # Local configure fragment for sysdeps/unix/sysv/linux/i386.
 
-# Check if CFLAGS allows compiler to use ebp register in inline assembly.
-AC_CACHE_CHECK([if compiler flags allows ebp in inline assembly],
-                libc_cv_can_use_register_asm_ebp, [
-AC_COMPILE_IFELSE(
-  [AC_LANG_PROGRAM([
-    void foo (int i)
-    {
-      register int reg asm ("ebp") = i;
-      asm ("# %0" : : "r" (reg));
-    }])],
-  [libc_cv_can_use_register_asm_ebp=yes],
-  [libc_cv_can_use_register_asm_ebp=no])
-])
-if test $libc_cv_can_use_register_asm_ebp = yes; then
-  AC_DEFINE(CAN_USE_REGISTER_ASM_EBP)
-fi
-
 libc_cv_gcc_unwind_find_fde=yes
 ldd_rewrite_script=sysdeps/unix/sysv/linux/ldd-rewrite.sed
diff --git a/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S b/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S
index 9119cfdf01..20841fb265 100644
--- a/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S
+++ b/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S
@@ -18,7 +18,7 @@
 
 #include <sysdep.h>
 
-#ifndef OPTIMIZE_FOR_GCC_5
+#if !I386_USE_EBP_IN_ASM_CONSTRAINTS
 
 /* %eax, %ecx, %edx and %esi contain the values expected by the kernel.
    %edi points to a structure with the values of %ebx, %edi and %ebp.  */
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 0be10744ff..e2f3fcf1ca 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -46,13 +46,12 @@
 # endif
 #endif
 
-/* Since GCC 5 and above can properly spill %ebx with PIC when needed,
-   we can inline syscalls with 6 arguments if GCC 5 or above is used
-   to compile glibc.  Disable GCC 5 optimization when compiling for
-   profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
-   can't be used to put the 6th argument in %ebp for syscall.  */
-#if __GNUC_PREREQ (5,0) && !defined PROF && CAN_USE_REGISTER_ASM_EBP
-# define OPTIMIZE_FOR_GCC_5
+/* When profiling is enabled, GCC cannot spill the %ebp register, so
+   it cannot be used directly in constraints in inline assembly.  */
+#ifdef PROF
+# define I386_USE_EBP_IN_ASM_CONSTRAINTS 0
+#else
+# define I386_USE_EBP_IN_ASM_CONSTRAINTS 1
 #endif
 
 #ifdef __ASSEMBLER__
@@ -241,7 +240,7 @@
 extern int __syscall_error (int)
   attribute_hidden __attribute__ ((__regparm__ (1)));
 
-#ifndef OPTIMIZE_FOR_GCC_5
+#if !I386_USE_EBP_IN_ASM_CONSTRAINTS
 /* We need some help from the assembler to generate optimal code.  We
    define some macros here which later will be used.  */
 asm (".L__X'%ebx = 1\n\t"
@@ -338,10 +337,10 @@ struct libc_do_syscall_args
     INTERNAL_SYSCALL_MAIN_INLINE(name, err, 5, args)
 /* Each object using 6-argument inline syscalls must include a
    definition of __libc_do_syscall.  */
-#ifdef OPTIMIZE_FOR_GCC_5
+#if I386_USE_EBP_IN_ASM_CONSTRAINTS
 # define INTERNAL_SYSCALL_MAIN_6(name, err, args...) \
     INTERNAL_SYSCALL_MAIN_INLINE(name, err, 6, args)
-#else /* GCC 5  */
+#else /* !I386_USE_EBP_IN_ASM_CONSTRAINTS  */
 # define INTERNAL_SYSCALL_MAIN_6(name, err, arg1, arg2, arg3,		\
 				 arg4, arg5, arg6)			\
   struct libc_do_syscall_args _xv =					\
@@ -356,14 +355,14 @@ struct libc_do_syscall_args
     : "=a" (resultvar)							\
     : "i" (__NR_##name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \
     : "memory", "cc")
-#endif /* GCC 5  */
+#endif /* !I386_USE_EBP_IN_ASM_CONSTRAINTS  */
 #define INTERNAL_SYSCALL(name, err, nr, args...) \
   ({									      \
     register unsigned int resultvar;					      \
     INTERNAL_SYSCALL_MAIN_##nr (name, err, args);			      \
     (int) resultvar; })
 #if I386_USE_SYSENTER
-# ifdef OPTIMIZE_FOR_GCC_5
+# if I386_USE_EBP_IN_ASM_CONSTRAINTS
 #  ifdef PIC
 #   define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
     LOADREGS_##nr(args)							\
@@ -399,7 +398,7 @@ struct libc_do_syscall_args
     : "a" (name) ASMARGS_##nr(args) : "memory", "cc");			\
     (int) resultvar; })
 #  endif
-# else /* GCC 5  */
+# else /* !I386_USE_EBP_IN_ASM_CONSTRAINTS  */
 #  ifdef PIC
 #   define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
     EXTRAVAR_##nr							      \
@@ -445,9 +444,9 @@ struct libc_do_syscall_args
     : "0" (name) ASMFMT_##nr(args) : "memory", "cc");			      \
     (int) resultvar; })
 #  endif
-# endif /* GCC 5  */
+# endif /* !I386_USE_EBP_IN_ASM_CONSTRAINTS  */
 #else
-# ifdef OPTIMIZE_FOR_GCC_5
+# if I386_USE_EBP_IN_ASM_CONSTRAINTS
 #  define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
@@ -463,7 +462,7 @@ struct libc_do_syscall_args
     : "=a" (resultvar)							\
     : "a" (name) ASMARGS_##nr(args) : "memory", "cc");			\
     (int) resultvar; })
-# else /* GCC 5  */
+# else /* !I386_USE_EBP_IN_ASM_CONSTRAINTS  */
 #  define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
     EXTRAVAR_##nr							      \
     asm volatile (							      \
@@ -484,7 +483,7 @@ struct libc_do_syscall_args
     : "=a" (resultvar)							      \
     : "0" (name) ASMFMT_##nr(args) : "memory", "cc");			      \
     (int) resultvar; })
-# endif /* GCC 5  */
+# endif /* !I386_USE_EBP_IN_ASM_CONSTRAINTS  */
 #endif
 
 #undef INTERNAL_SYSCALL_DECL
@@ -549,7 +548,7 @@ struct libc_do_syscall_args
 # define RESTOREARGS_5
 #endif
 
-#ifdef OPTIMIZE_FOR_GCC_5
+#if I386_USE_EBP_IN_ASM_CONSTRAINTS
 # define LOADREGS_0()
 # define ASMARGS_0()
 # define LOADREGS_1(arg1) \
@@ -577,7 +576,7 @@ struct libc_do_syscall_args
 	LOADREGS_5 (arg1, arg2, arg3, arg4, arg5)
 # define ASMARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
 	ASMARGS_5 (arg1, arg2, arg3, arg4, arg5), "r" (_a6)
-#endif /* GCC 5  */
+#endif /* !I386_USE_EBP_IN_ASM_CONSTRAINTS  */
 
 #define ASMFMT_0()
 #ifdef __PIC__
@@ -615,20 +614,6 @@ struct libc_do_syscall_args
 # define EXTRAVAR_5
 #endif
 
-/* Consistency check for position-independent code.  */
-#if defined __PIC__ && !defined OPTIMIZE_FOR_GCC_5
-# define check_consistency()						      \
-  ({ int __res;								      \
-     __asm__ __volatile__						      \
-       (LOAD_PIC_REG_STR (cx) ";"					      \
-	"subl %%ebx, %%ecx;"						      \
-	"je 1f;"							      \
-	"ud2;"								      \
-	"1:\n"								      \
-	: "=c" (__res));						      \
-     __res; })
-#endif
-
 #endif	/* __ASSEMBLER__ */
 
 
--
Work around Zimbra bug.
Joseph Myers Feb. 1, 2019, 4:35 p.m. UTC | #3
On Fri, 1 Feb 2019, Florian Weimer wrote:

> What about the patch below instead?  I tested it on i386 with and
> without profiling.

What about -fno-omit-frame-pointer?  CAN_USE_REGISTER_ASM_EBP is also for 
that.
Florian Weimer Feb. 2, 2019, 12:58 p.m. UTC | #4
* Joseph Myers:

> On Fri, 1 Feb 2019, Florian Weimer wrote:
>
>> What about the patch below instead?  I tested it on i386 with and
>> without profiling.
>
> What about -fno-omit-frame-pointer?  CAN_USE_REGISTER_ASM_EBP is also for 
> that.

Well, this is getting embarrassing.  Here's the next attempt.  This time
tested on i386 (four builds, with/without -fno-omit-frame-pointer,
--enable-profile) and x86-64.

Not much can in fact be removed, but I think it's still worthwhile to
use a more descriptive macro and document the situation in comments.

Thanks,
Florian

i386: Use I386_USE_REGISTER_ASM_EBP instead of OPTIMIZE_FOR_GCC_5

Make I386_USE_REGISTER_ASM_EBP always defined, with 0 or 1 as
appropriate, relying on CAN_USE_REGISTER_ASM_EBP for the non-profiling
case.  (CAN_USE_REGISTER_ASM_EBP continues to reflect the compiler
behavior with default/user-specified flags.)

Remove the check_consistency hardening check.  %ebx is not preserved
in non-profiling, non-frame-pointer builds (the default), so the
check was already disabled in most configurations.

2019-02-01  Florian Weimer  <fweimer@redhat.com>

	* sysdeps/unix/sysv/linux/i386/sysdep.h
	(OPTIMIZE_FOR_GCC_5): Remove.
	(I386_USE_REGISTER_ASM_EBP): New macro. Replace references to
	OPTIMIZE_FOR_GCC_5 throughout the this file.
	(check_consistency): Remove.
	* elf/dl-load.c (_dl_map_object_from_fd): Remove call to
	check_consistency.
	* sysdeps/unix/sysv/linux/dl-execstack.c
	(_dl_make_stack_executable): Likewise.
	* config.h.in (CAN_USE_REGISTER_ASM): Update comment.
	* sysdeps/unix/sysv/linux/i386/libc-do-syscall.S: Use
	I386_USE_REGISTER_ASM_EBP instead of OPTIMIZE_FOR_GCC_5.

diff --git a/config.h.in b/config.h.in
index f059ec0435..a21c31cc96 100644
--- a/config.h.in
+++ b/config.h.in
@@ -255,8 +255,13 @@
 /* Define if static PIE is enabled.  */
 #define ENABLE_STATIC_PIE 0
 
-/* Some compiler options may now allow to use ebp in __asm__ (used mainly
-   in i386 6 argument syscall issue).  */
+/* Some configurations may not allow to use of the i386 %ebp register
+   in inline assembly.  In this case, this macro is defined as 0.
+   Note that this macro only reflects the compiler behavior with the
+   default/user-specified flags.  Profiling builds can never use %ebp
+   in this way because they require a frame pointer.  See
+   I386_USE_REGISTER_EBP in sysdeps/unix/sysv/linux/i386/sysdep.h for
+   the macro that actual code should check.  */
 #define CAN_USE_REGISTER_ASM_EBP 0
 
 #endif
diff --git a/elf/dl-load.c b/elf/dl-load.c
index f972524421..80c23446ba 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1281,10 +1281,6 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
 #endif
 	__stack_prot |= PROT_READ|PROT_WRITE|PROT_EXEC;
 
-#ifdef check_consistency
-      check_consistency ();
-#endif
-
       errval = (*GL(dl_make_stack_executable_hook)) (stack_endp);
       if (errval)
 	{
diff --git a/sysdeps/unix/sysv/linux/dl-execstack.c b/sysdeps/unix/sysv/linux/dl-execstack.c
index ac1aa72f3b..28f3bd90e0 100644
--- a/sysdeps/unix/sysv/linux/dl-execstack.c
+++ b/sysdeps/unix/sysv/linux/dl-execstack.c
@@ -50,10 +50,6 @@ _dl_make_stack_executable (void **stack_endp)
   GL(dl_stack_flags) |= PF_X;
 
  out:
-#ifdef check_consistency
-  check_consistency ();
-#endif
-
   return result;
 }
 rtld_hidden_def (_dl_make_stack_executable)
diff --git a/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S b/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S
index 9119cfdf01..4361c6ec3c 100644
--- a/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S
+++ b/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S
@@ -18,7 +18,7 @@
 
 #include <sysdep.h>
 
-#ifndef OPTIMIZE_FOR_GCC_5
+#if !I386_USE_REGISTER_ASM_EBP
 
 /* %eax, %ecx, %edx and %esi contain the values expected by the kernel.
    %edi points to a structure with the values of %ebx, %edi and %ebp.  */
@@ -50,4 +50,4 @@ ENTRY (__libc_do_syscall)
 	cfi_restore (ebx)
 	ret
 END (__libc_do_syscall)
-#endif
+#endif /* !I386_USE_REGISTER_ASM_EBP */
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 0be10744ff..033e10a322 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -29,7 +29,6 @@
 #include <dl-sysdep.h>
 #include <tls.h>
 
-
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
    of the kernel.  But these symbols do not follow the SYS_* syntax
@@ -46,15 +45,19 @@
 # endif
 #endif
 
-/* Since GCC 5 and above can properly spill %ebx with PIC when needed,
-   we can inline syscalls with 6 arguments if GCC 5 or above is used
-   to compile glibc.  Disable GCC 5 optimization when compiling for
-   profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
-   can't be used to put the 6th argument in %ebp for syscall.  */
-#if __GNUC_PREREQ (5,0) && !defined PROF && CAN_USE_REGISTER_ASM_EBP
-# define OPTIMIZE_FOR_GCC_5
+/* Indicator for whether inline assembly can use the %ebp register.
+   The configure script only detects the compiler behavior with
+   default compiler flags.  In a profiling build, a frame pointer is
+   always required, so %ebp is never usable.  Code should always check
+   I386_USE_REGISTER_ASM_EBP for this reason, and not
+   CAN_USE_REGISTER_ASM_EBP.  */
+#ifdef PROF
+# define I386_USE_REGISTER_ASM_EBP 0
+#else
+# define I386_USE_REGISTER_ASM_EBP CAN_USE_REGISTER_ASM_EBP
 #endif
 
+
 #ifdef __ASSEMBLER__
 
 /* Linux uses a negative return value to indicate syscall errors,
@@ -241,7 +244,7 @@
 extern int __syscall_error (int)
   attribute_hidden __attribute__ ((__regparm__ (1)));
 
-#ifndef OPTIMIZE_FOR_GCC_5
+#if !I386_USE_REGISTER_ASM_EBP
 /* We need some help from the assembler to generate optimal code.  We
    define some macros here which later will be used.  */
 asm (".L__X'%ebx = 1\n\t"
@@ -338,10 +341,10 @@ struct libc_do_syscall_args
     INTERNAL_SYSCALL_MAIN_INLINE(name, err, 5, args)
 /* Each object using 6-argument inline syscalls must include a
    definition of __libc_do_syscall.  */
-#ifdef OPTIMIZE_FOR_GCC_5
+#if I386_USE_REGISTER_ASM_EBP
 # define INTERNAL_SYSCALL_MAIN_6(name, err, args...) \
     INTERNAL_SYSCALL_MAIN_INLINE(name, err, 6, args)
-#else /* GCC 5  */
+#else /* !I386_USE_REGISTER_ASM_EBP */
 # define INTERNAL_SYSCALL_MAIN_6(name, err, arg1, arg2, arg3,		\
 				 arg4, arg5, arg6)			\
   struct libc_do_syscall_args _xv =					\
@@ -356,14 +359,14 @@ struct libc_do_syscall_args
     : "=a" (resultvar)							\
     : "i" (__NR_##name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \
     : "memory", "cc")
-#endif /* GCC 5  */
+#endif /* !I386_USE_REGISTER_ASM_EBP */
 #define INTERNAL_SYSCALL(name, err, nr, args...) \
   ({									      \
     register unsigned int resultvar;					      \
     INTERNAL_SYSCALL_MAIN_##nr (name, err, args);			      \
     (int) resultvar; })
 #if I386_USE_SYSENTER
-# ifdef OPTIMIZE_FOR_GCC_5
+# if I386_USE_REGISTER_ASM_EBP
 #  ifdef PIC
 #   define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
     LOADREGS_##nr(args)							\
@@ -399,7 +402,7 @@ struct libc_do_syscall_args
     : "a" (name) ASMARGS_##nr(args) : "memory", "cc");			\
     (int) resultvar; })
 #  endif
-# else /* GCC 5  */
+# else /* !I386_USE_REGISTER_ASM_EBP */
 #  ifdef PIC
 #   define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
     EXTRAVAR_##nr							      \
@@ -445,9 +448,9 @@ struct libc_do_syscall_args
     : "0" (name) ASMFMT_##nr(args) : "memory", "cc");			      \
     (int) resultvar; })
 #  endif
-# endif /* GCC 5  */
+# endif /* !I386_USE_REGISTER_ASM_EBP */
 #else
-# ifdef OPTIMIZE_FOR_GCC_5
+# if I386_USE_REGISTER_ASM_EBP
 #  define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
@@ -463,7 +466,7 @@ struct libc_do_syscall_args
     : "=a" (resultvar)							\
     : "a" (name) ASMARGS_##nr(args) : "memory", "cc");			\
     (int) resultvar; })
-# else /* GCC 5  */
+# else /* !I386_USE_REGISTER_ASM_EBP */
 #  define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
     EXTRAVAR_##nr							      \
     asm volatile (							      \
@@ -484,7 +487,7 @@ struct libc_do_syscall_args
     : "=a" (resultvar)							      \
     : "0" (name) ASMFMT_##nr(args) : "memory", "cc");			      \
     (int) resultvar; })
-# endif /* GCC 5  */
+# endif /* !I386_USE_REGISTER_ASM_EBP */
 #endif
 
 #undef INTERNAL_SYSCALL_DECL
@@ -549,7 +552,7 @@ struct libc_do_syscall_args
 # define RESTOREARGS_5
 #endif
 
-#ifdef OPTIMIZE_FOR_GCC_5
+#if I386_USE_REGISTER_ASM_EBP
 # define LOADREGS_0()
 # define ASMARGS_0()
 # define LOADREGS_1(arg1) \
@@ -577,7 +580,7 @@ struct libc_do_syscall_args
 	LOADREGS_5 (arg1, arg2, arg3, arg4, arg5)
 # define ASMARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
 	ASMARGS_5 (arg1, arg2, arg3, arg4, arg5), "r" (_a6)
-#endif /* GCC 5  */
+#endif /* !I386_USE_REGISTER_ASM_EBP */
 
 #define ASMFMT_0()
 #ifdef __PIC__
@@ -615,20 +618,6 @@ struct libc_do_syscall_args
 # define EXTRAVAR_5
 #endif
 
-/* Consistency check for position-independent code.  */
-#if defined __PIC__ && !defined OPTIMIZE_FOR_GCC_5
-# define check_consistency()						      \
-  ({ int __res;								      \
-     __asm__ __volatile__						      \
-       (LOAD_PIC_REG_STR (cx) ";"					      \
-	"subl %%ebx, %%ecx;"						      \
-	"je 1f;"							      \
-	"ud2;"								      \
-	"1:\n"								      \
-	: "=c" (__res));						      \
-     __res; })
-#endif
-
 #endif	/* __ASSEMBLER__ */
diff mbox series

Patch

diff --git a/elf/dl-load.c b/elf/dl-load.c
index f972524421..80c23446ba 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1281,10 +1281,6 @@  _dl_map_object_from_fd (const char *name, const char *origname, int fd,
 #endif
 	__stack_prot |= PROT_READ|PROT_WRITE|PROT_EXEC;
 
-#ifdef check_consistency
-      check_consistency ();
-#endif
-
       errval = (*GL(dl_make_stack_executable_hook)) (stack_endp);
       if (errval)
 	{
diff --git a/sysdeps/unix/sysv/linux/dl-execstack.c b/sysdeps/unix/sysv/linux/dl-execstack.c
index ac1aa72f3b..28f3bd90e0 100644
--- a/sysdeps/unix/sysv/linux/dl-execstack.c
+++ b/sysdeps/unix/sysv/linux/dl-execstack.c
@@ -50,10 +50,6 @@  _dl_make_stack_executable (void **stack_endp)
   GL(dl_stack_flags) |= PF_X;
 
  out:
-#ifdef check_consistency
-  check_consistency ();
-#endif
-
   return result;
 }
 rtld_hidden_def (_dl_make_stack_executable)
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 0be10744ff..7bfb42dbbb 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -241,48 +241,6 @@ 
 extern int __syscall_error (int)
   attribute_hidden __attribute__ ((__regparm__ (1)));
 
-#ifndef OPTIMIZE_FOR_GCC_5
-/* We need some help from the assembler to generate optimal code.  We
-   define some macros here which later will be used.  */
-asm (".L__X'%ebx = 1\n\t"
-     ".L__X'%ecx = 2\n\t"
-     ".L__X'%edx = 2\n\t"
-     ".L__X'%eax = 3\n\t"
-     ".L__X'%esi = 3\n\t"
-     ".L__X'%edi = 3\n\t"
-     ".L__X'%ebp = 3\n\t"
-     ".L__X'%esp = 3\n\t"
-     ".macro bpushl name reg\n\t"
-     ".if 1 - \\name\n\t"
-     ".if 2 - \\name\n\t"
-     "error\n\t"
-     ".else\n\t"
-     "xchgl \\reg, %ebx\n\t"
-     ".endif\n\t"
-     ".endif\n\t"
-     ".endm\n\t"
-     ".macro bpopl name reg\n\t"
-     ".if 1 - \\name\n\t"
-     ".if 2 - \\name\n\t"
-     "error\n\t"
-     ".else\n\t"
-     "xchgl \\reg, %ebx\n\t"
-     ".endif\n\t"
-     ".endif\n\t"
-     ".endm\n\t");
-
-/* Six-argument syscalls use an out-of-line helper, because an inline
-   asm using all registers apart from %esp cannot work reliably and
-   the assembler does not support describing an asm that saves and
-   restores %ebp itself as a separate stack frame.  This structure
-   stores the arguments not passed in registers; %edi is passed with a
-   pointer to this structure.  */
-struct libc_do_syscall_args
-{
-  int ebx, edi, ebp;
-};
-#endif
-
 /* Define a macro which expands inline into the wrapper code for a system
    call.  */
 #undef INLINE_SYSCALL
@@ -336,43 +294,23 @@  struct libc_do_syscall_args
     INTERNAL_SYSCALL_MAIN_INLINE(name, err, 4, args)
 #define INTERNAL_SYSCALL_MAIN_5(name, err, args...) \
     INTERNAL_SYSCALL_MAIN_INLINE(name, err, 5, args)
-/* Each object using 6-argument inline syscalls must include a
-   definition of __libc_do_syscall.  */
-#ifdef OPTIMIZE_FOR_GCC_5
-# define INTERNAL_SYSCALL_MAIN_6(name, err, args...) \
+#define INTERNAL_SYSCALL_MAIN_6(name, err, args...) \
     INTERNAL_SYSCALL_MAIN_INLINE(name, err, 6, args)
-#else /* GCC 5  */
-# define INTERNAL_SYSCALL_MAIN_6(name, err, arg1, arg2, arg3,		\
-				 arg4, arg5, arg6)			\
-  struct libc_do_syscall_args _xv =					\
-    {									\
-      (int) (arg1),							\
-      (int) (arg5),							\
-      (int) (arg6)							\
-    };									\
-    asm volatile (							\
-    "movl %1, %%eax\n\t"						\
-    "call __libc_do_syscall"						\
-    : "=a" (resultvar)							\
-    : "i" (__NR_##name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \
-    : "memory", "cc")
-#endif /* GCC 5  */
 #define INTERNAL_SYSCALL(name, err, nr, args...) \
   ({									      \
     register unsigned int resultvar;					      \
     INTERNAL_SYSCALL_MAIN_##nr (name, err, args);			      \
     (int) resultvar; })
 #if I386_USE_SYSENTER
-# ifdef OPTIMIZE_FOR_GCC_5
-#  ifdef PIC
-#   define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+# ifdef PIC
+#  define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
     "call *%%gs:%P2"							\
     : "=a" (resultvar)							\
     : "a" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo))		\
       ASMARGS_##nr(args) : "memory", "cc")
-#   define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+#  define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
   ({									\
     register unsigned int resultvar;					\
     LOADREGS_##nr(args)							\
@@ -382,14 +320,14 @@  struct libc_do_syscall_args
     : "a" (name), "i" (offsetof (tcbhead_t, sysinfo))			\
       ASMARGS_##nr(args) : "memory", "cc");				\
     (int) resultvar; })
-#  else
-#   define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+# else
+#  define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
     "call *_dl_sysinfo"							\
     : "=a" (resultvar)							\
     : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc")
-#   define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+#  define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
   ({									\
     register unsigned int resultvar;					\
     LOADREGS_##nr(args)							\
@@ -398,63 +336,15 @@  struct libc_do_syscall_args
     : "=a" (resultvar)							\
     : "a" (name) ASMARGS_##nr(args) : "memory", "cc");			\
     (int) resultvar; })
-#  endif
-# else /* GCC 5  */
-#  ifdef PIC
-#   define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
-    EXTRAVAR_##nr							      \
-    asm volatile (							      \
-    LOADARGS_##nr							      \
-    "movl %1, %%eax\n\t"						      \
-    "call *%%gs:%P2\n\t"						      \
-    RESTOREARGS_##nr							      \
-    : "=a" (resultvar)							      \
-    : "i" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo))		      \
-      ASMFMT_##nr(args) : "memory", "cc")
-#   define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
-  ({									      \
-    register unsigned int resultvar;					      \
-    EXTRAVAR_##nr							      \
-    asm volatile (							      \
-    LOADARGS_##nr							      \
-    "call *%%gs:%P2\n\t"						      \
-    RESTOREARGS_##nr							      \
-    : "=a" (resultvar)							      \
-    : "0" (name), "i" (offsetof (tcbhead_t, sysinfo))			      \
-      ASMFMT_##nr(args) : "memory", "cc");				      \
-    (int) resultvar; })
-#  else
-#   define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
-    EXTRAVAR_##nr							      \
-    asm volatile (							      \
-    LOADARGS_##nr							      \
-    "movl %1, %%eax\n\t"						      \
-    "call *_dl_sysinfo\n\t"						      \
-    RESTOREARGS_##nr							      \
-    : "=a" (resultvar)							      \
-    : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
-#   define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
-  ({									      \
-    register unsigned int resultvar;					      \
-    EXTRAVAR_##nr							      \
-    asm volatile (							      \
-    LOADARGS_##nr							      \
-    "call *_dl_sysinfo\n\t"						      \
-    RESTOREARGS_##nr							      \
-    : "=a" (resultvar)							      \
-    : "0" (name) ASMFMT_##nr(args) : "memory", "cc");			      \
-    (int) resultvar; })
-#  endif
-# endif /* GCC 5  */
+# endif
 #else
-# ifdef OPTIMIZE_FOR_GCC_5
-#  define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
     "int $0x80"								\
     : "=a" (resultvar)							\
     : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc")
-#  define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
   ({									\
     register unsigned int resultvar;					\
     LOADREGS_##nr(args)							\
@@ -463,28 +353,6 @@  struct libc_do_syscall_args
     : "=a" (resultvar)							\
     : "a" (name) ASMARGS_##nr(args) : "memory", "cc");			\
     (int) resultvar; })
-# else /* GCC 5  */
-#  define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
-    EXTRAVAR_##nr							      \
-    asm volatile (							      \
-    LOADARGS_##nr							      \
-    "movl %1, %%eax\n\t"						      \
-    "int $0x80\n\t"							      \
-    RESTOREARGS_##nr							      \
-    : "=a" (resultvar)							      \
-    : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
-#  define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
-  ({									      \
-    register unsigned int resultvar;					      \
-    EXTRAVAR_##nr							      \
-    asm volatile (							      \
-    LOADARGS_##nr							      \
-    "int $0x80\n\t"							      \
-    RESTOREARGS_##nr							      \
-    : "=a" (resultvar)							      \
-    : "0" (name) ASMFMT_##nr(args) : "memory", "cc");			      \
-    (int) resultvar; })
-# endif /* GCC 5  */
 #endif
 
 #undef INTERNAL_SYSCALL_DECL
@@ -549,35 +417,33 @@  struct libc_do_syscall_args
 # define RESTOREARGS_5
 #endif
 
-#ifdef OPTIMIZE_FOR_GCC_5
-# define LOADREGS_0()
-# define ASMARGS_0()
-# define LOADREGS_1(arg1) \
+#define LOADREGS_0()
+#define ASMARGS_0()
+#define LOADREGS_1(arg1) \
 	LOADREGS_0 ()
-# define ASMARGS_1(arg1) \
+#define ASMARGS_1(arg1) \
 	ASMARGS_0 (), "b" ((unsigned int) (arg1))
-# define LOADREGS_2(arg1, arg2) \
+#define LOADREGS_2(arg1, arg2) \
 	LOADREGS_1 (arg1)
-# define ASMARGS_2(arg1, arg2) \
+#define ASMARGS_2(arg1, arg2) \
 	ASMARGS_1 (arg1), "c" ((unsigned int) (arg2))
-# define LOADREGS_3(arg1, arg2, arg3) \
+#define LOADREGS_3(arg1, arg2, arg3) \
 	LOADREGS_2 (arg1, arg2)
-# define ASMARGS_3(arg1, arg2, arg3) \
+#define ASMARGS_3(arg1, arg2, arg3) \
 	ASMARGS_2 (arg1, arg2), "d" ((unsigned int) (arg3))
-# define LOADREGS_4(arg1, arg2, arg3, arg4) \
+#define LOADREGS_4(arg1, arg2, arg3, arg4) \
 	LOADREGS_3 (arg1, arg2, arg3)
-# define ASMARGS_4(arg1, arg2, arg3, arg4) \
+#define ASMARGS_4(arg1, arg2, arg3, arg4) \
 	ASMARGS_3 (arg1, arg2, arg3), "S" ((unsigned int) (arg4))
-# define LOADREGS_5(arg1, arg2, arg3, arg4, arg5) \
+#define LOADREGS_5(arg1, arg2, arg3, arg4, arg5) \
 	LOADREGS_4 (arg1, arg2, arg3, arg4)
-# define ASMARGS_5(arg1, arg2, arg3, arg4, arg5) \
+#define ASMARGS_5(arg1, arg2, arg3, arg4, arg5) \
 	ASMARGS_4 (arg1, arg2, arg3, arg4), "D" ((unsigned int) (arg5))
-# define LOADREGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
+#define LOADREGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
 	register unsigned int _a6 asm ("ebp") = (unsigned int) (arg6); \
 	LOADREGS_5 (arg1, arg2, arg3, arg4, arg5)
-# define ASMARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
+#define ASMARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
 	ASMARGS_5 (arg1, arg2, arg3, arg4, arg5), "r" (_a6)
-#endif /* GCC 5  */
 
 #define ASMFMT_0()
 #ifdef __PIC__
@@ -615,20 +481,6 @@  struct libc_do_syscall_args
 # define EXTRAVAR_5
 #endif
 
-/* Consistency check for position-independent code.  */
-#if defined __PIC__ && !defined OPTIMIZE_FOR_GCC_5
-# define check_consistency()						      \
-  ({ int __res;								      \
-     __asm__ __volatile__						      \
-       (LOAD_PIC_REG_STR (cx) ";"					      \
-	"subl %%ebx, %%ecx;"						      \
-	"je 1f;"							      \
-	"ud2;"								      \
-	"1:\n"								      \
-	: "=c" (__res));						      \
-     __res; })
-#endif
-
 #endif	/* __ASSEMBLER__ */