[PATCH 4/4] gas: sframe: handle .cfi_same_value

Jens Remus jremus@linux.ibm.com
Tue May 13 08:54:02 GMT 2025


On 12.05.2025 23:25, Indu Bhagat wrote:
> On 5/12/25 3:10 AM, Jens Remus wrote:
>> On 11.05.2025 09:35, Indu Bhagat wrote:

>> Shouldn't SFrame therefore represent .cfi_same_value and .cfa_restore as
>> follows?
>>
>> .cfi_same_value <FP/RA>
>> Reset the FP/RA save information to "unsaved".  That is
>> {bp|ra}_loc = SFRAME_FRE_ELEM_LOC_REG and bp_offset = 0.
>>
> 
> This, then, is effectively the same as ignoring them.  Right ?

That depends on whether the previous rule to restore the register is
still valid.  If the stack save slots (or in case of S390 possibly
another register) are then used for other things the previous rule
would become invalid.

It may be that GDB erroneously ignored (at least in the past on AArch64)
.cfi_restore. At least the comment on .cfi_restore in Glibc
sysdeps/aarch64/__longjmp.S gives that impression.

Compilers usually do not emit .cfi_restore or .cfi_same_value when
restoring call saved registers in the epilogue.  I guess to save some
CFI instructions, as long as the then still effective rules do not
become invalid.

>> .cfi_same_value <SP>
>> May require architecture/ABI dependent handling.  On x86-64 ARM64 this
>> should probably cause the FDE to be skipped, as SP at function entry is
>> not equal to SP at call site (due to the call instruction).  On S390 it
>> should be safe to ignore, as the SP at function entry is equal to the
>> SP at call site.

In contrast (to the above) this is safe to ignore on S390, as SFrame
will use the implicit rule to restore SP from CFA.  Re-thinking I wonder
whether that does also mean it would be save to ignore on x86-64,
assuming the rule to compute the CFA is correct?

Regards,
Jens
-- 
Jens Remus
Linux on Z Development (D3303)
+49-7031-16-1128 Office
jremus@de.ibm.com

IBM

IBM Deutschland Research & Development GmbH; Vorsitzender des
Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der
Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/



More information about the Binutils mailing list