diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2018-08-11 06:41:33 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2018-08-11 06:41:33 -0700 |
commit | ab9e342807d132182892de1be1a92d6e91a5c1da (patch) | |
tree | d32c6022a8a8bc94e13c72470e6ddaacd6aced8c /bfd | |
parent | 1dc9e2d63e37839ff1768346b2e3f52e338baba5 (diff) | |
download | gdb-ab9e342807d132182892de1be1a92d6e91a5c1da.zip gdb-ab9e342807d132182892de1be1a92d6e91a5c1da.tar.gz gdb-ab9e342807d132182892de1be1a92d6e91a5c1da.tar.bz2 |
x86: Properly add X86_ISA_1_NEEDED property
Existing properties may be removed during property merging. We avoid
adding X86_ISA_1_NEEDED property only if existing properties won't be
removed.
bfd/
PR ld/23428
* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Don't
add X86_ISA_1_NEEDED property only if existing properties won't
be removed.
ld/
PR ld/23428
* testsuite/ld-elf/dummy.s: New file.
* testsuite/ld-elf/linux-x86.S: Add X86_FEATURE_1_AND property.
* testsuite/ld-elf/linux-x86.exp: Add dummy.s to pr23428.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elfxx-x86.c | 28 |
2 files changed, 29 insertions, 6 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8c2c6cc..8d8f0a6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2018-08-11 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/23428 + * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Don't + add X86_ISA_1_NEEDED property only if existing properties won't + be removed. + 2018-08-11 Alan Modra <amodra@gmail.com> * reloc.c (bfd_get_reloc_size): Sort switch. diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index 7ccfd25..2d8f7b6 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -2588,7 +2588,6 @@ _bfd_x86_elf_link_setup_gnu_properties prop->pr_kind = property_number; } else if (has_text - && elf_properties (ebfd) == NULL && elf_tdata (info->output_bfd)->o->build_id.sec == NULL && !htab->elf.dynamic_sections_created && !info->traditional_format @@ -2598,11 +2597,28 @@ _bfd_x86_elf_link_setup_gnu_properties /* If the separate code program header is needed, make sure that the first read-only PT_LOAD segment has no code by adding a GNU_PROPERTY_X86_ISA_1_NEEDED note. */ - prop = _bfd_elf_get_property (ebfd, - GNU_PROPERTY_X86_ISA_1_NEEDED, - 4); - prop->u.number = GNU_PROPERTY_X86_ISA_1_486; - prop->pr_kind = property_number; + elf_property_list *list; + bfd_boolean need_property = TRUE; + + for (list = elf_properties (ebfd); list; list = list->next) + switch (list->property.pr_type) + { + case GNU_PROPERTY_STACK_SIZE: + case GNU_PROPERTY_NO_COPY_ON_PROTECTED: + case GNU_PROPERTY_X86_ISA_1_NEEDED: + /* These properties won't be removed during merging. */ + need_property = FALSE; + break; + } + + if (need_property) + { + prop = _bfd_elf_get_property (ebfd, + GNU_PROPERTY_X86_ISA_1_NEEDED, + 4); + prop->u.number = GNU_PROPERTY_X86_ISA_1_486; + prop->pr_kind = property_number; + } } /* Create the GNU property note section if needed. */ |