bug-diffutils
[Top][All Lists]
Advanced

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

[bug-diffutils] bug#63333: bug#63333: [PATCH] Add hurd-amd64 support


From: Bruno Haible
Subject: [bug-diffutils] bug#63333: bug#63333: [PATCH] Add hurd-amd64 support
Date: Fri, 12 May 2023 21:38:29 +0200

Samuel Thibault <samuel.thibault@ens-lyon.org> wrote:
> > This adds SIGSEGV_FAULT_STACKPOINTER for the hurd-amd64 case
> >
> > --- ./lib/sigsegv.c.original    2023-05-05 10:45:54.673751100 +0000
> > +++ ./lib/sigsegv.c     2023-05-05 10:48:47.903577554 +0000
> > @@ -351,6 +351,17 @@
> >     "old esp, if trapped from user".  */
> >  #  define SIGSEGV_FAULT_STACKPOINTER  scp->sc_uesp
> >
> > +# elif defined __x86_64__
> > +
> > +/* scp points to a 'struct sigcontext' (defined in
> > +   glibc/sysdeps/mach/hurd/x86_64/bits/sigcontext.h).
> > +   The registers of this struct get pushed on the stack through
> > +   gnumach/x86_64/i386/locore.S:trapall.  */
> > +/* Both sc_rsp and sc_ursp appear to have the same value.
> > +   It appears more reliable to use sc_ursp because it is labelled as
> > +   "old rsp, if trapped from user".  */
> > +#  define SIGSEGV_FAULT_STACKPOINTER  scp->sc_ursp
> > +
> >  # endif
> >
> >  #endif

Thanks Samuel. The definition of SIGSEGV_FAULT_STACKPOINTER seems correct in
this patch, but the comments are not. I am applying this instead.

I'm calling this "tentative" support for Hurd/x86_64, because
  - I have no way to test it,
  - some of the code paths involved seem to be incorrect so far, see
    https://lists.gnu.org/archive/html/bug-hurd/2023-05/msg00207.html


2023-05-12  Bruno Haible  <bruno@clisp.org>

        sigsegv: Add tentative support for Hurd/x86_64.
        Reported by Samuel Thibault <samuel.thibault@ens-lyon.org>.
        * lib/sigsegv.c: Update from libsigsegv/src/fault-hurd-i386.h.

diff --git a/lib/sigsegv.c b/lib/sigsegv.c
index 5e943e4d5d..aadba4e060 100644
--- a/lib/sigsegv.c
+++ b/lib/sigsegv.c
@@ -365,12 +365,26 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
 # define SIGSEGV_FAULT_ADDRESS  (unsigned long) code
 # define SIGSEGV_FAULT_CONTEXT  scp
 
-# if defined __i386__
+# if defined __x86_64__
+/* 64 bit registers */
+
+/* scp points to a 'struct sigcontext' (defined in
+   glibc/sysdeps/mach/hurd/x86_64/bits/sigcontext.h).
+   The registers, at the moment the signal occurred, get pushed on the stack
+   through gnumach/x86_64/locore.S:alltraps and then copied into the struct
+   through glibc/sysdeps/mach/hurd/x86/trampoline.c.  */
+/* sc_rsp is unused (not set by gnumach/x86_64/locore.S:alltraps).  We need
+   to use sc_ursp.  */
+#  define SIGSEGV_FAULT_STACKPOINTER  scp->sc_ursp
+
+# elif defined __i386__
+/* 32 bit registers */
 
 /* scp points to a 'struct sigcontext' (defined in
    glibc/sysdeps/mach/hurd/i386/bits/sigcontext.h).
-   The registers of this struct get pushed on the stack through
-   gnumach/i386/i386/locore.S:trapall.  */
+   The registers, at the moment the signal occurred, get pushed on the stack
+   through gnumach/i386/i386/locore.S:alltraps and then copied into the struct
+   through glibc/sysdeps/mach/hurd/x86/trampoline.c.  */
 /* Both sc_esp and sc_uesp appear to have the same value.
    It appears more reliable to use sc_uesp because it is labelled as
    "old esp, if trapped from user".  */








reply via email to

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