return sec;
}
+/* Prune empty generic properties. */
+
+static void
+elf_prune_empty_properties (elf_property_list **pp)
+{
+ elf_property_list *p;
+
+ while ((p = *pp) != NULL)
+ if ((p->property.pr_type < GNU_PROPERTY_LOPROC
+ || p->property.pr_type >= GNU_PROPERTY_LOUSER)
+ && p->property.pr_datasz != 0
+ && p->property.pr_kind == property_number
+ && p->property.u.number == 0)
+ *pp = p->next;
+ else
+ pp = &p->next;
+}
/* Set up GNU properties. Return the first relocatable ELF input with
GNU properties if found. Otherwise, return NULL. */
if (bed->fixup_gnu_properties)
bed->fixup_gnu_properties (info, &elf_properties (first_pbfd));
- if (elf_properties (first_pbfd) == NULL)
- {
- /* Discard .note.gnu.property section if all properties have
- been removed. */
- sec->output_section = bfd_abs_section_ptr;
- return NULL;
- }
-
- /* Compute the section size. */
- list = elf_properties (first_pbfd);
- size = elf_get_gnu_property_section_size (list, align_size);
-
- /* Update .note.gnu.property section now. */
- sec->size = size;
- contents = (bfd_byte *) bfd_zalloc (first_pbfd, size);
-
if (info->indirect_extern_access <= 0)
{
/* Get GNU_PROPERTY_1_NEEDED properties. */
}
}
+ elf_prune_empty_properties (&elf_properties (first_pbfd));
+
+ if (elf_properties (first_pbfd) == NULL)
+ {
+ /* Discard .note.gnu.property section if all properties have
+ been removed. */
+ sec->output_section = bfd_abs_section_ptr;
+ return NULL;
+ }
+
+ /* Compute the section size. */
+ list = elf_properties (first_pbfd);
+ size = elf_get_gnu_property_section_size (list, align_size);
+
+ /* Update .note.gnu.property section now. */
+ sec->size = size;
+ contents = (bfd_byte *) bfd_zalloc (first_pbfd, size);
+
elf_write_gnu_properties (info, first_pbfd, contents, list, size,
align_size);
--- /dev/null
+#source: pr33292.s
+#as: --x32 -mx86-used-note=yes
+#ld: -shared -m elf32_x86_64 -z noindirect-extern-access
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ ]+Owner[ ]+Data size[ ]+Description
+ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature used: x86
+ x86 ISA used: x86-64-baseline
--- /dev/null
+#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes
+#ld: -shared -m elf_x86_64 -z noindirect-extern-access
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ ]+Owner[ ]+Data size[ ]+Description
+ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature used: x86
+ x86 ISA used: x86-64-baseline
--- /dev/null
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length */
+ .long 5f - 2f /* data length */
+ .long 5 /* note type */
+0: .asciz "GNU" /* vendor name */
+1:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+2: .long 0xb0008000 /* pr_type. */
+ .long 4f - 3f /* pr_datasz. */
+3:
+ .long 0x1
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
+
+ .text
+ .globl foo
+ .type foo, @function
+foo:
+ ret
+ .section .note.GNU-stack