diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2018-08-08 06:09:15 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2018-08-08 06:09:28 -0700 |
commit | f7309df20c4e787041cedc4a6aced89c15259e54 (patch) | |
tree | ecb88f279679414d47357a767902758458acdc40 /bfd/elfxx-x86.c | |
parent | 9d4a934ce604afea155c39f06834cdbc47e92a6e (diff) | |
download | gdb-f7309df20c4e787041cedc4a6aced89c15259e54.zip gdb-f7309df20c4e787041cedc4a6aced89c15259e54.tar.gz gdb-f7309df20c4e787041cedc4a6aced89c15259e54.tar.bz2 |
x86: Properly merge GNU_PROPERTY_X86_ISA_1_USED
Without the GNU_PROPERTY_X86_ISA_1_USED property, all ISAs may be used.
If a bit in the GNU_PROPERTY_X86_ISA_1_USED property is unset, the
corresponding x86 instruction set isn’t used. When merging properties
from 2 input files and one input file doesn't have the
GNU_PROPERTY_X86_ISA_1_USED property, the output file shouldn't have
it neither. This patch removes the GNU_PROPERTY_X86_ISA_1_USED
property if an input file doesn't have it.
This patch replaces the GNU_PROPERTY_X86_ISA_1_USED property with the
GNU_PROPERTY_X86_ISA_1_NEEDED property which is the minimum ISA
requirement.
bfd/
PR ld/23486
* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Remove
GNU_PROPERTY_X86_ISA_1_USED if an input file doesn't have it.
(_bfd_x86_elf_link_setup_gnu_properties): Adding the
GNU_PROPERTY_X86_ISA_1_NEEDED, instead of
GNU_PROPERTY_X86_ISA_1_USED, property.
ld/
PR ld/23486
* testsuite/ld-i386/i386.exp: Run PR ld/23486 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr23486a.d: New file.
* testsuite/ld-i386/pr23486b.d: Likewise.
* testsuite/ld-x86-64/pr23486a-x32.d: Likewise.
* testsuite/ld-x86-64/pr23486a.d: Likewise.
* testsuite/ld-x86-64/pr23486a.s: Likewise.
* testsuite/ld-x86-64/pr23486b-x32.d: Likewise.
* testsuite/ld-x86-64/pr23486b.d: Likewise.
* testsuite/ld-x86-64/pr23486b.s: Likewise.
* testsuite/ld-i386/property-3.r: Remove "x86 ISA used".
* testsuite/ld-i386/property-4.r: Likewise.
* testsuite/ld-i386/property-5.r: Likewise.
* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
* testsuite/ld-x86-64/property-3.r: Likewise.
* testsuite/ld-x86-64/property-4.r: Likewise.
* testsuite/ld-x86-64/property-5.r: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
Diffstat (limited to 'bfd/elfxx-x86.c')
-rw-r--r-- | bfd/elfxx-x86.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index 2e4ff88..7ccfd25 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -2407,12 +2407,27 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info, switch (pr_type) { case GNU_PROPERTY_X86_ISA_1_USED: + if (aprop == NULL || bprop == NULL) + { + /* Only one of APROP and BPROP can be NULL. */ + if (aprop != NULL) + { + /* Remove this property since the other input file doesn't + have it. */ + aprop->pr_kind = property_remove; + updated = TRUE; + } + break; + } + goto or_property; + case GNU_PROPERTY_X86_ISA_1_NEEDED: if (aprop != NULL && bprop != NULL) { +or_property: number = aprop->u.number; aprop->u.number = number | bprop->u.number; - /* Remove the property if ISA bits are empty. */ + /* Remove the property if all bits are empty. */ if (aprop->u.number == 0) { aprop->pr_kind = property_remove; @@ -2428,14 +2443,14 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info, { if (aprop->u.number == 0) { - /* Remove APROP if ISA bits are empty. */ + /* Remove APROP if all bits are empty. */ aprop->pr_kind = property_remove; updated = TRUE; } } else { - /* Return TRUE if APROP is NULL and ISA bits of BPROP + /* Return TRUE if APROP is NULL and all bits of BPROP aren't empty to indicate that BPROP should be added to ABFD. */ updated = bprop->u.number != 0; @@ -2582,9 +2597,9 @@ _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_USED note. */ + adding a GNU_PROPERTY_X86_ISA_1_NEEDED note. */ prop = _bfd_elf_get_property (ebfd, - GNU_PROPERTY_X86_ISA_1_USED, + GNU_PROPERTY_X86_ISA_1_NEEDED, 4); prop->u.number = GNU_PROPERTY_X86_ISA_1_486; prop->pr_kind = property_number; |