Fix sparc64 bits/setjmp.h namespace (bug 21261)

Submitted by Joseph S. Myers on March 17, 2017, 3:08 a.m.

Details

Message ID alpine.DEB.2.20.1703170308190.6157@digraph.polyomino.org.uk
State New
Headers show

Commit Message

Joseph S. Myers March 17, 2017, 3:08 a.m.
sysdeps/unix/sysv/linux/sparc/bits/setjmp.h defines 64-bit __jmp_buf
with a load of identifiers that are not part of any standard
namespace, resulting in conform/ tests failing.  This patch fixes this
by moving those identifiers to the implementation namespace, so
enabling the conform/ tests to pass for sparc64.

Tested (compilation only) for sparc64 with build-many-glibcs.py.

2017-03-17  Joseph Myers  <joseph@codesourcery.com>

	[BZ #21261]
	* sysdeps/unix/sysv/linux/sparc/bits/setjmp.h
	[__WORDSIZE == 64 && !_ASM] (__sparc64_jmp_buf): Use reserved
	names for all fields.
	* sysdeps/sparc/sparc64/jmpbuf-unwind.h (_JMPBUF_UNWINDS): Update
	for jmp_buf field renaming.
	(_JMPBUF_UNWINDS_ADJ): Likewise.

Comments

David Miller March 17, 2017, 3:47 a.m.
From: Joseph Myers <joseph@codesourcery.com>
Date: Fri, 17 Mar 2017 03:08:58 +0000

> sysdeps/unix/sysv/linux/sparc/bits/setjmp.h defines 64-bit __jmp_buf
> with a load of identifiers that are not part of any standard
> namespace, resulting in conform/ tests failing.  This patch fixes this
> by moving those identifiers to the implementation namespace, so
> enabling the conform/ tests to pass for sparc64.

This is going to break the build of the address sanitizer on sparc64.

It will also probably break lots of other programs too that grovel
through the mcontext register bits for unwinding and state inspection.
Mike Frysinger March 17, 2017, 3:48 a.m.
On 17 Mar 2017 03:08, Joseph Myers wrote:
> sysdeps/unix/sysv/linux/sparc/bits/setjmp.h defines 64-bit __jmp_buf
> with a load of identifiers that are not part of any standard
> namespace, resulting in conform/ tests failing.  This patch fixes this
> by moving those identifiers to the implementation namespace, so
> enabling the conform/ tests to pass for sparc64.

lgtm
-mike
Joseph S. Myers March 17, 2017, 2:26 p.m.
On Fri, 17 Mar 2017, David Miller wrote:

> From: Joseph Myers <joseph@codesourcery.com>
> Date: Fri, 17 Mar 2017 03:08:58 +0000
> 
> > sysdeps/unix/sysv/linux/sparc/bits/setjmp.h defines 64-bit __jmp_buf
> > with a load of identifiers that are not part of any standard
> > namespace, resulting in conform/ tests failing.  This patch fixes this
> > by moving those identifiers to the implementation namespace, so
> > enabling the conform/ tests to pass for sparc64.
> 
> This is going to break the build of the address sanitizer on sparc64.
> 
> It will also probably break lots of other programs too that grovel
> through the mcontext register bits for unwinding and state inspection.

Are those things really looking at jmp_buf, rather than ucontext / 
mcontext from sys/ucontext.h (which are unchanged by the patch)?
David Miller March 17, 2017, 10:24 p.m.
From: Joseph Myers <joseph@codesourcery.com>
Date: Fri, 17 Mar 2017 14:26:18 +0000

> Are those things really looking at jmp_buf, rather than ucontext / 
> mcontext from sys/ucontext.h (which are unchanged by the patch)?

Indeed it is looking at a ucontext_t.  So we might be lucky and get
away with this.
Joseph S. Myers March 18, 2017, 12:18 a.m.
On Fri, 17 Mar 2017, David Miller wrote:

> From: Joseph Myers <joseph@codesourcery.com>
> Date: Fri, 17 Mar 2017 14:26:18 +0000
> 
> > Are those things really looking at jmp_buf, rather than ucontext / 
> > mcontext from sys/ucontext.h (which are unchanged by the patch)?
> 
> Indeed it is looking at a ucontext_t.  So we might be lucky and get
> away with this.

I've committed the patch.  We'll need to watch out for any issues arising.

Patch hide | download patch | download mbox

diff --git a/sysdeps/sparc/sparc64/jmpbuf-unwind.h b/sysdeps/sparc/sparc64/jmpbuf-unwind.h
index d84a5ea..eb2e2e2 100644
--- a/sysdeps/sparc/sparc64/jmpbuf-unwind.h
+++ b/sysdeps/sparc/sparc64/jmpbuf-unwind.h
@@ -22,15 +22,16 @@ 
 
 /* Test if longjmp to JMPBUF would unwind the frame
    containing a local variable at ADDRESS.  */
-#define _JMPBUF_UNWINDS(jmpbuf, address, demangle)			\
-  ((unsigned long int) (address) < (jmpbuf)->uc_mcontext.mc_gregs[MC_O6] + 2047)
+#define _JMPBUF_UNWINDS(jmpbuf, address, demangle)	\
+  ((unsigned long int) (address)			\
+   < (jmpbuf)->__uc_mcontext.__mc_gregs[MC_O6] + 2047)
 
 #define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
   _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
 
 #define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
   ((uintptr_t) (_address) - (_adj) \
-   < (uintptr_t) (_jmpbuf)[0].uc_mcontext.mc_gregs[MC_O6] + 2047 - (_adj))
+   < (uintptr_t) (_jmpbuf)[0].__uc_mcontext.__mc_gregs[MC_O6] + 2047 - (_adj))
 
 /* We use the normal lobngjmp for unwinding.  */
 #define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/setjmp.h b/sysdeps/unix/sysv/linux/sparc/bits/setjmp.h
index e43bc72..5e92e82 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/setjmp.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/setjmp.h
@@ -29,30 +29,30 @@ 
 #ifndef _ASM
 typedef struct __sparc64_jmp_buf
   {
-    struct __sparc64_jmp_buf	*uc_link;
-    unsigned long		uc_flags;
-    unsigned long		uc_sigmask;
+    struct __sparc64_jmp_buf	*__uc_link;
+    unsigned long		__uc_flags;
+    unsigned long		__uc_sigmask;
     struct __sparc64_jmp_buf_mcontext
       {
-	unsigned long		mc_gregs[19];
-	unsigned long		mc_fp;
-	unsigned long		mc_i7;
+	unsigned long		__mc_gregs[19];
+	unsigned long		__mc_fp;
+	unsigned long		__mc_i7;
 	struct __sparc64_jmp_buf_fpu
 	  {
 	    union
 	      {
-		unsigned int	sregs[32];
-		unsigned long	dregs[32];
-		long double	qregs[16];
-	      }			mcfpu_fpregs;
-	    unsigned long	mcfpu_fprs;
-	    unsigned long	mcfpu_gsr;
-	    void		*mcfpu_fq;
-	    unsigned char	mcfpu_qcnt;
-	    unsigned char	mcfpu_qentsz;
-	    unsigned char	mcfpu_enab;
-	  }			mc_fpregs;
-      }				uc_mcontext;
+		unsigned int	__sregs[32];
+		unsigned long	__dregs[32];
+		long double	__qregs[16];
+	      }			__mcfpu_fpregs;
+	    unsigned long	__mcfpu_fprs;
+	    unsigned long	__mcfpu_gsr;
+	    void		*__mcfpu_fq;
+	    unsigned char	__mcfpu_qcnt;
+	    unsigned char	__mcfpu_qentsz;
+	    unsigned char	__mcfpu_enab;
+	  }			__mc_fpregs;
+      }				__uc_mcontext;
   } __jmp_buf[1];
 #endif