From: Adhemerval Zanella Date: Fri, 12 Jun 2026 16:10:13 +0000 (-0300) Subject: Remove the jmp_buf stack pointer demangle on ABIs that do not mangle it X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c626d764d7ea2ffe3e5dd60452435eeaebdf68f6;p=thirdparty%2Fglibc.git Remove the jmp_buf stack pointer demangle on ABIs that do not mangle it 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 --- diff --git a/sysdeps/arc/jmpbuf-unwind.h b/sysdeps/arc/jmpbuf-unwind.h index d007c78564..48a9f9a7c5 100644 --- a/sysdeps/arc/jmpbuf-unwind.h +++ b/sysdeps/arc/jmpbuf-unwind.h @@ -20,7 +20,6 @@ #include #include #include -#include /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ @@ -31,12 +30,12 @@ #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) \ diff --git a/sysdeps/m68k/jmpbuf-unwind.h b/sysdeps/m68k/jmpbuf-unwind.h index 9c5206fb69..2f4bc71d5b 100644 --- a/sysdeps/m68k/jmpbuf-unwind.h +++ b/sysdeps/m68k/jmpbuf-unwind.h @@ -19,7 +19,6 @@ #include #include #include -#include /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ @@ -29,12 +28,12 @@ #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) \ diff --git a/sysdeps/microblaze/jmpbuf-unwind.h b/sysdeps/microblaze/jmpbuf-unwind.h index cb28dd83ec..9584203257 100644 --- a/sysdeps/microblaze/jmpbuf-unwind.h +++ b/sysdeps/microblaze/jmpbuf-unwind.h @@ -20,7 +20,6 @@ #include #include #include -#include /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ @@ -30,12 +29,12 @@ #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) \ diff --git a/sysdeps/mips/jmpbuf-unwind.h b/sysdeps/mips/jmpbuf-unwind.h index c213c0a97f..039cad5de8 100644 --- a/sysdeps/mips/jmpbuf-unwind.h +++ b/sysdeps/mips/jmpbuf-unwind.h @@ -19,7 +19,6 @@ #include #include #include -#include /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ @@ -31,12 +30,12 @@ (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) \ diff --git a/sysdeps/riscv/jmpbuf-unwind.h b/sysdeps/riscv/jmpbuf-unwind.h index 1a4de568d2..9676723b57 100644 --- a/sysdeps/riscv/jmpbuf-unwind.h +++ b/sysdeps/riscv/jmpbuf-unwind.h @@ -20,7 +20,6 @@ #include #include #include -#include /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ @@ -30,12 +29,12 @@ #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) \