[PATCH v3 2/4] x86: Simplify stack and pointer guard macros
Uros Bizjak
ubizjak@gmail.com
Wed Oct 1 12:30:13 GMT 2025
Replace manual casts with a direct `(__tcbhead_t __seg_gs *)0`
dereferences for `stack_guard` and `pointer_guard`. This makes
the macros more straightforward and removes the dependency on
<stdint.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
---
sysdeps/i386/stackguard-macros.h | 8 ++------
sysdeps/x86_64/stackguard-macros.h | 8 ++------
2 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/sysdeps/i386/stackguard-macros.h b/sysdeps/i386/stackguard-macros.h
index 574a409584..2939934ef1 100644
--- a/sysdeps/i386/stackguard-macros.h
+++ b/sysdeps/i386/stackguard-macros.h
@@ -1,7 +1,3 @@
-#include <stdint.h>
+#define STACK_CHK_GUARD (((tcbhead_t __seg_gs *)0)->stack_guard)
-#define STACK_CHK_GUARD \
- (*(uintptr_t __seg_gs *) offsetof (tcbhead_t, stack_guard))
-
-#define POINTER_CHK_GUARD \
- (*(uintptr_t __seg_gs *) offsetof (tcbhead_t, pointer_guard))
+#define POINTER_CHK_GUARD (((tcbhead_t __seg_gs *)0)->pointer_guard)
diff --git a/sysdeps/x86_64/stackguard-macros.h b/sysdeps/x86_64/stackguard-macros.h
index 1d4c620ff1..77f13c986d 100644
--- a/sysdeps/x86_64/stackguard-macros.h
+++ b/sysdeps/x86_64/stackguard-macros.h
@@ -1,7 +1,3 @@
-#include <stdint.h>
+#define STACK_CHK_GUARD (((tcbhead_t __seg_fs *)0)->stack_guard)
-#define STACK_CHK_GUARD \
- (*(uintptr_t __seg_fs *) offsetof (tcbhead_t, stack_guard))
-
-#define POINTER_CHK_GUARD \
- (*(uintptr_t __seg_fs *) offsetof (tcbhead_t, pointer_guard))
+#define POINTER_CHK_GUARD (((tcbhead_t __seg_fs *)0)->pointer_guard)
--
2.51.0
More information about the Libc-alpha
mailing list