[binutils-gdb] OAv2 merge: mark unknown subsections

Matthieu Longo mlongo@sourceware.org
Thu Jan 22 10:13:16 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bd36d9a5641c725176b794df262af805807f11b5

commit bd36d9a5641c725176b794df262af805807f11b5
Author: Matthieu Longo <matthieu.longo@arm.com>
Date:   Fri Nov 14 19:34:25 2025 +0000

    OAv2 merge: mark unknown subsections
    
    In Object Attributes v2, the merge policy is not encoded within the
    subsection definition. It is therefore up to the linker to determine
    the appropriate policy based on the subsection's name and properties.
    Unless a subsection is explicitly recognized by the linker, the
    spefication of OAv2 provides no means to infer its merge policy.
    Furthermore, in theory, this merge policy could vary between
    attributes within the same subsection.
    
    As a result, before beginning the merge process, ld inspects each
    subsections, and attempts to identify them as either a GNU subsection,
    or a backend-specific one. If this identification fails, the status
    of the subsection is set to 'UNKNOWN'. Subsections marked as unknown
    are then skipped during the merge process, and later pruned from the
    output before the serialization.

Diff:
---
 bfd/elf-attrs.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c
index a09cf92e7aa..d3d3f328985 100644
--- a/bfd/elf-attrs.c
+++ b/bfd/elf-attrs.c
@@ -1036,8 +1036,14 @@ oav2_file_scope_merge_subsections (const bfd *abfd)
 static void
 oav2_subsections_mark_unknown (const bfd *abfd)
 {
-  (void) abfd;
-  /* TO IMPLEMENT */
+  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+  for (obj_attr_subsection_v2_t *subsec = elf_obj_attr_subsections (abfd).first;
+       subsec != NULL;
+       subsec = subsec->next)
+    {
+      if (bfd_obj_attr_v2_identify_subsection (bed, subsec->name) == NULL)
+	subsec->status = obj_attr_subsection_v2_unknown;
+    }
 }
 
 /* Merge object attributes from FROZEN into the object file ABFD.


More information about the Binutils-cvs mailing list