[PATCH v9 02/19] gas: move code for object attribute parsing into obj-elf-attr.c
Matthieu Longo
matthieu.longo@arm.com
Mon Oct 27 17:31:57 GMT 2025
On 2025-10-24 13:15, Jan Beulich wrote:
> On 01.09.2025 18:56, Matthieu Longo wrote:
>> Gas, contrarilly to others binutils tools, is compiled for a specific
>> target. Some targets don't support Object Attributes (OAs). For those
>> cases, today the OA directive ".gnu_attribute" is still enabled but the
>> processing would probably fail in most of cases because the named tag
>> would be unknown. Most of the parsing code on such a target can be
>> considered as dead code.
>>
>> This patch aims at removing this dead code from Gas when the target does
>> not support the OAs by:
>> - moving the code of OA parsing into a separate file under gas/config
>> which is only included for the relevant targets supporting OAs.
>> - disabling the code related to OAs on non-OA target via a TC_OBJ_ATTR
>> macro.
>>
>> Adding/removing the OA feature from Gas for a specific target can easilly
>> be done from tc-<arch>.h by changing the values of TC_OBJ_ATTR: 1 enabled,
>> 0 disabled. You might also want to guard the enablement of OAs only for
>> ELF targets with OBJ_ELF (see example below).
>>
>> \#ifdef OBJ_ELF
>> /* The target supports Object Attributes. */
>> \#define TC_OBJ_ATTR 1
>> \#endif
>
> Okay, albeit I'm wondering ...
>
>> --- a/gas/config/obj-elf.c
>> +++ b/gas/config/obj-elf.c
>> @@ -71,7 +71,9 @@ static void obj_elf_visibility (int);
>> static void obj_elf_symver (int);
>> static void obj_elf_subsection (int);
>> static void obj_elf_popsection (int);
>> +#ifdef TC_OBJ_ATTR
>> static void obj_elf_gnu_attribute (int);
>> +#endif /* TC_OBJ_ATTR */
>
> ... this remains here. It would need to lose its static, yes, but otherwise
> couldn't the function also move into the new file?
>
> Jan
You are right. There's no good reason to keep it there.
I moved it into gas/config/obj-elf-attr.c
Matthieu
More information about the Binutils
mailing list