git: 04262ed78d23 - main - rtld-elf: Add CFI annotation for .rtld_start on RISC-V

From: Alex Richardson <arichardson_at_FreeBSD.org>
Date: Mon, 26 Aug 2024 04:53:19 UTC
The branch main has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=04262ed78d2368a9e1f64755fb92a22872a20cac

commit 04262ed78d2368a9e1f64755fb92a22872a20cac
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2024-08-26 04:51:55 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2024-08-26 04:51:55 +0000

    rtld-elf: Add CFI annotation for .rtld_start on RISC-V
    
    Without this change, unwinders such as LLVM libunwind will attempt to
    unwind beyond the start of RTLD and get stuck in an infinite loop or
    crash (depending on the current values on the stack).
    This fixes an infinite loop in the LLVM libunwind test suite on RISC-V.
    
    See also https://reviews.freebsd.org/D40844 for AArch64
    
    Reviewed By:    #riscv, jhb
    MFC After:      2 weeks
    Differential Revision: https://reviews.freebsd.org/D46406
---
 libexec/rtld-elf/riscv/rtld_start.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libexec/rtld-elf/riscv/rtld_start.S b/libexec/rtld-elf/riscv/rtld_start.S
index 5459089fa1e6..e0b8157c964f 100644
--- a/libexec/rtld-elf/riscv/rtld_start.S
+++ b/libexec/rtld-elf/riscv/rtld_start.S
@@ -39,6 +39,7 @@
  */
 
 ENTRY(.rtld_start)
+	.cfi_undefined ra	/* Do not attempt to unwind any further. */
 	mv	s0, a0		/* Put ps_strings in a callee-saved register */
 	mv	s1, sp		/* And the stack pointer */