From a264cb726bfb051bf012cd234c33966cb5ed3828 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 10 Nov 2017 01:17:26 +0000 Subject: [PATCH] Some fixups to the CFI directives for PLT stub entry points. The directives I added in r323466 and r323501 did not define a valid CFA until several instructions into the associated functions. This triggers an assertion in GDB when generating a stack trace while stopped at the first instruction of PLT stub entry point since there is no valid CFA rule for the first instruction. This is probably just wrong on my part as the non-simple .cfi_startproc would have defined a valid CFA. Instead, define a valid CFA as sp + 0 at the start of the functions and then use .cfa_def_offset to change the offset when sp is adjusted later in the function. Sponsored by: DARPA / AFRL --- libexec/rtld-elf/mips/rtld_start.S | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libexec/rtld-elf/mips/rtld_start.S b/libexec/rtld-elf/mips/rtld_start.S index fc5e0f80d1f..10e2e571bbc 100644 --- a/libexec/rtld-elf/mips/rtld_start.S +++ b/libexec/rtld-elf/mips/rtld_start.S @@ -32,6 +32,8 @@ #include + .cfi_sections .debug_frame + .globl _C_LABEL(_rtld_relocate_nonplt_self) .globl _C_LABEL(_rtld) @@ -107,6 +109,7 @@ END(rtld_start) _rtld_bind_start: .frame sp, XCALLFRAME_SIZ, $15 .cfi_startproc simple + .cfi_def_cfa sp, 0 .cfi_register ra, $15 move v1, gp /* save old GP */ #if defined(__mips_o32) || defined(__mips_o64) @@ -114,7 +117,7 @@ _rtld_bind_start: #endif SETUP_GP PTR_SUBU sp, XCALLFRAME_SIZ /* save arguments and sp value in stack */ - .cfi_def_cfa sp, XCALLFRAME_SIZ + .cfi_def_cfa_offset XCALLFRAME_SIZ SETUP_GP64(XCALLFRAME_GP, _rtld_bind_start) SAVE_GP(XCALLFRAME_GP) #if defined(__mips_n32) || defined(__mips_n64) @@ -200,6 +203,7 @@ END(_rtld_bind_start) _rtld_pltbind_start: .frame sp, XCALLFRAME_SIZ, $15 .cfi_startproc simple + .cfi_def_cfa sp, 0 .cfi_register ra, $15 #if defined(__mips_o32) move v1, gp /* save pointer to .got.plt */ @@ -211,7 +215,7 @@ _rtld_pltbind_start: #endif SETUP_GP PTR_SUBU sp, XCALLFRAME_SIZ /* save arguments and sp value in stack */ - .cfi_def_cfa sp, XCALLFRAME_SIZ + .cfi_def_cfa_offset XCALLFRAME_SIZ SETUP_GP64(XCALLFRAME_GP, _rtld_pltbind_start) SAVE_GP(XCALLFRAME_GP) #if defined(__mips_n32) || defined(__mips_n64)