From 73caa85d4a97eb991e581ccba3ff4eccce5e2e1d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 12 May 2017 08:07:21 -0700 Subject: [PATCH] x86: Merge X86_ISA_1_USED/X86_ISA_1_NEEDED properties If there are more than GNU property note in an input, we should merge X86_ISA_1_USED and X86_ISA_1_NEEDED properties. bfd/ * elf32-i386.c (elf_i386_parse_gnu_properties): Merge GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED properties. * elf64-x86-64.c (elf_x86_64_parse_gnu_properties): Likewise. ld/ * testsuite/ld-i386/i386.exp: Run property-x86-3. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/property-x86-3.d: New file. * testsuite/ld-i386/property-x86-3.s: Likewise. * testsuite/ld-x86-64/property-x86-3.d: Likewise. * testsuite/ld-x86-64/property-x86-3.s: Likewise. --- bfd/ChangeLog | 7 ++++ bfd/elf32-i386.c | 3 +- bfd/elf64-x86-64.c | 3 +- ld/ChangeLog | 9 +++++ ld/testsuite/ld-i386/i386.exp | 1 + ld/testsuite/ld-i386/property-x86-3.d | 9 +++++ ld/testsuite/ld-i386/property-x86-3.s | 51 +++++++++++++++++++++++++ ld/testsuite/ld-x86-64/property-x86-3.d | 9 +++++ ld/testsuite/ld-x86-64/property-x86-3.s | 51 +++++++++++++++++++++++++ ld/testsuite/ld-x86-64/x86-64.exp | 1 + 10 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 ld/testsuite/ld-i386/property-x86-3.d create mode 100644 ld/testsuite/ld-i386/property-x86-3.s create mode 100644 ld/testsuite/ld-x86-64/property-x86-3.d create mode 100644 ld/testsuite/ld-x86-64/property-x86-3.s diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9128808e57..bd7356cc6a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2017-05-12 H.J. Lu + + * elf32-i386.c (elf_i386_parse_gnu_properties): Merge + GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED + properties. + * elf64-x86-64.c (elf_x86_64_parse_gnu_properties): Likewise. + 2017-05-11 H.J. Lu * elf64-x86-64.c (elf_x86_64_link_hash_entry): Rename plt_bnd diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 6f59fb75d6..513e296840 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -6362,7 +6362,8 @@ elf_i386_parse_gnu_properties (bfd *abfd, unsigned int type, return property_corrupt; } prop = _bfd_elf_get_property (abfd, type, datasz); - prop->u.number = bfd_h_get_32 (abfd, ptr); + /* Combine properties of the same type. */ + prop->u.number |= bfd_h_get_32 (abfd, ptr); prop->pr_kind = property_number; break; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index c77725dd80..1b9337944e 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -7003,7 +7003,8 @@ elf_x86_64_parse_gnu_properties (bfd *abfd, unsigned int type, return property_corrupt; } prop = _bfd_elf_get_property (abfd, type, datasz); - prop->u.number = bfd_h_get_32 (abfd, ptr); + /* Combine properties of the same type. */ + prop->u.number |= bfd_h_get_32 (abfd, ptr); prop->pr_kind = property_number; break; diff --git a/ld/ChangeLog b/ld/ChangeLog index 92ebbf7f0a..7e22adfc2e 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,12 @@ +2017-05-12 H.J. Lu + + * testsuite/ld-i386/i386.exp: Run property-x86-3. + * testsuite/ld-x86-64/x86-64.exp: Likewise. + * testsuite/ld-i386/property-x86-3.d: New file. + * testsuite/ld-i386/property-x86-3.s: Likewise. + * testsuite/ld-x86-64/property-x86-3.d: Likewise. + * testsuite/ld-x86-64/property-x86-3.s: Likewise. + 2017-05-11 H.J. Lu * emulparams/elf_x86_64.sh (TINY_READONLY_SECTION): Replace diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index 5cb741f2d8..0118f245c4 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -417,6 +417,7 @@ run_dump_test "pr20253-4b" run_dump_test "pr20253-4c" run_dump_test "pr20253-5" run_dump_test "pr20515" +run_dump_test "property-x86-3" if { !([istarget "i?86-*-linux*"] || [istarget "i?86-*-gnu*"] diff --git a/ld/testsuite/ld-i386/property-x86-3.d b/ld/testsuite/ld-i386/property-x86-3.d new file mode 100644 index 0000000000..19c6699716 --- /dev/null +++ b/ld/testsuite/ld-i386/property-x86-3.d @@ -0,0 +1,9 @@ +#as: --32 +#ld: -shared -m elf_i386 +#readelf: -n + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 + Properties: x86 ISA used: i486, 586, SSE2, SSE3 + x86 ISA needed: 586, SSE, SSE3, SSE4_1 diff --git a/ld/testsuite/ld-i386/property-x86-3.s b/ld/testsuite/ld-i386/property-x86-3.s new file mode 100644 index 0000000000..a6fd830977 --- /dev/null +++ b/ld/testsuite/ld-i386/property-x86-3.s @@ -0,0 +1,51 @@ + .section ".note.gnu.property", "a" + .p2align 2 + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align 2 + /* GNU_PROPERTY_X86_ISA_1_USED */ + .long 0xc0000000 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0x3 +5: + .p2align 2 + /* GNU_PROPERTY_X86_ISA_1_NEEDED */ + .long 0xc0000001 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0xa +5: + .p2align 2 +3: + + .section ".note.gnu.property", "a" + .p2align 2 + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align 2 + /* GNU_PROPERTY_X86_ISA_1_USED */ + .long 0xc0000000 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0x30 +5: + .p2align 2 + /* GNU_PROPERTY_X86_ISA_1_NEEDED */ + .long 0xc0000001 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0xa0 +5: + .p2align 2 +3: diff --git a/ld/testsuite/ld-x86-64/property-x86-3.d b/ld/testsuite/ld-x86-64/property-x86-3.d new file mode 100644 index 0000000000..1e0348c8ab --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-3.d @@ -0,0 +1,9 @@ +#as: --64 +#ld: -shared -m elf_x86_64 +#readelf: -n + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 + Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 + x86 ISA needed: i486, 586, SSE2, SSE3 diff --git a/ld/testsuite/ld-x86-64/property-x86-3.s b/ld/testsuite/ld-x86-64/property-x86-3.s new file mode 100644 index 0000000000..e87ac81770 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-3.s @@ -0,0 +1,51 @@ + .section ".note.gnu.property", "a" + .p2align 3 + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align 3 + /* GNU_PROPERTY_X86_ISA_1_USED */ + .long 0xc0000000 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0xa +5: + .p2align 3 + /* GNU_PROPERTY_X86_ISA_1_NEEDED */ + .long 0xc0000001 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0x3 +5: + .p2align 3 +3: + + .section ".note.gnu.property", "a" + .p2align 3 + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align 3 + /* GNU_PROPERTY_X86_ISA_1_USED */ + .long 0xc0000000 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0xa0 +5: + .p2align 3 + /* GNU_PROPERTY_X86_ISA_1_NEEDED */ + .long 0xc0000001 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0x30 +5: + .p2align 3 +3: diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 61032aa30a..05125df6b2 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -329,6 +329,7 @@ run_dump_test "pr19807-2e" run_dump_test "pr19969" run_dump_test "pr20093-1" run_dump_test "pr20093-2" +run_dump_test "property-x86-3" if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} { return -- 2.34.1