]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
OAv2 merge: mark unknown subsections
authorMatthieu Longo <matthieu.longo@arm.com>
Fri, 14 Nov 2025 19:34:25 +0000 (19:34 +0000)
committerMatthieu Longo <matthieu.longo@arm.com>
Thu, 22 Jan 2026 10:11:17 +0000 (10:11 +0000)
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.

bfd/elf-attrs.c

index a09cf92e7aaac15580be02f6f7044b1fc62e8d63..d3d3f328985e07499f85f1014ee89f8c200e0d9a 100644 (file)
@@ -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.