diff mbox series

[uclibc-ng-devel,1/1] arc: fix signal handler restorer

Message ID 20220108205342.17746-1-geomatsi@gmail.com
State Accepted
Headers show
Series [uclibc-ng-devel,1/1] arc: fix signal handler restorer | expand

Commit Message

Sergey Matyukevich Jan. 8, 2022, 8:53 p.m. UTC
From: Sergey Matyukevich <sergey.matyukevich@synopsys.com>

When MD_FALLBACK_FRAME_STATE_FOR handler in libgcc unwind code checks
the second instruction opcode in __default_rt_sa_restorer function,
it expects to see the following values for ARC cores:
- 0x7ee0781e for ARCv2 LE
- 0x003f226f for ARC700 LE

ARC700 value correspond to trap0 instruction. ARCv2 value corresponds
to the following code:
        traps_0
        j_s     [blink]

However, unlike glibc, uClibc implementation of __default_rt_sa_restorer
for ARC does not have that jump. Hence libgcc unwind code is not able
to recognize signal frame correctly on ARCv2 and completes too early.

This change fixes libgcc unwinding over signal frame on ARCv2 adding
missing jump to __default_rt_sa_restorer.

Signed-off-by: Sergey Matyukevich <sergey.matyukevich@synopsys.com>
---
 libc/sysdeps/linux/arc/sigrestorer.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Waldemar Brodkorb Jan. 10, 2022, 12:43 p.m. UTC | #1
Hi Sergey,

committed and pushed,
 best regards
  Waldemar

Sergey Matyukevich wrote,

> From: Sergey Matyukevich <sergey.matyukevich@synopsys.com>
> 
> When MD_FALLBACK_FRAME_STATE_FOR handler in libgcc unwind code checks
> the second instruction opcode in __default_rt_sa_restorer function,
> it expects to see the following values for ARC cores:
> - 0x7ee0781e for ARCv2 LE
> - 0x003f226f for ARC700 LE
> 
> ARC700 value correspond to trap0 instruction. ARCv2 value corresponds
> to the following code:
>         traps_0
>         j_s     [blink]
> 
> However, unlike glibc, uClibc implementation of __default_rt_sa_restorer
> for ARC does not have that jump. Hence libgcc unwind code is not able
> to recognize signal frame correctly on ARCv2 and completes too early.
> 
> This change fixes libgcc unwinding over signal frame on ARCv2 adding
> missing jump to __default_rt_sa_restorer.
> 
> Signed-off-by: Sergey Matyukevich <sergey.matyukevich@synopsys.com>
> ---
>  libc/sysdeps/linux/arc/sigrestorer.S | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libc/sysdeps/linux/arc/sigrestorer.S b/libc/sysdeps/linux/arc/sigrestorer.S
> index e4deb6bd4..60d35ab3e 100644
> --- a/libc/sysdeps/linux/arc/sigrestorer.S
> +++ b/libc/sysdeps/linux/arc/sigrestorer.S
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (C) 2017 Synopsys, Inc. (www.synopsys.com)
> + * Copyright (C) 2017-2022 Synopsys, Inc. (www.synopsys.com)
>   *
>   * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
>   */
> @@ -22,4 +22,5 @@
>  __default_rt_sa_restorer:
>  	mov r8, __NR_rt_sigreturn
>  	ARC_TRAP_INSN
> +	j_s     [blink]
>  
> -- 
> 2.34.1
> 
> _______________________________________________
> devel mailing list -- devel@uclibc-ng.org
> To unsubscribe send an email to devel-leave@uclibc-ng.org
>
diff mbox series

Patch

diff --git a/libc/sysdeps/linux/arc/sigrestorer.S b/libc/sysdeps/linux/arc/sigrestorer.S
index e4deb6bd4..60d35ab3e 100644
--- a/libc/sysdeps/linux/arc/sigrestorer.S
+++ b/libc/sysdeps/linux/arc/sigrestorer.S
@@ -1,5 +1,5 @@ 
 /*
- * Copyright (C) 2017 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2017-2022 Synopsys, Inc. (www.synopsys.com)
  *
  * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  */
@@ -22,4 +22,5 @@ 
 __default_rt_sa_restorer:
 	mov r8, __NR_rt_sigreturn
 	ARC_TRAP_INSN
+	j_s     [blink]