This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
PATCH: Add x32 support to STACK_CHK_GUARD
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Fri, 11 May 2012 09:13:47 -0700
- Subject: PATCH: Add x32 support to STACK_CHK_GUARD
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
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; })