[PATCH v2 2/2] Enable arch-specific CFI directives and DWARF instructions only when required by the target (part 1)
Jan Beulich
jbeulich@suse.com
Tue May 13 12:40:19 GMT 2025
On 06.05.2025 13:20, Matthieu Longo wrote:
> On 2025-04-28 07:24, Jan Beulich wrote:
>> On 25.04.2025 17:53, Matthieu Longo wrote:
>>> On 2025-04-25 15:45, Jan Beulich wrote:
>>>> On 25.04.2025 16:02, Matthieu Longo wrote:
>>>>> On 2025-04-25 14:10, Jan Beulich wrote:
>>>>>> On 25.04.2025 13:04, Matthieu Longo wrote:
>>>>>>> --- a/gas/dw2gencfi.c
>>>>>>> +++ b/gas/dw2gencfi.c
>>>>>>> @@ -720,9 +720,16 @@ const pseudo_typeS cfi_pseudo_table[] =
>>>>>>> { "cfi_same_value", dot_cfi, DW_CFA_same_value },
>>>>>>> { "cfi_remember_state", dot_cfi, DW_CFA_remember_state },
>>>>>>> { "cfi_restore_state", dot_cfi, DW_CFA_restore_state },
>>>>>>> - { "cfi_window_save", dot_cfi, DW_CFA_GNU_window_save },
>>>>>>> +#if TC_AARCH64
>>>>>>> + /* cfi_window_save is an alias of cfi_negate_ra_state which is kept for
>>>>>>> + backward-compatibility concerns. */
>>>>>>> + { "cfi_window_save", dot_cfi, DW_CFA_AARCH64_negate_ra_state },
>>>>>>
>>>>>> Why's this of concern only for Arm64?
>>>>>
>>>>> I am not sure that I understand what your question is here.
>>>>> cfi_window_save is only used by AArch64 and Sparc.
>>>>
>>>> Arm64 uses .cfi_negate_ra_state. .cfi_window_save was wrongly exposed
>>>> everywhere except for Sparc. Hence as I view it either all other
>>>> architectures need to retain it for backwards compatibility, or none
>>>> of them. Yet perhaps I'm missing some peculiarity here.
>>>
>>> None of others architectures has used cfi_window_save, except AArch64.
>>> It does not mean that some people out there were not mistakenly adding
>>> the directive into their assembly files, but it was not doing anything
>>> anyway as it was ignored by the tools.
>>>
>>> You can check this inside GCC, and see that it is only used for
>>> unwinding inside Sparc and AArch64 backend.
>>
>> Hmm, beside this being a gross hack (.cfi_negate_ra_state ought to be
>> used there), commentary there even alludes to the possibility of using
>> these elsewhere.
>
> Please, could you be more explicit in what this is a gross hack ?
What I alluded to with the part in parentheses: To use .cfi_window_save
when .cfi_negate_ra_state is meant. See gcc's
dwarf2out_frame_debug_cfa_toggle_ra_mangle(), the bottom of
change_cfi_row(), and hence everything ending up at the
DW_CFA_GNU_window_save case in output_cfi_directive(). (All in gcc 14.2
sources; 15.1 looks better in this regard, as I now see, but the
correct directive still doesn't look to be used there.)
> What is this commentary you are referring to ?
E.g. the comment ahead of gcc's dwarf2out_frame_debug_cfa_toggle_ra_mangle():
/* A subroutine of dwarf2out_frame_debug, process a REG_CFA_TOGGLE_RA_MANGLE.
Note: DW_CFA_GNU_window_save dwarf opcode is reused for toggling RA mangle
state, this is a target specific operation on AArch64 and can only be used
on other targets if they don't use the window save operation otherwise. */
But also the absence of any target-specific commentary in gas code.
Jan
More information about the Binutils
mailing list