[PATCH v10 08/28] bfd: write Object Attributes v2

Matthieu Longo matthieu.longo@arm.com
Wed Dec 10 13:18:47 GMT 2025


On 09/12/2025 15:58, Jan Beulich wrote:
> On 20.11.2025 18:58, Matthieu Longo wrote:
>>   /* Write the contents of the object attributes section to CONTENTS.  */
>>   void
>>   bfd_elf_set_obj_attr_contents (bfd *abfd, bfd_byte *buffer, bfd_vma size)
>>   {
>> -  write_obj_attr_section_v1 (abfd, buffer, size);
>> +  if ((! abfd->is_linker_output)
> 
> Why the extra parentheses? To me they only hamper readability.
> 

Fixed in the next revision.

>> +      && elf_obj_attr_version (abfd) == OBJ_ATTR_V2)
>> +    /* Before dumping the data, sort subsections in alphabetical order, and
>> +       attributes according to their tag in numerical order.  This is useful
>> +       for diagnostic tools so that they dump the same output even if the
>> +       subsections or their attributes were not declared in the same order in
>> +       different files.
>> +       This sorting is only performed in the case of the assembler.  In the
>> +       case of the linker, the subsections and attributes are already sorted
>> +       by the merge process.  */
>> +    oav2_sort_subsections (&elf_obj_attr_subsections (abfd));
>> +
>> +  obj_attr_version_t version = elf_obj_attr_version (abfd);
>> +  if (version == OBJ_ATTR_V1)
>> +    oav1_write_section (abfd, buffer, size);
>> +  else if (version == OBJ_ATTR_V2)
>> +    oav2_write_section (abfd, buffer, size);
>> +  else
>> +    abort ();
> 
> Another candidate for using switch()? Also, is it guaranteed that
> OBJ_ATTR_VERSION_NONE can't ever make it here?
> 

Fixed in the next revision.

> Okay preferably with those small adjustments.
> 
> Jan

Matthieu.


More information about the Binutils mailing list