]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Remove the jmp_buf stack pointer demangle on ABIs that do not mangle it
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 12 Jun 2026 16:10:13 +0000 (13:10 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 16 Jun 2026 17:53:29 +0000 (14:53 -0300)
arc, m68k, microblaze, mips, and riscv store the raw stack pointer in
setjmp, while their jmpbuf-unwind.h applies PTR_DEMANGLE to it in
_jmpbuf_sp.  This is currently harmless because these ABIs use the
generic pointer_guard.h, where the C PTR_DEMANGLE is a no-op.

No functional change.

Reviewed-by: DJ Delorie <dj@redhat.com>
sysdeps/arc/jmpbuf-unwind.h
sysdeps/m68k/jmpbuf-unwind.h
sysdeps/microblaze/jmpbuf-unwind.h
sysdeps/mips/jmpbuf-unwind.h
sysdeps/riscv/jmpbuf-unwind.h

index d007c785649788bbf22b5a381b4bcfbf202112a8..48a9f9a7c531b8319da7e1c0d6c635c6503cea4b 100644 (file)
@@ -20,7 +20,6 @@
 #include <jmpbuf-offsets.h>
 #include <stdint.h>
 #include <unwind.h>
-#include <pointer_guard.h>
 
 /* Test if longjmp to JMPBUF would unwind the frame
    containing a local variable at ADDRESS.  */
 #define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
   _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
 
+/* setjmp does not mangle the stack pointer on this ABI, so the saved
+   value is used as-is.  */
 static inline uintptr_t __attribute__ ((unused))
 _jmpbuf_sp (__jmp_buf jmpbuf)
 {
-  uintptr_t sp = jmpbuf[JB_SP];
-  PTR_DEMANGLE (sp);
-  return sp;
+  return jmpbuf[JB_SP];
 }
 
 #define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
index 9c5206fb69f813a4e926daaacc679a0fa1271f78..2f4bc71d5bcfc7488dcf5bfa32491ebe909c521f 100644 (file)
@@ -19,7 +19,6 @@
 #include <setjmp.h>
 #include <stdint.h>
 #include <unwind.h>
-#include <pointer_guard.h>
 
 /* Test if longjmp to JMPBUF would unwind the frame
    containing a local variable at ADDRESS.  */
 #define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
   _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
 
+/* setjmp does not mangle the stack pointer on this ABI, so the saved
+   value is used as-is.  */
 static inline uintptr_t __attribute__ ((unused))
 _jmpbuf_sp (__jmp_buf regs)
 {
-  uintptr_t sp = (uintptr_t) regs[0].__sp;
-  PTR_DEMANGLE (sp);
-  return sp;
+  return (uintptr_t) regs[0].__sp;
 }
 
 #define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
index cb28dd83ec4508aa331e2f0da50c57594df9a8c1..9584203257a3e9daafb82ea478b4e933ea857a25 100644 (file)
@@ -20,7 +20,6 @@
 #include <stdint.h>
 #include <unwind.h>
 #include <sysdep.h>
-#include <pointer_guard.h>
 
 /* Test if longjmp to JMPBUF would unwind the frame
    containing a local variable at ADDRESS.  */
 #define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
   _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
 
+/* setjmp does not mangle the stack pointer on this ABI, so the saved
+   value is used as-is.  */
 static inline uintptr_t __attribute__ ((unused))
 _jmpbuf_sp (__jmp_buf regs)
 {
-  void *sp = (void *) regs[0].__sp;
-  PTR_DEMANGLE (sp);
-  return (uintptr_t) sp;
+  return (uintptr_t) regs[0].__sp;
 }
 
 #define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
index c213c0a97f62eb3ba02b02367b780937eb243c98..039cad5de80d8e8300b18421fd11532c4ad4e98d 100644 (file)
@@ -19,7 +19,6 @@
 #include <stdint.h>
 #include <unwind.h>
 #include <sysdep.h>
-#include <pointer_guard.h>
 
 /* Test if longjmp to JMPBUF would unwind the frame
    containing a local variable at ADDRESS.  */
                       (void *) (_Unwind_Ptr) _Unwind_GetCFA (_context), \
                       _adj)
 
+/* setjmp does not mangle the stack pointer on this ABI, so the saved
+   value is used as-is.  */
 static inline uintptr_t __attribute__ ((unused))
 _jmpbuf_sp (__jmp_buf regs)
 {
-  uintptr_t sp = (uintptr_t) regs[0].__sp;
-  PTR_DEMANGLE (sp);
-  return sp;
+  return (uintptr_t) regs[0].__sp;
 }
 
 #define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
index 1a4de568d2ae695c4e04ae4c9edfe4597698cabd..9676723b57a925545586759842d0b67f1e3bbde4 100644 (file)
@@ -20,7 +20,6 @@
 #include <stdint.h>
 #include <unwind.h>
 #include <sysdep.h>
-#include <pointer_guard.h>
 
 /* Test if longjmp to JMPBUF would unwind the frame
    containing a local variable at ADDRESS.  */
 #define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
   _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
 
+/* setjmp does not mangle the stack pointer on this ABI, so the saved
+   value is used as-is.  */
 static inline uintptr_t __attribute__ ((unused))
 _jmpbuf_sp (__jmp_buf regs)
 {
-  uintptr_t sp = regs[0].__sp;
-  PTR_DEMANGLE (sp);
-  return sp;
+  return regs[0].__sp;
 }
 
 #define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \