[PATCH v2 5/6] x86-64: Use RBP instead of RBX as CFA register in _dl_tlsdesc_dynamic
Aliaksei Kandratsenka
alkondratenko@gmail.com
Tue Nov 3 00:02:05 GMT 2026
The slow path of _dl_tlsdesc_dynamic realigns the stack and uses RBX as
the CFA register around the call to __tls_get_addr. As with the PLT
trampolines, unwinders that track only SP, FP and RA (SFrame, the Linux
kernel user-space unwinder, aw-backtrace) can use such a CFA only in
the topmost frame, so they cannot unwind out of __tls_get_addr.
Use RBP instead. The change is mechanical.
Signed-off-by: Aliaksei Kandratsenka <alkondratenko@gmail.com>
---
sysdeps/x86_64/dl-tlsdesc-dynamic.h | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/sysdeps/x86_64/dl-tlsdesc-dynamic.h b/sysdeps/x86_64/dl-tlsdesc-dynamic.h
index 7f47275c21..2b9b9983c9 100644
--- a/sysdeps/x86_64/dl-tlsdesc-dynamic.h
+++ b/sysdeps/x86_64/dl-tlsdesc-dynamic.h
@@ -79,14 +79,14 @@ _dl_tlsdesc_dynamic:
movq -8(%rsp), %rdi
ret
2:
- movq %rbx, -24(%rsp)
- mov %RSP_LP, %RBX_LP
- cfi_def_cfa_register(%rbx)
+ movq %rbp, -24(%rsp)
+ mov %RSP_LP, %RBP_LP
+ cfi_def_cfa_register(%rbp)
and $-STATE_SAVE_ALIGNMENT, %RSP_LP
#ifdef REGISTER_SAVE_AREA
/* STATE_SAVE_OFFSET has space for 8 integer registers. But we
need space for RCX, RDX, RSI, RDI, R8, R9, R10 and R11, plus
- RBX above. */
+ RBP above. */
sub $(REGISTER_SAVE_AREA + STATE_SAVE_ALIGNMENT), %RSP_LP
#else
/* Allocate stack space of the required size to save the state. */
@@ -141,10 +141,10 @@ _dl_tlsdesc_dynamic:
movq REGISTER_SAVE_R8(%rsp), %r8
movq REGISTER_SAVE_RDX(%rsp), %rdx
movq REGISTER_SAVE_RCX(%rsp), %rcx
- mov %RBX_LP, %RSP_LP
+ mov %RBP_LP, %RSP_LP
cfi_def_cfa_register(%rsp)
- movq -24(%rsp), %rbx
- cfi_restore(%rbx)
+ movq -24(%rsp), %rbp
+ cfi_restore(%rbp)
jmp 1b
cfi_endproc
.size _dl_tlsdesc_dynamic, .-_dl_tlsdesc_dynamic
--
2.55.0
More information about the Libc-alpha
mailing list