x86-64: Use RBP instead of RBX as CFA register in PLT trampolines

Message ID 20261019221729.3350862-1-alkondratenko@gmail.com (mailing list archive)
State Changes Requested
Headers
Series x86-64: Use RBP instead of RBX as CFA register in PLT trampolines |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
redhat-pt-bot/TryBot-32bit fail Patch series failed to apply
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed

Commit Message

Aliaksei Kandratsenka Oct. 19, 2026, 10:17 p.m. UTC
  _dl_runtime_resolve and _dl_runtime_profile save the machine state on
the stack around the call to _dl_fixup and _dl_profile_fixup.  Because
the stack is realigned, they use RBX as the CFA register for the
duration of that call.  This is valid DWARF and works for GDB and
libgcc, but not for unwinders that track only SP, FP and RA (SFrame,
the Linux kernel user-space unwinder, aw-backtrace).

Such unwinders can use a CFA based on another register only in the
topmost frame, because callees may have clobbered that register.  As a
result, a backtrace taken while _dl_fixup (or anything it calls) is
running stops at _dl_runtime_resolve.  The SFrame v3 specification's
example unwinder (Appendix A of "The SFrame Format") makes the same
restriction: it returns ERR_SFRAME_UNSAFE_UNWIND for a non-SP/FP CFA
base in any frame other than the topmost one.

Use RBP, the conventional frame pointer register, instead of RBX.  The
change is mechanical except in _dl_runtime_profile, where
La_x86_64_regs.lr_rbp is now loaded from the stack slot holding the
caller's RBP, since RBP itself has already been overwritten at that
point.

Signed-off-by: Aliaksei Kandratsenka <alkondratenko@gmail.com>
---

I found this while testing my aw-backtrace project
(https://github.com/gperftools/aw-backtrace).  The test single-steps
code, runs a signal handler at every instruction boundary, and checks
that the captured backtrace matches the actual call/ret sequence.  In
general, glibc (together with GCC) keeps unwind info on x86-64 correct
and simple; _dl_runtime_resolve is a notable exception.

Tested on x86_64-linux-gnu: make check on x86_64 and x32, no
regressions compared to the parent commit.. LD_AUDIT tested
manually. Also verified that aw-backtrace's backtrace-comparer now
passes on /usr/bin/true without suppressing _dl_fixup or
_dl_runtime_resolve.

 sysdeps/x86_64/dl-trampoline-state.h |  4 +-
 sysdeps/x86_64/dl-trampoline.h       | 85 ++++++++++++++--------------
 2 files changed, 45 insertions(+), 44 deletions(-)
  

Comments

Adhemerval Zanella Netto Oct. 26, 2026, 7:32 p.m. UTC | #1
On 19/10/26 19:17, Aliaksei Kandratsenka wrote:
> _dl_runtime_resolve and _dl_runtime_profile save the machine state on
> the stack around the call to _dl_fixup and _dl_profile_fixup.  Because
> the stack is realigned, they use RBX as the CFA register for the
> duration of that call.  This is valid DWARF and works for GDB and
> libgcc, but not for unwinders that track only SP, FP and RA (SFrame,
> the Linux kernel user-space unwinder, aw-backtrace).
> 
> Such unwinders can use a CFA based on another register only in the
> topmost frame, because callees may have clobbered that register.  As a
> result, a backtrace taken while _dl_fixup (or anything it calls) is
> running stops at _dl_runtime_resolve.  The SFrame v3 specification's
> example unwinder (Appendix A of "The SFrame Format") makes the same
> restriction: it returns ERR_SFRAME_UNSAFE_UNWIND for a non-SP/FP CFA
> base in any frame other than the topmost one.
> 
> Use RBP, the conventional frame pointer register, instead of RBX.  The
> change is mechanical except in _dl_runtime_profile, where
> La_x86_64_regs.lr_rbp is now loaded from the stack slot holding the
> caller's RBP, since RBP itself has already been overwritten at that
> point.
> 
> Signed-off-by: Aliaksei Kandratsenka <alkondratenko@gmail.com>
> ---
> 
> I found this while testing my aw-backtrace project
> (https://github.com/gperftools/aw-backtrace).  The test single-steps
> code, runs a signal handler at every instruction boundary, and checks
> that the captured backtrace matches the actual call/ret sequence.  In
> general, glibc (together with GCC) keeps unwind info on x86-64 correct
> and simple; _dl_runtime_resolve is a notable exception.
> 
> Tested on x86_64-linux-gnu: make check on x86_64 and x32, no
> regressions compared to the parent commit.. LD_AUDIT tested
> manually. Also verified that aw-backtrace's backtrace-comparer now
> passes on /usr/bin/true without suppressing _dl_fixup or
> _dl_runtime_resolve.
> 
>  sysdeps/x86_64/dl-trampoline-state.h |  4 +-
>  sysdeps/x86_64/dl-trampoline.h       | 85 ++++++++++++++--------------
>  2 files changed, 45 insertions(+), 44 deletions(-)
> 
> diff --git a/sysdeps/x86_64/dl-trampoline-state.h b/sysdeps/x86_64/dl-trampoline-state.h
> index 21cc9d5082..9a2703c159 100644
> --- a/sysdeps/x86_64/dl-trampoline-state.h
> +++ b/sysdeps/x86_64/dl-trampoline-state.h
> @@ -25,9 +25,9 @@
>  #endif
>  
>  #if DL_RUNTIME_RESOLVE_REALIGN_STACK
> -/* Local stack area before jumping to function address: RBX.  */
> +/* Local stack area before jumping to function address: RBP.  */
>  # define LOCAL_STORAGE_AREA	8
> -# define BASE			rbx
> +# define BASE			rbp
>  # ifdef USE_FXSAVE
>  /* Use fxsave to save XMM registers.  */
>  #  define REGISTER_SAVE_AREA	(512 + STATE_SAVE_OFFSET)

The dl-tlsdesc-dynamic.h also includes this header, and although it does not
use BASE or LOCAL_STORAGE_AREA, I think it has a similar issue.

> diff --git a/sysdeps/x86_64/dl-trampoline.h b/sysdeps/x86_64/dl-trampoline.h
> index b07f29c55a..7717f539b7 100644
> --- a/sysdeps/x86_64/dl-trampoline.h
> +++ b/sysdeps/x86_64/dl-trampoline.h
> @@ -41,11 +41,11 @@ _dl_runtime_resolve:
>  #  if LOCAL_STORAGE_AREA != 8
>  #   error LOCAL_STORAGE_AREA must be 8
>  #  endif
> -	pushq %rbx			# push subtracts stack by 8.
> +	pushq %rbp			# push subtracts stack by 8.
>  	cfi_adjust_cfa_offset(8)
> -	cfi_rel_offset(%rbx, 0)
> -	mov %RSP_LP, %RBX_LP
> -	cfi_def_cfa_register(%rbx)
> +	cfi_rel_offset(%rbp, 0)
> +	mov %RSP_LP, %RBP_LP
> +	cfi_def_cfa_register(%rbp)


After this, %rbp points to something that looks like a frame record but
is not one.  0(%rbp) is the caller's %rbp, but 8(%rbp) is the link_map
that PLT0 pushed, not a return address.

A walker that only follows frame pointers now reports the link_map pointer
as a frame.

I think adding a copy of the return address first turns it into a real frame
record,:

	pushq 16(%rsp)
	cfi_adjust_cfa_offset(8)
	pushq %rbp
	cfi_adjust_cfa_offset(8)
	cfi_rel_offset(%rbp, 0)
	mov %RSP_LP, %RBP_LP
	cfi_def_cfa_register(%rbp)

For this, set LOCAL_STORAGE_AREA to 16.  The cost is one push next to the
xsave.  I would not do the same in _dl_runtime_profile.

>  	and $-STATE_SAVE_ALIGNMENT, %RSP_LP
>  # endif
>  # ifdef REGISTER_SAVE_AREA
> @@ -113,10 +113,10 @@ _dl_runtime_resolve:
>  	movq REGISTER_SAVE_RCX(%rsp), %rcx
>  	movq REGISTER_SAVE_RAX(%rsp), %rax
>  # if DL_RUNTIME_RESOLVE_REALIGN_STACK
> -	mov %RBX_LP, %RSP_LP
> +	mov %RBP_LP, %RSP_LP
>  	cfi_def_cfa_register(%rsp)
> -	movq (%rsp), %rbx
> -	cfi_restore(%rbx)
> +	movq (%rsp), %rbp
> +	cfi_restore(%rbp)
>  # endif
>  	# Adjust stack(PLT did 2 pushes)
>  	add $(LOCAL_STORAGE_AREA + 16), %RSP_LP
> @@ -143,30 +143,30 @@ _dl_runtime_profile:
>  	/* The La_x86_64_regs data structure pointed to by the
>  	   fourth parameter must be VEC_SIZE-byte aligned.  This must
>  	   be explicitly enforced.  We have the set up a dynamically
> -	   sized stack frame.  %rbx points to the top half which
> +	   sized stack frame.  %rbp points to the top half which
>  	   has a fixed size and preserves the original stack pointer.  */
>  
>  	sub $32, %RSP_LP	# Allocate the local storage.
>  	cfi_adjust_cfa_offset(32)
> -	movq %rbx, (%rsp)
> -	cfi_rel_offset(%rbx, 0)
> +	movq %rbp, (%rsp)
> +	cfi_rel_offset(%rbp, 0)
>  
>  	/* On the stack:
> -		56(%rbx)	parameter #1
> -		48(%rbx)	return address
> +		56(%rbp)	parameter #1
> +		48(%rbp)	return address
>  
> -		40(%rbx)	reloc index
> -		32(%rbx)	link_map
> +		40(%rbp)	reloc index
> +		32(%rbp)	link_map
>  
> -		24(%rbx)	La_x86_64_regs pointer
> -		16(%rbx)	framesize
> -		 8(%rbx)	rax
> -		  (%rbx)	rbx
> +		24(%rbp)	La_x86_64_regs pointer
> +		16(%rbp)	framesize
> +		 8(%rbp)	rax
> +		  (%rbp)	rbp
>  	*/
>  
>  	movq %rax, 8(%rsp)
> -	mov %RSP_LP, %RBX_LP
> -	cfi_def_cfa_register(%rbx)
> +	mov %RSP_LP, %RBP_LP
> +	cfi_def_cfa_register(%rbp)
>  
>  	/* Actively align the La_x86_64_regs structure.  */
>  	and $-VEC_SIZE, %RSP_LP
> @@ -174,7 +174,7 @@ _dl_runtime_profile:
>  	   to detect if any xmm0-xmm7 registers are changed by audit
>  	   module.  */
>  	sub $(LR_SIZE + XMM_SIZE*8), %RSP_LP
> -	movq %rsp, 24(%rbx)
> +	movq %rsp, 24(%rbp)
>  
>  	/* Fill the La_x86_64_regs structure.  */
>  	movq %rdx, LR_RDX_OFFSET(%rsp)
> @@ -183,9 +183,10 @@ _dl_runtime_profile:
>  	movq %rcx, LR_RCX_OFFSET(%rsp)
>  	movq %rsi, LR_RSI_OFFSET(%rsp)
>  	movq %rdi, LR_RDI_OFFSET(%rsp)
> -	movq %rbp, LR_RBP_OFFSET(%rsp)
> +	movq (%rbp), %rax	# Caller's %rbp, saved above.
> +	movq %rax, LR_RBP_OFFSET(%rsp)
>  
> -	lea 48(%rbx), %RAX_LP
> +	lea 48(%rbp), %RAX_LP
>  	movq %rax, LR_RSP_OFFSET(%rsp)
>  
>  	/* We always store the XMM registers even if AVX is available.
> @@ -224,15 +225,15 @@ _dl_runtime_profile:
>  # endif
>  
>  	mov %RSP_LP, %RCX_LP	# La_x86_64_regs pointer to %rcx.
> -	mov 48(%rbx), %RDX_LP	# Load return address if needed.
> -	mov 40(%rbx), %RSI_LP	# Copy args pushed by PLT in register.
> -	mov 32(%rbx), %RDI_LP	# %rdi: link_map, %rsi: reloc_index
> -	lea 16(%rbx), %R8_LP	# Address of framesize
> +	mov 48(%rbp), %RDX_LP	# Load return address if needed.
> +	mov 40(%rbp), %RSI_LP	# Copy args pushed by PLT in register.
> +	mov 32(%rbp), %RDI_LP	# %rdi: link_map, %rsi: reloc_index
> +	lea 16(%rbp), %R8_LP	# Address of framesize
>  	call _dl_profile_fixup	# Call resolver.
>  
>  	mov %RAX_LP, %R11_LP	# Save return value.
>  
> -	movq 8(%rbx), %rax	# Get back register content.
> +	movq 8(%rbp), %rax	# Get back register content.
>  	movq LR_RDX_OFFSET(%rsp), %rdx
>  	movq  LR_R8_OFFSET(%rsp), %r8
>  	movq  LR_R9_OFFSET(%rsp), %r9
> @@ -324,7 +325,7 @@ _dl_runtime_profile:
>  1:
>  # endif
>  
> -	mov  16(%rbx), %RCX_LP	# Anything in framesize?
> +	mov  16(%rbp), %RCX_LP	# Anything in framesize?
>  	test %RCX_LP, %RCX_LP
>  	jns 3f
>  
> @@ -336,9 +337,9 @@ _dl_runtime_profile:
>  	movq LR_RSI_OFFSET(%rsp), %rsi
>  	movq LR_RDI_OFFSET(%rsp), %rdi
>  
> -	mov %RBX_LP, %RSP_LP
> -	movq (%rsp), %rbx
> -	cfi_restore(%rbx)
> +	mov %RBP_LP, %RSP_LP
> +	movq (%rsp), %rbp
> +	cfi_restore(%rbp)
>  	cfi_def_cfa_register(%rsp)
>  
>  	add $48, %RSP_LP	# Adjust the stack to the return value
> @@ -348,15 +349,15 @@ _dl_runtime_profile:
>  
>  3:
>  	cfi_adjust_cfa_offset(48)
> -	cfi_rel_offset(%rbx, 0)
> -	cfi_def_cfa_register(%rbx)
> +	cfi_rel_offset(%rbp, 0)
> +	cfi_def_cfa_register(%rbp)
>  
>  	/* At this point we need to prepare new stack for the function
>  	   which has to be called.  We copy the original stack to a
>  	   temporary buffer of the size specified by the 'framesize'
>  	   returned from _dl_profile_fixup */
>  
> -	lea LR_RSP_OFFSET(%rbx), %RSI_LP # stack
> +	lea LR_RSP_OFFSET(%rbp), %RSI_LP # stack
>  	add $8, %RCX_LP
>  	and $-16, %RCX_LP
>  	sub %RCX_LP, %RSP_LP
> @@ -369,7 +370,7 @@ _dl_runtime_profile:
>  
>  	call *%r11
>  
> -	mov 24(%rbx), %RSP_LP	# Drop the copied stack content
> +	mov 24(%rbp), %RSP_LP	# Drop the copied stack content
>  
>  	/* Now we have to prepare the La_x86_64_retval structure for the
>  	   _dl_audit_pltexit.  The La_x86_64_regs is being pointed by rsp now,
> @@ -414,9 +415,9 @@ _dl_runtime_profile:
>  	fstpt LRV_ST0_OFFSET(%rcx)
>  	fstpt LRV_ST1_OFFSET(%rcx)
>  
> -	movq 24(%rbx), %rdx	# La_x86_64_regs argument to %rdx.
> -	movq 40(%rbx), %rsi	# Copy args pushed by PLT in register.
> -	movq 32(%rbx), %rdi	# %rdi: link_map, %rsi: reloc_index
> +	movq 24(%rbp), %rdx	# La_x86_64_regs argument to %rdx.
> +	movq 40(%rbp), %rsi	# Copy args pushed by PLT in register.
> +	movq 32(%rbp), %rdi	# %rdi: link_map, %rsi: reloc_index
>  	call _dl_audit_pltexit
>  
>  	/* Restore return registers.  */
> @@ -446,9 +447,9 @@ _dl_runtime_profile:
>  	fldt LRV_ST1_OFFSET(%rsp)
>  	fldt LRV_ST0_OFFSET(%rsp)
>  
> -	mov %RBX_LP, %RSP_LP
> -	movq (%rsp), %rbx
> -	cfi_restore(%rbx)
> +	mov %RBP_LP, %RSP_LP
> +	movq (%rsp), %rbp
> +	cfi_restore(%rbp)
>  	cfi_def_cfa_register(%rsp)
>  
>  	add $48, %RSP_LP	# Adjust the stack to the return value

The rest of the conversion looks right to me.

One more thing outside the patch, I think sysdeps/x86_64/dl-tlsdesc-dynamic.h has
a similar same pattern (an RBX-based CFA around the call to __tls_get_addr). But
I have not tested nor check it with our project.
  

Patch

diff --git a/sysdeps/x86_64/dl-trampoline-state.h b/sysdeps/x86_64/dl-trampoline-state.h
index 21cc9d5082..9a2703c159 100644
--- a/sysdeps/x86_64/dl-trampoline-state.h
+++ b/sysdeps/x86_64/dl-trampoline-state.h
@@ -25,9 +25,9 @@ 
 #endif
 
 #if DL_RUNTIME_RESOLVE_REALIGN_STACK
-/* Local stack area before jumping to function address: RBX.  */
+/* Local stack area before jumping to function address: RBP.  */
 # define LOCAL_STORAGE_AREA	8
-# define BASE			rbx
+# define BASE			rbp
 # ifdef USE_FXSAVE
 /* Use fxsave to save XMM registers.  */
 #  define REGISTER_SAVE_AREA	(512 + STATE_SAVE_OFFSET)
diff --git a/sysdeps/x86_64/dl-trampoline.h b/sysdeps/x86_64/dl-trampoline.h
index b07f29c55a..7717f539b7 100644
--- a/sysdeps/x86_64/dl-trampoline.h
+++ b/sysdeps/x86_64/dl-trampoline.h
@@ -41,11 +41,11 @@  _dl_runtime_resolve:
 #  if LOCAL_STORAGE_AREA != 8
 #   error LOCAL_STORAGE_AREA must be 8
 #  endif
-	pushq %rbx			# push subtracts stack by 8.
+	pushq %rbp			# push subtracts stack by 8.
 	cfi_adjust_cfa_offset(8)
-	cfi_rel_offset(%rbx, 0)
-	mov %RSP_LP, %RBX_LP
-	cfi_def_cfa_register(%rbx)
+	cfi_rel_offset(%rbp, 0)
+	mov %RSP_LP, %RBP_LP
+	cfi_def_cfa_register(%rbp)
 	and $-STATE_SAVE_ALIGNMENT, %RSP_LP
 # endif
 # ifdef REGISTER_SAVE_AREA
@@ -113,10 +113,10 @@  _dl_runtime_resolve:
 	movq REGISTER_SAVE_RCX(%rsp), %rcx
 	movq REGISTER_SAVE_RAX(%rsp), %rax
 # if DL_RUNTIME_RESOLVE_REALIGN_STACK
-	mov %RBX_LP, %RSP_LP
+	mov %RBP_LP, %RSP_LP
 	cfi_def_cfa_register(%rsp)
-	movq (%rsp), %rbx
-	cfi_restore(%rbx)
+	movq (%rsp), %rbp
+	cfi_restore(%rbp)
 # endif
 	# Adjust stack(PLT did 2 pushes)
 	add $(LOCAL_STORAGE_AREA + 16), %RSP_LP
@@ -143,30 +143,30 @@  _dl_runtime_profile:
 	/* The La_x86_64_regs data structure pointed to by the
 	   fourth parameter must be VEC_SIZE-byte aligned.  This must
 	   be explicitly enforced.  We have the set up a dynamically
-	   sized stack frame.  %rbx points to the top half which
+	   sized stack frame.  %rbp points to the top half which
 	   has a fixed size and preserves the original stack pointer.  */
 
 	sub $32, %RSP_LP	# Allocate the local storage.
 	cfi_adjust_cfa_offset(32)
-	movq %rbx, (%rsp)
-	cfi_rel_offset(%rbx, 0)
+	movq %rbp, (%rsp)
+	cfi_rel_offset(%rbp, 0)
 
 	/* On the stack:
-		56(%rbx)	parameter #1
-		48(%rbx)	return address
+		56(%rbp)	parameter #1
+		48(%rbp)	return address
 
-		40(%rbx)	reloc index
-		32(%rbx)	link_map
+		40(%rbp)	reloc index
+		32(%rbp)	link_map
 
-		24(%rbx)	La_x86_64_regs pointer
-		16(%rbx)	framesize
-		 8(%rbx)	rax
-		  (%rbx)	rbx
+		24(%rbp)	La_x86_64_regs pointer
+		16(%rbp)	framesize
+		 8(%rbp)	rax
+		  (%rbp)	rbp
 	*/
 
 	movq %rax, 8(%rsp)
-	mov %RSP_LP, %RBX_LP
-	cfi_def_cfa_register(%rbx)
+	mov %RSP_LP, %RBP_LP
+	cfi_def_cfa_register(%rbp)
 
 	/* Actively align the La_x86_64_regs structure.  */
 	and $-VEC_SIZE, %RSP_LP
@@ -174,7 +174,7 @@  _dl_runtime_profile:
 	   to detect if any xmm0-xmm7 registers are changed by audit
 	   module.  */
 	sub $(LR_SIZE + XMM_SIZE*8), %RSP_LP
-	movq %rsp, 24(%rbx)
+	movq %rsp, 24(%rbp)
 
 	/* Fill the La_x86_64_regs structure.  */
 	movq %rdx, LR_RDX_OFFSET(%rsp)
@@ -183,9 +183,10 @@  _dl_runtime_profile:
 	movq %rcx, LR_RCX_OFFSET(%rsp)
 	movq %rsi, LR_RSI_OFFSET(%rsp)
 	movq %rdi, LR_RDI_OFFSET(%rsp)
-	movq %rbp, LR_RBP_OFFSET(%rsp)
+	movq (%rbp), %rax	# Caller's %rbp, saved above.
+	movq %rax, LR_RBP_OFFSET(%rsp)
 
-	lea 48(%rbx), %RAX_LP
+	lea 48(%rbp), %RAX_LP
 	movq %rax, LR_RSP_OFFSET(%rsp)
 
 	/* We always store the XMM registers even if AVX is available.
@@ -224,15 +225,15 @@  _dl_runtime_profile:
 # endif
 
 	mov %RSP_LP, %RCX_LP	# La_x86_64_regs pointer to %rcx.
-	mov 48(%rbx), %RDX_LP	# Load return address if needed.
-	mov 40(%rbx), %RSI_LP	# Copy args pushed by PLT in register.
-	mov 32(%rbx), %RDI_LP	# %rdi: link_map, %rsi: reloc_index
-	lea 16(%rbx), %R8_LP	# Address of framesize
+	mov 48(%rbp), %RDX_LP	# Load return address if needed.
+	mov 40(%rbp), %RSI_LP	# Copy args pushed by PLT in register.
+	mov 32(%rbp), %RDI_LP	# %rdi: link_map, %rsi: reloc_index
+	lea 16(%rbp), %R8_LP	# Address of framesize
 	call _dl_profile_fixup	# Call resolver.
 
 	mov %RAX_LP, %R11_LP	# Save return value.
 
-	movq 8(%rbx), %rax	# Get back register content.
+	movq 8(%rbp), %rax	# Get back register content.
 	movq LR_RDX_OFFSET(%rsp), %rdx
 	movq  LR_R8_OFFSET(%rsp), %r8
 	movq  LR_R9_OFFSET(%rsp), %r9
@@ -324,7 +325,7 @@  _dl_runtime_profile:
 1:
 # endif
 
-	mov  16(%rbx), %RCX_LP	# Anything in framesize?
+	mov  16(%rbp), %RCX_LP	# Anything in framesize?
 	test %RCX_LP, %RCX_LP
 	jns 3f
 
@@ -336,9 +337,9 @@  _dl_runtime_profile:
 	movq LR_RSI_OFFSET(%rsp), %rsi
 	movq LR_RDI_OFFSET(%rsp), %rdi
 
-	mov %RBX_LP, %RSP_LP
-	movq (%rsp), %rbx
-	cfi_restore(%rbx)
+	mov %RBP_LP, %RSP_LP
+	movq (%rsp), %rbp
+	cfi_restore(%rbp)
 	cfi_def_cfa_register(%rsp)
 
 	add $48, %RSP_LP	# Adjust the stack to the return value
@@ -348,15 +349,15 @@  _dl_runtime_profile:
 
 3:
 	cfi_adjust_cfa_offset(48)
-	cfi_rel_offset(%rbx, 0)
-	cfi_def_cfa_register(%rbx)
+	cfi_rel_offset(%rbp, 0)
+	cfi_def_cfa_register(%rbp)
 
 	/* At this point we need to prepare new stack for the function
 	   which has to be called.  We copy the original stack to a
 	   temporary buffer of the size specified by the 'framesize'
 	   returned from _dl_profile_fixup */
 
-	lea LR_RSP_OFFSET(%rbx), %RSI_LP # stack
+	lea LR_RSP_OFFSET(%rbp), %RSI_LP # stack
 	add $8, %RCX_LP
 	and $-16, %RCX_LP
 	sub %RCX_LP, %RSP_LP
@@ -369,7 +370,7 @@  _dl_runtime_profile:
 
 	call *%r11
 
-	mov 24(%rbx), %RSP_LP	# Drop the copied stack content
+	mov 24(%rbp), %RSP_LP	# Drop the copied stack content
 
 	/* Now we have to prepare the La_x86_64_retval structure for the
 	   _dl_audit_pltexit.  The La_x86_64_regs is being pointed by rsp now,
@@ -414,9 +415,9 @@  _dl_runtime_profile:
 	fstpt LRV_ST0_OFFSET(%rcx)
 	fstpt LRV_ST1_OFFSET(%rcx)
 
-	movq 24(%rbx), %rdx	# La_x86_64_regs argument to %rdx.
-	movq 40(%rbx), %rsi	# Copy args pushed by PLT in register.
-	movq 32(%rbx), %rdi	# %rdi: link_map, %rsi: reloc_index
+	movq 24(%rbp), %rdx	# La_x86_64_regs argument to %rdx.
+	movq 40(%rbp), %rsi	# Copy args pushed by PLT in register.
+	movq 32(%rbp), %rdi	# %rdi: link_map, %rsi: reloc_index
 	call _dl_audit_pltexit
 
 	/* Restore return registers.  */
@@ -446,9 +447,9 @@  _dl_runtime_profile:
 	fldt LRV_ST1_OFFSET(%rsp)
 	fldt LRV_ST0_OFFSET(%rsp)
 
-	mov %RBX_LP, %RSP_LP
-	movq (%rsp), %rbx
-	cfi_restore(%rbx)
+	mov %RBP_LP, %RSP_LP
+	movq (%rsp), %rbp
+	cfi_restore(%rbp)
 	cfi_def_cfa_register(%rsp)
 
 	add $48, %RSP_LP	# Adjust the stack to the return value