Patchwork [x32] PATCH: Use long long to check rt_sigreturn syscall

login
register
mail settings
Submitter H.J. Lu
Date March 5, 2011, 7:10 p.m.
Message ID <20110305191051.GA4614@intel.com>
Download mbox | patch
Permalink /patch/85548/
State New
Headers show

Comments

H.J. Lu - March 5, 2011, 7:10 p.m.
On Fri, Mar 04, 2011 at 03:50:07PM -0800, H.J. Lu wrote:
> Hi,
> 
> I checked this patch into x32 branch.
> 
> 
> H.J.
> ---
> commit f8dd1a34cd51d52589cac5833dbf60e99e258504
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date:   Fri Mar 4 15:22:45 2011 -0800
> 
>     Use long long to check rt_sigreturn syscall.
> 
> diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
> index a3b7364..1bee1d9 100644
> --- a/gcc/ChangeLog.x32
> +++ b/gcc/ChangeLog.x32
> @@ -1,3 +1,8 @@
> +2011-03-04  H.J. Lu  <hongjiu.lu@intel.com>
> +
> +	* config/i386/linux-unwind.h (x86_64_fallback_frame_state): Use
> +	long long to check rt_sigreturn syscall.
> +
>  2011-03-02  H.J. Lu  <hongjiu.lu@intel.com>
>  
>  	PR rtl-optimization/47958
> diff --git a/gcc/config/i386/linux-unwind.h b/gcc/config/i386/linux-unwind.h
> index c5f7ea0..11afd86 100644
> --- a/gcc/config/i386/linux-unwind.h
> +++ b/gcc/config/i386/linux-unwind.h
> @@ -45,7 +45,7 @@ x86_64_fallback_frame_state (struct _Unwind_Context *context,
>  
>    /* movq __NR_rt_sigreturn, %rax ; syscall  */
>    if (*(unsigned char *)(pc+0) == 0x48
> -      && *(unsigned long *)(pc+1) == 0x050f0000000fc0c7)
> +      && *(unsigned long long *)(pc+1) == 0x050f0000000fc0c7ULL)
>      {
>        struct ucontext *uc_ = context->cfa;
>        /* The void * cast is necessary to avoid an aliasing warning.

This isn't right since x32 has a different system call number.  I
checked in this patch.


H.J.
--

Patch

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 1bee1d9..5389f19 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,8 @@ 
+2011-03-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* config/i386/linux-unwind.h (x86_64_fallback_frame_state):
+	Support x32 system call.
+
 2011-03-04  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* config/i386/linux-unwind.h (x86_64_fallback_frame_state): Use
diff --git a/gcc/config/i386/linux-unwind.h b/gcc/config/i386/linux-unwind.h
index 11afd86..a9ddb7e 100644
--- a/gcc/config/i386/linux-unwind.h
+++ b/gcc/config/i386/linux-unwind.h
@@ -43,9 +43,15 @@  x86_64_fallback_frame_state (struct _Unwind_Context *context,
   struct sigcontext *sc;
   long new_cfa;
 
-  /* movq __NR_rt_sigreturn, %rax ; syscall  */
+  /* movq __NR_rt_sigreturn, %rax ; syscall.  FIXME: x32 system call
+     number may change.  */
+#ifdef __LP64__
+#define RT_SIGRETURN_SYSCALL	0x050f0000000fc0c7ULL
+#else
+#define RT_SIGRETURN_SYSCALL	0x050f0000100fc0c7ULL
+#endif
   if (*(unsigned char *)(pc+0) == 0x48
-      && *(unsigned long long *)(pc+1) == 0x050f0000000fc0c7ULL)
+      && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL)
     {
       struct ucontext *uc_ = context->cfa;
       /* The void * cast is necessary to avoid an aliasing warning.