[PATCH v11 14/25] OAv2 merge: merge subsections and tags at file scope
Matthieu Longo
matthieu.longo@arm.com
Mon Jan 12 18:08:08 GMT 2026
On 08/01/2026 14:02, Jan Beulich wrote:
> On 31.12.2025 00:05, Matthieu Longo wrote:
>> Before merging input object files together, each input's object
>> attributes must be sanitized to ensure that duplicate subsections and
>> attributes are merged and properly sorted. Indeed, uniqueness and
>> ordering of subsections and attributes are required prerequisites for
>> the merge process.
>> This operation also handles, on a best-effort basis, exotic objects
>> produced by non-GNU assemblers, where duplicate subsections may appear
>> across different sections, and similarly, duplicate attributes across
>> subsections.
>> It is importand to note that such cases are not covered by the Object
>> Attributes specification, and the resulting behavior is implementation
>> -defined. Other linkers may handle these inputs differently.
>> ---
>> bfd/elf-attrs.c | 182 +++++++++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 179 insertions(+), 3 deletions(-)
>
> Okay with ...
>
>> +/* Merge two subsections together (object attributes v2 only).
>> + The result is stored into subsec1. subsec2 is destroyed.
>> + Return true if the merge was successful, false otherwise.
>> + Note: subsec1 and subsec2 are expected to be sorted before the call to this
>> + function. */
>> +static bool
>> +oav2_subsection_destructive_merge (const bfd *abfd,
>> + obj_attr_subsection_v2_t *subsec1,
>> + obj_attr_subsection_v2_t *subsec2)
>> +{
>> + BFD_ASSERT (subsec1->encoding == subsec2->encoding
>> + && subsec1->optional == subsec2->optional);
>> +
>> + bool success = true;
>> +
>> + success &= oav2_compact_tags (abfd, subsec1);
>> + success &= oav2_compact_tags (abfd, subsec2);
>> +
>> + obj_attr_v2_t *a1 = subsec1->first;
>> + obj_attr_v2_t *a2 = subsec2->first;
>> + while (a1 != NULL && a2 != NULL)
>> + {
>> + if (a1->tag < a2->tag)
>> + {} /* Nothing to do, a1 is already in subsec1. */
>> + else if (a1->tag > a2->tag)
>> + {
>> + /* a2 is missing in subsec1, add it. */
>> + obj_attr_v2_t *previous
>> + = LINKED_LIST_REMOVE(obj_attr_v2_t) (subsec2, a2);
>> + LINKED_LIST_INSERT_BEFORE(obj_attr_v2_t) (subsec1, a2, a1);
>
> ... the style issue here (and further down) addressed.
>
> Jan
Here, and others places, added a space between the macro and the opening bracket.
Matthieu.
More information about the Binutils
mailing list