rtld: Annotate .rtld_start on aarch64

1. Add a stop indicator to rtld_start to satisfy unwinders on aarch64:
The right unwinding stop indicator should be CFI-undefined PC.
https://dwarfstd.org/doc/Dwarf3.pdf - page 118:
If a Return Address register is defined in the virtual unwind table,
and its rule is undefined (for example, by DW_CFA_undefined), then
there is no return address and no call address, and the virtual
unwind of stack activations is complete.

2. Add a proper annotations for CFA.

That is allows gdb and libunwind successfully stop when unwinding stack
from global constructors and destructors.

Reviewed by:
Differential Revision:	https://reviews.freebsd.org/D40844
This commit is contained in:
Dmitry Chagin 2023-07-07 19:55:28 +03:00
parent 5645dfb41a
commit ac7759f545

View file

@ -31,15 +31,18 @@
__FBSDID("$FreeBSD$");
ENTRY(.rtld_start)
.cfi_undefined x30
mov x19, x0 /* Put ps_strings in a callee-saved register */
sub sp, sp, #16 /* Make room for obj_main & exit proc */
.cfi_adjust_cfa_offset 16
mov x1, sp /* exit_proc */
add x2, x1, #8 /* obj_main */
bl _rtld /* Call the loader */
mov x8, x0 /* Backup the entry point */
ldp x2, x1, [sp], #16 /* Load cleanup, obj_main */
.cfi_adjust_cfa_offset 0
mov x0, x19 /* Restore ps_strings */
br x8 /* Jump to the entry point */