[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCHv2] hurd: libgcc unwinding over signal trampolines with SIGINF
From: |
Thomas Schwinge |
Subject: |
Re: [PATCHv2] hurd: libgcc unwinding over signal trampolines with SIGINFO |
Date: |
Wed, 13 Jan 2021 12:02:30 +0100 |
User-agent: |
Notmuch/0.29.1+93~g67ed7df (https://notmuchmail.org) Emacs/25.2.2 (x86_64-pc-linux-gnu) |
Hi!
On 2020-12-21T15:36:30+0100, Samuel Thibault <samuel.thibault@gnu.org> wrote:
> When the application sets SA_SIGINFO, the signal trampoline parameters
> are different to follow POSIX.
Thanks (and sorry for the delay), pushed "hurd: libgcc unwinding over
signal trampolines with SIGINFO" to master branch in commit
2b356e689c334ca4765a9ffd95a76cf715447200, and cherry-picked into
releases/gcc-10 branch in commit
2c4d3e6db8583c83f4252bb0c78b85f174420a90, releases/gcc-9 branch in commit
23b1bb7b22aa23a1f096448c319856cbeb720082, releases/gcc-8 branch in commit
c6c6d1d33533a3107bec0bf6f149761b4084d8b4, see attached.
Grüße
Thomas
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander
Walter
>From 2b356e689c334ca4765a9ffd95a76cf715447200 Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@gnu.org>
Date: Mon, 21 Dec 2020 15:36:30 +0100
Subject: [PATCH] hurd: libgcc unwinding over signal trampolines with SIGINFO
When the application sets SA_SIGINFO, the signal trampoline parameters
are different to follow POSIX.
libgcc/
* config/i386/gnu-unwind.h (x86_gnu_fallback_frame_state): Add the
posix siginfo case to struct handler_args. Detect between legacy
and siginfo from the second parameter, which is a small sigcode in
the legacy case, and a pointer in the siginfo case.
---
libgcc/config/i386/gnu-unwind.h | 60 ++++++++++++++++++++++++++-------
1 file changed, 47 insertions(+), 13 deletions(-)
diff --git a/libgcc/config/i386/gnu-unwind.h b/libgcc/config/i386/gnu-unwind.h
index d69d07c1c80..0632348d4cd 100644
--- a/libgcc/config/i386/gnu-unwind.h
+++ b/libgcc/config/i386/gnu-unwind.h
@@ -38,10 +38,21 @@ x86_gnu_fallback_frame_state
{
struct handler_args {
int signo;
- int sigcode;
- struct sigcontext *scp;
+ union
+ {
+ struct
+ {
+ long int sigcode;
+ struct sigcontext *scp;
+ } legacy;
+ struct
+ {
+ siginfo_t *siginfop;
+ ucontext_t *uctxp;
+ } posix;
+ };
} *handler_args;
- struct sigcontext *scp;
+ long int sigcode;
unsigned long usp;
/*
@@ -75,29 +86,52 @@ x86_gnu_fallback_frame_state
return _URC_END_OF_STACK;
handler_args = context->cfa;
- scp = handler_args->scp;
- usp = scp->sc_uesp;
+ sigcode = handler_args->legacy.sigcode;
+ if (sigcode >= -16 && sigcode < 4096)
+ {
+ /* This cannot be a SIGINFO pointer, assume legacy. */
+ struct sigcontext *scp = handler_args->legacy.scp;
+ usp = scp->sc_uesp;
+
+ fs->regs.reg[0].loc.offset = (unsigned long)&scp->sc_eax - usp;
+ fs->regs.reg[1].loc.offset = (unsigned long)&scp->sc_ecx - usp;
+ fs->regs.reg[2].loc.offset = (unsigned long)&scp->sc_edx - usp;
+ fs->regs.reg[3].loc.offset = (unsigned long)&scp->sc_ebx - usp;
+ fs->regs.reg[5].loc.offset = (unsigned long)&scp->sc_ebp - usp;
+ fs->regs.reg[6].loc.offset = (unsigned long)&scp->sc_esi - usp;
+ fs->regs.reg[7].loc.offset = (unsigned long)&scp->sc_edi - usp;
+ fs->regs.reg[8].loc.offset = (unsigned long)&scp->sc_eip - usp;
+ }
+ else
+ {
+ /* This is not a valid sigcode, assume SIGINFO. */
+ ucontext_t *uctxp = handler_args->posix.uctxp;
+ gregset_t *gregset = &uctxp->uc_mcontext.gregs;
+ usp = (*gregset)[REG_UESP];
+
+ fs->regs.reg[0].loc.offset = (unsigned long)&(*gregset)[REG_EAX] - usp;
+ fs->regs.reg[1].loc.offset = (unsigned long)&(*gregset)[REG_ECX] - usp;
+ fs->regs.reg[2].loc.offset = (unsigned long)&(*gregset)[REG_EDX] - usp;
+ fs->regs.reg[3].loc.offset = (unsigned long)&(*gregset)[REG_EBX] - usp;
+ fs->regs.reg[5].loc.offset = (unsigned long)&(*gregset)[REG_EBP] - usp;
+ fs->regs.reg[6].loc.offset = (unsigned long)&(*gregset)[REG_ESI] - usp;
+ fs->regs.reg[7].loc.offset = (unsigned long)&(*gregset)[REG_EDI] - usp;
+ fs->regs.reg[8].loc.offset = (unsigned long)&(*gregset)[REG_EIP] - usp;
+ }
fs->regs.cfa_how = CFA_REG_OFFSET;
fs->regs.cfa_reg = 4;
fs->regs.cfa_offset = usp - (unsigned long) context->cfa;
fs->regs.reg[0].how = REG_SAVED_OFFSET;
- fs->regs.reg[0].loc.offset = (unsigned long)&scp->sc_eax - usp;
fs->regs.reg[1].how = REG_SAVED_OFFSET;
- fs->regs.reg[1].loc.offset = (unsigned long)&scp->sc_ecx - usp;
fs->regs.reg[2].how = REG_SAVED_OFFSET;
- fs->regs.reg[2].loc.offset = (unsigned long)&scp->sc_edx - usp;
fs->regs.reg[3].how = REG_SAVED_OFFSET;
- fs->regs.reg[3].loc.offset = (unsigned long)&scp->sc_ebx - usp;
fs->regs.reg[5].how = REG_SAVED_OFFSET;
- fs->regs.reg[5].loc.offset = (unsigned long)&scp->sc_ebp - usp;
fs->regs.reg[6].how = REG_SAVED_OFFSET;
- fs->regs.reg[6].loc.offset = (unsigned long)&scp->sc_esi - usp;
fs->regs.reg[7].how = REG_SAVED_OFFSET;
- fs->regs.reg[7].loc.offset = (unsigned long)&scp->sc_edi - usp;
fs->regs.reg[8].how = REG_SAVED_OFFSET;
- fs->regs.reg[8].loc.offset = (unsigned long)&scp->sc_eip - usp;
+
fs->retaddr_column = 8;
fs->signal_frame = 1;
--
2.17.1
>From 2c4d3e6db8583c83f4252bb0c78b85f174420a90 Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@gnu.org>
Date: Mon, 21 Dec 2020 15:36:30 +0100
Subject: [PATCH] hurd: libgcc unwinding over signal trampolines with SIGINFO
When the application sets SA_SIGINFO, the signal trampoline parameters
are different to follow POSIX.
libgcc/
* config/i386/gnu-unwind.h (x86_gnu_fallback_frame_state): Add the
posix siginfo case to struct handler_args. Detect between legacy
and siginfo from the second parameter, which is a small sigcode in
the legacy case, and a pointer in the siginfo case.
(cherry picked from commit 2b356e689c334ca4765a9ffd95a76cf715447200)
---
libgcc/config/i386/gnu-unwind.h | 60 ++++++++++++++++++++++++++-------
1 file changed, 47 insertions(+), 13 deletions(-)
diff --git a/libgcc/config/i386/gnu-unwind.h b/libgcc/config/i386/gnu-unwind.h
index db47f0ac1d4..f83411e3de4 100644
--- a/libgcc/config/i386/gnu-unwind.h
+++ b/libgcc/config/i386/gnu-unwind.h
@@ -38,10 +38,21 @@ x86_gnu_fallback_frame_state
{
struct handler_args {
int signo;
- int sigcode;
- struct sigcontext *scp;
+ union
+ {
+ struct
+ {
+ long int sigcode;
+ struct sigcontext *scp;
+ } legacy;
+ struct
+ {
+ siginfo_t *siginfop;
+ ucontext_t *uctxp;
+ } posix;
+ };
} *handler_args;
- struct sigcontext *scp;
+ long int sigcode;
unsigned long usp;
/*
@@ -75,29 +86,52 @@ x86_gnu_fallback_frame_state
return _URC_END_OF_STACK;
handler_args = context->cfa;
- scp = handler_args->scp;
- usp = scp->sc_uesp;
+ sigcode = handler_args->legacy.sigcode;
+ if (sigcode >= -16 && sigcode < 4096)
+ {
+ /* This cannot be a SIGINFO pointer, assume legacy. */
+ struct sigcontext *scp = handler_args->legacy.scp;
+ usp = scp->sc_uesp;
+
+ fs->regs.reg[0].loc.offset = (unsigned long)&scp->sc_eax - usp;
+ fs->regs.reg[1].loc.offset = (unsigned long)&scp->sc_ecx - usp;
+ fs->regs.reg[2].loc.offset = (unsigned long)&scp->sc_edx - usp;
+ fs->regs.reg[3].loc.offset = (unsigned long)&scp->sc_ebx - usp;
+ fs->regs.reg[5].loc.offset = (unsigned long)&scp->sc_ebp - usp;
+ fs->regs.reg[6].loc.offset = (unsigned long)&scp->sc_esi - usp;
+ fs->regs.reg[7].loc.offset = (unsigned long)&scp->sc_edi - usp;
+ fs->regs.reg[8].loc.offset = (unsigned long)&scp->sc_eip - usp;
+ }
+ else
+ {
+ /* This is not a valid sigcode, assume SIGINFO. */
+ ucontext_t *uctxp = handler_args->posix.uctxp;
+ gregset_t *gregset = &uctxp->uc_mcontext.gregs;
+ usp = (*gregset)[REG_UESP];
+
+ fs->regs.reg[0].loc.offset = (unsigned long)&(*gregset)[REG_EAX] - usp;
+ fs->regs.reg[1].loc.offset = (unsigned long)&(*gregset)[REG_ECX] - usp;
+ fs->regs.reg[2].loc.offset = (unsigned long)&(*gregset)[REG_EDX] - usp;
+ fs->regs.reg[3].loc.offset = (unsigned long)&(*gregset)[REG_EBX] - usp;
+ fs->regs.reg[5].loc.offset = (unsigned long)&(*gregset)[REG_EBP] - usp;
+ fs->regs.reg[6].loc.offset = (unsigned long)&(*gregset)[REG_ESI] - usp;
+ fs->regs.reg[7].loc.offset = (unsigned long)&(*gregset)[REG_EDI] - usp;
+ fs->regs.reg[8].loc.offset = (unsigned long)&(*gregset)[REG_EIP] - usp;
+ }
fs->regs.cfa_how = CFA_REG_OFFSET;
fs->regs.cfa_reg = 4;
fs->regs.cfa_offset = usp - (unsigned long) context->cfa;
fs->regs.reg[0].how = REG_SAVED_OFFSET;
- fs->regs.reg[0].loc.offset = (unsigned long)&scp->sc_eax - usp;
fs->regs.reg[1].how = REG_SAVED_OFFSET;
- fs->regs.reg[1].loc.offset = (unsigned long)&scp->sc_ecx - usp;
fs->regs.reg[2].how = REG_SAVED_OFFSET;
- fs->regs.reg[2].loc.offset = (unsigned long)&scp->sc_edx - usp;
fs->regs.reg[3].how = REG_SAVED_OFFSET;
- fs->regs.reg[3].loc.offset = (unsigned long)&scp->sc_ebx - usp;
fs->regs.reg[5].how = REG_SAVED_OFFSET;
- fs->regs.reg[5].loc.offset = (unsigned long)&scp->sc_ebp - usp;
fs->regs.reg[6].how = REG_SAVED_OFFSET;
- fs->regs.reg[6].loc.offset = (unsigned long)&scp->sc_esi - usp;
fs->regs.reg[7].how = REG_SAVED_OFFSET;
- fs->regs.reg[7].loc.offset = (unsigned long)&scp->sc_edi - usp;
fs->regs.reg[8].how = REG_SAVED_OFFSET;
- fs->regs.reg[8].loc.offset = (unsigned long)&scp->sc_eip - usp;
+
fs->retaddr_column = 8;
fs->signal_frame = 1;
--
2.17.1
>From 23b1bb7b22aa23a1f096448c319856cbeb720082 Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@gnu.org>
Date: Mon, 21 Dec 2020 15:36:30 +0100
Subject: [PATCH] hurd: libgcc unwinding over signal trampolines with SIGINFO
When the application sets SA_SIGINFO, the signal trampoline parameters
are different to follow POSIX.
libgcc/
* config/i386/gnu-unwind.h (x86_gnu_fallback_frame_state): Add the
posix siginfo case to struct handler_args. Detect between legacy
and siginfo from the second parameter, which is a small sigcode in
the legacy case, and a pointer in the siginfo case.
(cherry picked from commit 2b356e689c334ca4765a9ffd95a76cf715447200)
---
libgcc/config/i386/gnu-unwind.h | 60 ++++++++++++++++++++++++++-------
1 file changed, 47 insertions(+), 13 deletions(-)
diff --git a/libgcc/config/i386/gnu-unwind.h b/libgcc/config/i386/gnu-unwind.h
index db47f0ac1d4..f83411e3de4 100644
--- a/libgcc/config/i386/gnu-unwind.h
+++ b/libgcc/config/i386/gnu-unwind.h
@@ -38,10 +38,21 @@ x86_gnu_fallback_frame_state
{
struct handler_args {
int signo;
- int sigcode;
- struct sigcontext *scp;
+ union
+ {
+ struct
+ {
+ long int sigcode;
+ struct sigcontext *scp;
+ } legacy;
+ struct
+ {
+ siginfo_t *siginfop;
+ ucontext_t *uctxp;
+ } posix;
+ };
} *handler_args;
- struct sigcontext *scp;
+ long int sigcode;
unsigned long usp;
/*
@@ -75,29 +86,52 @@ x86_gnu_fallback_frame_state
return _URC_END_OF_STACK;
handler_args = context->cfa;
- scp = handler_args->scp;
- usp = scp->sc_uesp;
+ sigcode = handler_args->legacy.sigcode;
+ if (sigcode >= -16 && sigcode < 4096)
+ {
+ /* This cannot be a SIGINFO pointer, assume legacy. */
+ struct sigcontext *scp = handler_args->legacy.scp;
+ usp = scp->sc_uesp;
+
+ fs->regs.reg[0].loc.offset = (unsigned long)&scp->sc_eax - usp;
+ fs->regs.reg[1].loc.offset = (unsigned long)&scp->sc_ecx - usp;
+ fs->regs.reg[2].loc.offset = (unsigned long)&scp->sc_edx - usp;
+ fs->regs.reg[3].loc.offset = (unsigned long)&scp->sc_ebx - usp;
+ fs->regs.reg[5].loc.offset = (unsigned long)&scp->sc_ebp - usp;
+ fs->regs.reg[6].loc.offset = (unsigned long)&scp->sc_esi - usp;
+ fs->regs.reg[7].loc.offset = (unsigned long)&scp->sc_edi - usp;
+ fs->regs.reg[8].loc.offset = (unsigned long)&scp->sc_eip - usp;
+ }
+ else
+ {
+ /* This is not a valid sigcode, assume SIGINFO. */
+ ucontext_t *uctxp = handler_args->posix.uctxp;
+ gregset_t *gregset = &uctxp->uc_mcontext.gregs;
+ usp = (*gregset)[REG_UESP];
+
+ fs->regs.reg[0].loc.offset = (unsigned long)&(*gregset)[REG_EAX] - usp;
+ fs->regs.reg[1].loc.offset = (unsigned long)&(*gregset)[REG_ECX] - usp;
+ fs->regs.reg[2].loc.offset = (unsigned long)&(*gregset)[REG_EDX] - usp;
+ fs->regs.reg[3].loc.offset = (unsigned long)&(*gregset)[REG_EBX] - usp;
+ fs->regs.reg[5].loc.offset = (unsigned long)&(*gregset)[REG_EBP] - usp;
+ fs->regs.reg[6].loc.offset = (unsigned long)&(*gregset)[REG_ESI] - usp;
+ fs->regs.reg[7].loc.offset = (unsigned long)&(*gregset)[REG_EDI] - usp;
+ fs->regs.reg[8].loc.offset = (unsigned long)&(*gregset)[REG_EIP] - usp;
+ }
fs->regs.cfa_how = CFA_REG_OFFSET;
fs->regs.cfa_reg = 4;
fs->regs.cfa_offset = usp - (unsigned long) context->cfa;
fs->regs.reg[0].how = REG_SAVED_OFFSET;
- fs->regs.reg[0].loc.offset = (unsigned long)&scp->sc_eax - usp;
fs->regs.reg[1].how = REG_SAVED_OFFSET;
- fs->regs.reg[1].loc.offset = (unsigned long)&scp->sc_ecx - usp;
fs->regs.reg[2].how = REG_SAVED_OFFSET;
- fs->regs.reg[2].loc.offset = (unsigned long)&scp->sc_edx - usp;
fs->regs.reg[3].how = REG_SAVED_OFFSET;
- fs->regs.reg[3].loc.offset = (unsigned long)&scp->sc_ebx - usp;
fs->regs.reg[5].how = REG_SAVED_OFFSET;
- fs->regs.reg[5].loc.offset = (unsigned long)&scp->sc_ebp - usp;
fs->regs.reg[6].how = REG_SAVED_OFFSET;
- fs->regs.reg[6].loc.offset = (unsigned long)&scp->sc_esi - usp;
fs->regs.reg[7].how = REG_SAVED_OFFSET;
- fs->regs.reg[7].loc.offset = (unsigned long)&scp->sc_edi - usp;
fs->regs.reg[8].how = REG_SAVED_OFFSET;
- fs->regs.reg[8].loc.offset = (unsigned long)&scp->sc_eip - usp;
+
fs->retaddr_column = 8;
fs->signal_frame = 1;
--
2.17.1
>From c6c6d1d33533a3107bec0bf6f149761b4084d8b4 Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@gnu.org>
Date: Mon, 21 Dec 2020 15:36:30 +0100
Subject: [PATCH] hurd: libgcc unwinding over signal trampolines with SIGINFO
When the application sets SA_SIGINFO, the signal trampoline parameters
are different to follow POSIX.
libgcc/
* config/i386/gnu-unwind.h (x86_gnu_fallback_frame_state): Add the
posix siginfo case to struct handler_args. Detect between legacy
and siginfo from the second parameter, which is a small sigcode in
the legacy case, and a pointer in the siginfo case.
(cherry picked from commit 2b356e689c334ca4765a9ffd95a76cf715447200)
---
libgcc/config/i386/gnu-unwind.h | 60 ++++++++++++++++++++++++++-------
1 file changed, 47 insertions(+), 13 deletions(-)
diff --git a/libgcc/config/i386/gnu-unwind.h b/libgcc/config/i386/gnu-unwind.h
index db47f0ac1d4..f83411e3de4 100644
--- a/libgcc/config/i386/gnu-unwind.h
+++ b/libgcc/config/i386/gnu-unwind.h
@@ -38,10 +38,21 @@ x86_gnu_fallback_frame_state
{
struct handler_args {
int signo;
- int sigcode;
- struct sigcontext *scp;
+ union
+ {
+ struct
+ {
+ long int sigcode;
+ struct sigcontext *scp;
+ } legacy;
+ struct
+ {
+ siginfo_t *siginfop;
+ ucontext_t *uctxp;
+ } posix;
+ };
} *handler_args;
- struct sigcontext *scp;
+ long int sigcode;
unsigned long usp;
/*
@@ -75,29 +86,52 @@ x86_gnu_fallback_frame_state
return _URC_END_OF_STACK;
handler_args = context->cfa;
- scp = handler_args->scp;
- usp = scp->sc_uesp;
+ sigcode = handler_args->legacy.sigcode;
+ if (sigcode >= -16 && sigcode < 4096)
+ {
+ /* This cannot be a SIGINFO pointer, assume legacy. */
+ struct sigcontext *scp = handler_args->legacy.scp;
+ usp = scp->sc_uesp;
+
+ fs->regs.reg[0].loc.offset = (unsigned long)&scp->sc_eax - usp;
+ fs->regs.reg[1].loc.offset = (unsigned long)&scp->sc_ecx - usp;
+ fs->regs.reg[2].loc.offset = (unsigned long)&scp->sc_edx - usp;
+ fs->regs.reg[3].loc.offset = (unsigned long)&scp->sc_ebx - usp;
+ fs->regs.reg[5].loc.offset = (unsigned long)&scp->sc_ebp - usp;
+ fs->regs.reg[6].loc.offset = (unsigned long)&scp->sc_esi - usp;
+ fs->regs.reg[7].loc.offset = (unsigned long)&scp->sc_edi - usp;
+ fs->regs.reg[8].loc.offset = (unsigned long)&scp->sc_eip - usp;
+ }
+ else
+ {
+ /* This is not a valid sigcode, assume SIGINFO. */
+ ucontext_t *uctxp = handler_args->posix.uctxp;
+ gregset_t *gregset = &uctxp->uc_mcontext.gregs;
+ usp = (*gregset)[REG_UESP];
+
+ fs->regs.reg[0].loc.offset = (unsigned long)&(*gregset)[REG_EAX] - usp;
+ fs->regs.reg[1].loc.offset = (unsigned long)&(*gregset)[REG_ECX] - usp;
+ fs->regs.reg[2].loc.offset = (unsigned long)&(*gregset)[REG_EDX] - usp;
+ fs->regs.reg[3].loc.offset = (unsigned long)&(*gregset)[REG_EBX] - usp;
+ fs->regs.reg[5].loc.offset = (unsigned long)&(*gregset)[REG_EBP] - usp;
+ fs->regs.reg[6].loc.offset = (unsigned long)&(*gregset)[REG_ESI] - usp;
+ fs->regs.reg[7].loc.offset = (unsigned long)&(*gregset)[REG_EDI] - usp;
+ fs->regs.reg[8].loc.offset = (unsigned long)&(*gregset)[REG_EIP] - usp;
+ }
fs->regs.cfa_how = CFA_REG_OFFSET;
fs->regs.cfa_reg = 4;
fs->regs.cfa_offset = usp - (unsigned long) context->cfa;
fs->regs.reg[0].how = REG_SAVED_OFFSET;
- fs->regs.reg[0].loc.offset = (unsigned long)&scp->sc_eax - usp;
fs->regs.reg[1].how = REG_SAVED_OFFSET;
- fs->regs.reg[1].loc.offset = (unsigned long)&scp->sc_ecx - usp;
fs->regs.reg[2].how = REG_SAVED_OFFSET;
- fs->regs.reg[2].loc.offset = (unsigned long)&scp->sc_edx - usp;
fs->regs.reg[3].how = REG_SAVED_OFFSET;
- fs->regs.reg[3].loc.offset = (unsigned long)&scp->sc_ebx - usp;
fs->regs.reg[5].how = REG_SAVED_OFFSET;
- fs->regs.reg[5].loc.offset = (unsigned long)&scp->sc_ebp - usp;
fs->regs.reg[6].how = REG_SAVED_OFFSET;
- fs->regs.reg[6].loc.offset = (unsigned long)&scp->sc_esi - usp;
fs->regs.reg[7].how = REG_SAVED_OFFSET;
- fs->regs.reg[7].loc.offset = (unsigned long)&scp->sc_edi - usp;
fs->regs.reg[8].how = REG_SAVED_OFFSET;
- fs->regs.reg[8].loc.offset = (unsigned long)&scp->sc_eip - usp;
+
fs->retaddr_column = 8;
fs->signal_frame = 1;
--
2.17.1