about summary refs log tree commit diff
path: root/sysdeps/riscv/start.S
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2018-09-25 11:11:27 +0200
committerAndreas Schwab <schwab@suse.de>2018-10-30 12:07:25 +0100
commit2dd12baa045f25c52b30a34b10f72d51f2605413 (patch)
tree0b6533d453252b050dcf19f052a1ccb4d6bf46cb /sysdeps/riscv/start.S
parentfec8bb7ca93d66cd2b019cfebcee6b3e6560ea36 (diff)
downloadglibc-2dd12baa045f25c52b30a34b10f72d51f2605413.tar.gz
glibc-2dd12baa045f25c52b30a34b10f72d51f2605413.tar.xz
glibc-2dd12baa045f25c52b30a34b10f72d51f2605413.zip
RISC-V: properly terminate call chain (bug 23125)
Mark the ra register as undefined in _start, so that unwinding through
main works correctly.  Also, don't use a tail call so that ra points after
the call to __libc_start_main, not after the previous call.
Diffstat (limited to 'sysdeps/riscv/start.S')
-rw-r--r--sysdeps/riscv/start.S7
1 files changed, 6 insertions, 1 deletions
diff --git a/sysdeps/riscv/start.S b/sysdeps/riscv/start.S
index 4635ddb5eb..2d6f06e630 100644
--- a/sysdeps/riscv/start.S
+++ b/sysdeps/riscv/start.S
@@ -43,6 +43,10 @@
    __libc_start_main wants this in a5.  */
 
 ENTRY (ENTRY_POINT)
+	/* Terminate call stack by noting ra is undefined.  Use a dummy
+	   .cfi_label to force starting the FDE.  */
+	.cfi_label .Ldummy
+	cfi_undefined (ra)
 	call  .Lload_gp
 	mv    a5, a0  /* rtld_fini.  */
 	/* main may be in a shared library.  */
@@ -54,7 +58,8 @@ ENTRY (ENTRY_POINT)
 	lla   a4, __libc_csu_fini
 	mv    a6, sp  /* stack_end.  */
 
-	tail  __libc_start_main@plt
+	call  __libc_start_main@plt
+	ebreak
 END (ENTRY_POINT)
 
 /* Dynamic links need the global pointer to be initialized prior to calling