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]

PATCH: Add x32 support to STACK_CHK_GUARD


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; })


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