This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] RISC-V: Mark RA as undefined at the start of execution
- From: Palmer Dabbelt <palmer at dabbelt dot com>
- To: libc-alpha at sourceware dot org
- Cc: Palmer Dabbelt <palmer at dabbelt dot com>
- Date: Fri, 18 May 2018 17:49:53 -0700
- Subject: [PATCH] RISC-V: Mark RA as undefined at the start of execution
glibc bug 23125 (originally GCC bug 85492) demonstrates an infinate loop
in exception handling that results from RA as being undefined at the
start of program execution. This patch uses a CFI directive to mark RA
as undefined, which allows the backtrace to terminate.
There is no explicit glibc test case for this, but I thought I'd send
the patch out anyway as it is fixing a bug. I'd like to have a test
before committing this.
I have not even compiled this. I will do that before committing... :)
Thanks to Aurelian Jarno for finding the bug, and Jim Wilson for fixing
it.
ChangeLog
2018-05-18 Palmer Dabbelt <palmer@sifive.com>
PR 23125
* sysdeps/riscv/start.S (ENTRY_POINT): Mark ra as undefined so
backtraces can terminate if they reach this point.
---
sysdeps/riscv/start.S | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sysdeps/riscv/start.S b/sysdeps/riscv/start.S
index 4635ddb5eb8c..93a80bc4a760 100644
--- a/sysdeps/riscv/start.S
+++ b/sysdeps/riscv/start.S
@@ -43,6 +43,8 @@
__libc_start_main wants this in a5. */
ENTRY (ENTRY_POINT)
+ /* Mark ra as undefined in order to stop unwinding here! */
+ cfi_undefined (ra)
call .Lload_gp
mv a5, a0 /* rtld_fini. */
/* main may be in a shared library. */
--
2.16.1