PATCH: Add x32 support to STACK_CHK_GUARD

H.J. Lu hongjiu.lu@intel.com
Fri May 11 16:17:00 GMT 2012


Hi,

This patch adds x32 support to STACK_CHK_GUARD.  Tested on Linux/x32
and Linux/x86-64.  OK to install?

Thanks.


H.J.
--
	* elf/stackguard-macros.h (STACK_CHK_GUARD): Add x32 version.

diff --git a/elf/stackguard-macros.h b/elf/stackguard-macros.h
index a9889cf..e9b15f5 100644
--- a/elf/stackguard-macros.h
+++ b/elf/stackguard-macros.h
@@ -4,8 +4,13 @@
 # define STACK_CHK_GUARD \
   ({ uintptr_t x; asm ("movl %%gs:0x14, %0" : "=r" (x)); x; })
 #elif defined __x86_64__
-# define STACK_CHK_GUARD \
+# ifdef __ILP32__
+#  define STACK_CHK_GUARD \
+  ({ uintptr_t x; asm ("movl %%fs:0x18, %0" : "=r" (x)); x; })
+# else
+#  define STACK_CHK_GUARD \
   ({ uintptr_t x; asm ("movq %%fs:0x28, %0" : "=r" (x)); x; })
+# endif
 #elif defined __powerpc64__
 # define STACK_CHK_GUARD \
   ({ uintptr_t x; asm ("ld %0,-28688(13)" : "=r" (x)); x; })



More information about the Libc-alpha mailing list