[PATCH v9 06/19] bfd: write Object Attributes v2

Jan Beulich jbeulich@suse.com
Fri Nov 7 08:23:20 GMT 2025


On 05.11.2025 11:18, Matthieu Longo wrote:
> On 30/10/2025 15:55, Jan Beulich wrote:
>> On 01.09.2025 18:56, Matthieu Longo wrote:
>>> --- a/gas/write.c
>>> +++ b/gas/write.c
>>> @@ -1919,6 +1919,8 @@ create_obj_attrs_section (void)
>>>     bfd_set_section_flags (s, SEC_READONLY | SEC_DATA);
>>>     frag_now_fix ();
>>>     char *p = frag_more (size);
>>> +
>>> +  bfd_elf_obj_attr_finalize_contents (stdoutput);
>>>     bfd_elf_set_obj_attr_contents (stdoutput, (bfd_byte *)p, size);
>>
>> Why is another export needed from libbfd? Can't bfd_elf_set_obj_attr_contents()
>> simply do whatever it takes? The other caller likely needs doing the same anyway?
> 
> bfd_elf_set_obj_attr_contents() is also used in objcpy, and objcpy 
> should not change the order of subsections and attributes, but simply 
> make a copy of the data as they were in the original object.

Is this the case already prior to your series? I can't seem to be able to
identify the call path for that case. Besides the direct call from gas,
bfd_elf_set_obj_attr_contents() is called only from
_bfd_elf_write_section_build_attributes(), which in turn is called solely by
bfd_elf_final_link(). And I can't see this being used by objcopy.

> Another possibility might be to add a parameter to 
> bfd_elf_set_obj_attr_contents() to enable/disable the sorting.

Can the distinction not be made by what struct bfd_link_info contains?

Jan


More information about the Binutils mailing list