diff mbox series

[17/21] ARC: testsuite fix: stdlib/tst-makecontext

Message ID 1545167083-16764-18-git-send-email-vgupta@synopsys.com
State New
Headers show
Series glibc port to ARC processors | expand

Commit Message

Vineet Gupta Dec. 18, 2018, 9:04 p.m. UTC
Terminate the unwinding by telling unwinder to fetch return address
(BLINK) from r15 which has been set apriori to 0.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
 ChangeLog                                 | 2 ++
 sysdeps/unix/sysv/linux/arc/makecontext.c | 1 +
 sysdeps/unix/sysv/linux/arc/setcontext.S  | 2 ++
 3 files changed, 5 insertions(+)

Comments

Andreas Schwab Dec. 18, 2018, 10:36 p.m. UTC | #1
On Dez 18 2018, Vineet Gupta <vineet.gupta1@synopsys.com> wrote:

> diff --git a/sysdeps/unix/sysv/linux/arc/setcontext.S b/sysdeps/unix/sysv/linux/arc/setcontext.S
> index 3f503c661d95..6ec2ec0ddc79 100644
> --- a/sysdeps/unix/sysv/linux/arc/setcontext.S
> +++ b/sysdeps/unix/sysv/linux/arc/setcontext.S
> @@ -79,6 +79,8 @@ weak_alias(__setcontext, setcontext)
>  
>  ENTRY(__startcontext)
>  
> +	cfi_register (blink, r15)
> +

You should precede that with a dummy .cfi_label (see
sysdeps/riscv/start.S) to force the CFI into the FDE instead of the
CIE.  Also, can you use cfi_undefined instead?

Andreas.
Vineet Gupta Jan. 21, 2019, 10:32 p.m. UTC | #2
On 12/18/18 2:36 PM, Andreas Schwab wrote:
>>  ENTRY(__startcontext)
>>  
>> +	cfi_register (blink, r15)
>> +
> You should precede that with a dummy .cfi_label (see
> sysdeps/riscv/start.S) to force the CFI into the FDE instead of the
> CIE.  Also, can you use cfi_undefined instead?

Yes that works as well.


 ENTRY (__startcontext)

-       cfi_register (blink, r15)
+       .cfi_label .Ldummy
+       cfi_undefined (blink)


00035e14 <__startcontext>:
   35e14:	jl	[r13]
   35e18:	mov	r0,r14
   35e1c:	breq.nt	r0,0,8	;35e24 <__startcontext+0x10>
   35e20:	bl	-168	;35d78 <setcontext>
   35e24:	b	-38248	;2c8bc <exit>

New
----
0000058c 00000010 00000590 FDE cie=00000000 pc=00035e14..00035e28
  DW_CFA_undefined: r31
  DW_CFA_nop

Old
----
00035df4 <__startcontext>:
   35df4:	jl	[r13]
   35df8:	mov	r0,r14
   35dfc:	breq.nt	r0,0,8	;35e04 <__startcontext+0x10>
   35e00:	bl	-168	;35d58 <setcontext>
   35e04:	b	-38248	;2c89c <exit>

0000058c 00000014 00000000 CIE
  Version:               1
  Augmentation:          "zR"
  Code alignment factor: 1
  Data alignment factor: -4
  Return address column: 31
  Augmentation data:     1b
  DW_CFA_def_cfa: r28 ofs 0
  DW_CFA_register: r31 in r15
  DW_CFA_nop

000005a4 00000010 0000001c FDE cie=0000058c pc=00035df4..00035e08
  DW_CFA_nop
  DW_CFA_nop
  DW_CFA_nop
diff mbox series

Patch

diff --git a/ChangeLog b/ChangeLog
index d3a979a9236b..39ff298b0091 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -110,6 +110,8 @@ 
 	* sysdeps/arc/entry.h: Add ENTRY_POINT define check.
 	* sysdeps/arc/crti.S: add .hidden annotations.
 	* sysdeps/unix/sysv/linux/arc/ipc_priv.h: New file.
+	* sysdeps/unix/sysv/linux/arc/makecontext.c: clear r15.
+	* sysdeps/unix/sysv/linux/arc/setcontext.S: set blink from r15.
 
 2018-12-17  Joseph Myers  <joseph@codesourcery.com>
 
diff --git a/sysdeps/unix/sysv/linux/arc/makecontext.c b/sysdeps/unix/sysv/linux/arc/makecontext.c
index 7018bed9d64a..8d233f83da7e 100644
--- a/sysdeps/unix/sysv/linux/arc/makecontext.c
+++ b/sysdeps/unix/sysv/linux/arc/makecontext.c
@@ -45,6 +45,7 @@  __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
    */
   ucp->uc_mcontext.callee.r13 = (unsigned long) func;
   ucp->uc_mcontext.callee.r14 = (unsigned long) ucp->uc_link;
+  ucp->uc_mcontext.callee.r15 = 0;
 
   r = &ucp->uc_mcontext.scratch.r0;
 
diff --git a/sysdeps/unix/sysv/linux/arc/setcontext.S b/sysdeps/unix/sysv/linux/arc/setcontext.S
index 3f503c661d95..6ec2ec0ddc79 100644
--- a/sysdeps/unix/sysv/linux/arc/setcontext.S
+++ b/sysdeps/unix/sysv/linux/arc/setcontext.S
@@ -79,6 +79,8 @@  weak_alias(__setcontext, setcontext)
 
 ENTRY(__startcontext)
 
+	cfi_register (blink, r15)
+
         /* call user @func, loaded in r13 by setcontext() */
         jl   [r13]