bug-libsigsegv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-libsigsegv] [PATCH] Don't use internal glibc macro


From: Bruno Haible
Subject: Re: [bug-libsigsegv] [PATCH] Don't use internal glibc macro
Date: Sat, 04 Mar 2017 16:33:46 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-64-generic; KDE/5.18.0; x86_64; ; )

Hi Andreas,

> __WORDSIZE is an internal, non-public glibc macro that can change any
> time.

Thank you for the report. Here's the patch I'd like to apply. (__WORDSIZE
was used in several places.)

> Moreover, it cannot distinguish aarch64 from arm.

What do you mean? I was assuming that 32-bit code on aarch64 uses the same
ABI as usual code on a 32-bit ARM CPU (like 32-bit code on x86_64 uses the
same ABI as x86 code). Are you saying that this is not true? That 32-bit
code on aarch64 is something different from ARM?


diff --git a/src/fault-linux-arm.h b/src/fault-linux-arm.h
index a3da5f8..efd9d5b 100644
--- a/src/fault-linux-arm.h
+++ b/src/fault-linux-arm.h
@@ -17,7 +17,7 @@
 
 #include "fault-posix-ucontext.h"
 
-#if __WORDSIZE == 64
+#if defined(__aarch64__) || defined(__ARM_64BIT_STATE) || 
defined(__ARM_PCS_AAPCS64) /* 64-bit */
 
 /* See glibc/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h.
    Note that the 'mcontext_t' defined in
@@ -27,7 +27,7 @@
 
 #define SIGSEGV_FAULT_STACKPOINTER  ((ucontext_t *) ucp)->uc_mcontext.sp
 
-#else
+#else /* 32-bit */
 
 /* See glibc/sysdeps/unix/sysv/linux/arm/sys/ucontext.h
    and the definition of GET_STACK in
diff --git a/src/fault-linux-powerpc.h b/src/fault-linux-powerpc.h
index 97fd0ab..36a3468 100644
--- a/src/fault-linux-powerpc.h
+++ b/src/fault-linux-powerpc.h
@@ -26,13 +26,13 @@
    and the 'struct pt_regs' defined in <asm/ptrace.h>
    are quite different types.  */
 
-#if __WORDSIZE == 32
+#if defined(__powerpc64__) || defined(_ARCH_PPC64) /* 64-bit */
+# define SIGSEGV_FAULT_STACKPOINTER  ((ucontext_t *) 
ucp)->uc_mcontext.gp_regs[1]
+#else /* 32-bit */
 /* both should be equivalent */
 # if 0
 #  define SIGSEGV_FAULT_STACKPOINTER  ((ucontext_t *) 
ucp)->uc_mcontext.regs->gpr[1]
 # else
 #  define SIGSEGV_FAULT_STACKPOINTER  ((ucontext_t *) 
ucp)->uc_mcontext.uc_regs->gregs[1]
 # endif
-#else
-# define SIGSEGV_FAULT_STACKPOINTER  ((ucontext_t *) 
ucp)->uc_mcontext.gp_regs[1]
 #endif
diff --git a/src/fault-linux-sparc-old.h b/src/fault-linux-sparc-old.h
index 2acaeb3..3212fbd 100644
--- a/src/fault-linux-sparc-old.h
+++ b/src/fault-linux-sparc-old.h
@@ -23,9 +23,9 @@
 #if 1 /* Old? FIXME */
 # define SIGSEGV_FAULT_STACKPOINTER  scp->sigc_sp
 #else
-# if __WORDSIZE == 64
+# if defined(__sparcv9) || defined(__arch64__) /* 64-bit */
 #  define SIGSEGV_FAULT_STACKPOINTER  scp->sigc_regs.u_regs[14]
-# else
+# else /* 32-bit */
 #  define SIGSEGV_FAULT_STACKPOINTER  scp->si_regs.u_regs[14]
 # endif
 #endif
diff --git a/src/fault-linux-sparc.h b/src/fault-linux-sparc.h
index 8b37874..9c1c285 100644
--- a/src/fault-linux-sparc.h
+++ b/src/fault-linux-sparc.h
@@ -27,13 +27,13 @@
    (see also <asm/sigcontext.h>)
    are quite different types.  */
 
-#if __WORDSIZE == 64
+#if defined(__sparcv9) || defined(__arch64__) /* 64-bit */
 /* From linux-4.8.1/arch/sparc/kernel/signal_64.c, function setup_rt_frame, we
    see that ucp is not an 'ucontext_t *' but rather a 'struct sigcontext *'
    that happens to have the same value as sip (which is possible because a
    'struct sigcontext' starts with 128 bytes room for the siginfo_t).  */
 #define SIGSEGV_FAULT_STACKPOINTER  (((struct sigcontext *) 
ucp)->sigc_regs.u_regs[14] + 2047)
-#else
+#else /* 32-bit */
 /* From linux-4.8.1/arch/sparc/kernel/signal_32.c, function setup_rt_frame,
    and linux-4.8.1/arch/sparc/kernel/signal32.c, function setup_rt_frame32, we
    see that ucp is a 'struct pt_regs *' or 'struct pt_regs32 *', respectively.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]