summaryrefslogtreecommitdiff
path: root/bfd/elf-properties.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-11-20 15:32:55 +0000
committerNick Clifton <nickc@redhat.com>2017-11-20 15:32:55 +0000
commitb77db948f4175e479bb3310ba86346c9554ab9f5 (patch)
tree634d70cd1221d48fa76e2f56c0c6836022e72c2c /bfd/elf-properties.c
parentb7486a74a62527412cfd2dd50a9a100118265c28 (diff)
downloadbinutils-gdb-b77db948f4175e479bb3310ba86346c9554ab9f5.tar.gz
Fix handling of GNU Property notes that are not in a GNU NOTE PROPERTY section.
PR 22450 gas * elf-properties.c (_bfd_elf_link_setup_gnu_properties): Skip objects without a GNU_PROPERTY note section when looking for a bfd onto which notes can be accumulated. ld * testsuite/ld-elf/elf.exp: Add --defsym ALIGN=2|3 to assembler command line depending upon the size of the target address space. * testsuite/ld-elf/pr22450.s: New test file. * testsuite/ld-elf/pr22450.d: New test driver. * testsuite/config/default.exp: Add note that LD_CLASS refers to the size of the host linker not the size of the target linker.
Diffstat (limited to 'bfd/elf-properties.c')
-rw-r--r--bfd/elf-properties.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/bfd/elf-properties.c b/bfd/elf-properties.c
index bfb106edc92..32e03dee37e 100644
--- a/bfd/elf-properties.c
+++ b/bfd/elf-properties.c
@@ -328,11 +328,15 @@ _bfd_elf_link_setup_gnu_properties (struct bfd_link_info *info)
has_properties = TRUE;
/* Ignore GNU properties from ELF objects with different machine
- code or class. */
+ code or class. Also skip objects without a GNU_PROPERTY note
+ section. */
if ((elf_machine_code
== get_elf_backend_data (abfd)->elf_machine_code)
&& (elfclass
- == get_elf_backend_data (abfd)->s->elfclass))
+ == get_elf_backend_data (abfd)->s->elfclass)
+ && bfd_get_section_by_name (abfd,
+ NOTE_GNU_PROPERTY_SECTION_NAME) != NULL
+ )
{
/* Keep .note.gnu.property section in FIRST_PBFD. */
first_pbfd = abfd;
@@ -374,10 +378,11 @@ _bfd_elf_link_setup_gnu_properties (struct bfd_link_info *info)
if (list != NULL)
{
- /* Discard .note.gnu.property section in the rest inputs. */
+ /* Discard the .note.gnu.property section in this bfd. */
sec = bfd_get_section_by_name (abfd,
NOTE_GNU_PROPERTY_SECTION_NAME);
- sec->output_section = bfd_abs_section_ptr;
+ if (sec != NULL)
+ sec->output_section = bfd_abs_section_ptr;
}
}
@@ -393,6 +398,7 @@ _bfd_elf_link_setup_gnu_properties (struct bfd_link_info *info)
sec = bfd_get_section_by_name (first_pbfd,
NOTE_GNU_PROPERTY_SECTION_NAME);
+ BFD_ASSERT (sec != NULL);
/* Update stack size in .note.gnu.property with -z stack-size=N
if N > 0. */