This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix build with compiler defining __i686 (bug 411)


On Fri, 3 Feb 2012, Roland McGrath wrote:

> > There is exactly one such inline asm instance.  You mean add a macro 
> > expanding to a string version of LOAD_PIC_REG (for that is what 
> > check_consistency in sysdeps/unix/sysv/linux/i386/sysdep.h is doing) and 
> > use it in that one place?
> 
> I guess so, yes.

This patch does that.  (It can't be done by stringizing SETUP_PIC_REG / 
LOAD_PIC_REG because these strings are for use inside asm statements, so 
also need to double % on register names.)  This one does pass comparison 
of disassembly (the first two patches presumably having caused the cx 
thunk to be aligned without needing the extra alignment specifier on this 
one as well).

I've committed the first two patches.

2012-02-04  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/i386/sysdep.h (SETUP_PIC_REG_STR, LOAD_PIC_REG_STR):
	Define.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (check_consistency): Use
	LOAD_PIC_REG_STR.

diff --git a/sysdeps/i386/sysdep.h b/sysdeps/i386/sysdep.h
index a31f5e7..36c678d 100644
--- a/sysdeps/i386/sysdep.h
+++ b/sysdeps/i386/sysdep.h
@@ -156,4 +156,24 @@ GET_PC_THUNK(reg):							      \
 
 #define atom_text_section .section ".text.atom", "ax"
 
+#else /* __ASSEMBLER__ */
+
+# define SETUP_PIC_REG_STR(reg)						\
+  ".ifndef "GET_PC_THUNK_STR(reg)";"					\
+  ".section .gnu.linkonce.t."GET_PC_THUNK_STR(reg)",\"ax\",@progbits;"	\
+  ".globl "GET_PC_THUNK_STR(reg)";"					\
+  ".hidden "GET_PC_THUNK_STR(reg)";"					\
+  ".p2align 4;"								\
+  ".type "GET_PC_THUNK_STR(reg)",@function;"				\
+GET_PC_THUNK_STR(reg)":"						\
+  "movl (%%esp), %%e"#reg";"						\
+  "ret;"								\
+  ".size "GET_PC_THUNK_STR(reg)", . - "GET_PC_THUNK_STR(reg)";"		\
+  ".previous;"								\
+  ".endif;"								\
+  "call "GET_PC_THUNK_STR(reg)
+
+# define LOAD_PIC_REG_STR(reg) \
+  SETUP_PIC_REG_STR(reg)"; addl $_GLOBAL_OFFSET_TABLE_, %%e"#reg
+
 #endif	/* __ASSEMBLER__ */
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 90660fd..b47a0fb 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -514,20 +514,11 @@ asm (".L__X'%ebx = 1\n\t"
 # define check_consistency()						      \
   ({ int __res;								      \
      __asm__ __volatile__						      \
-       ("call "GET_PC_THUNK_STR(cx)";"					      \
-	"addl $_GLOBAL_OFFSET_TABLE_, %%ecx;"				      \
+       (LOAD_PIC_REG_STR(cx)";"						      \
 	"subl %%ebx, %%ecx;"						      \
 	"je 1f;"							      \
 	"ud2;"								      \
 	"1:\n"								      \
-	".section .gnu.linkonce.t."GET_PC_THUNK_STR(cx)",\"ax\",@progbits;"   \
-	".globl "GET_PC_THUNK_STR(cx)";"				      \
-	".hidden "GET_PC_THUNK_STR(cx)";"				      \
-	".type "GET_PC_THUNK_STR(cx)",@function;"			      \
-	GET_PC_THUNK_STR(cx)":"						      \
-	"movl (%%esp), %%ecx;"						      \
-	"ret;"								      \
-	".previous"							      \
 	: "=c" (__res));						      \
      __res; })
 #endif

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]