From 2dd12baa045f25c52b30a34b10f72d51f2605413 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 25 Sep 2018 11:11:27 +0200 Subject: 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. --- sysdeps/riscv/start.S | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sysdeps') 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 -- cgit 1.4.1