This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] x86: Properly merge GNU_PROPERTY_X86_FEATURE_1_[IBT|SHSTK]
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: binutils at sourceware dot org
- Date: Wed, 13 Mar 2019 11:03:11 +0800
- Subject: [PATCH] x86: Properly merge GNU_PROPERTY_X86_FEATURE_1_[IBT|SHSTK]
Properly merge GNU_PROPERTY_X86_FEATURE_1_IBT and
GNU_PROPERTY_X86_FEATURE_1_SHSTK from -z ibt and -z shstk.
bfd/
PR ld/24322
* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Properly
merge GNU_PROPERTY_X86_FEATURE_1_[IBT|SHSTK].
ld/
PR ld/24322
* testsuite/ld-i386/i386.exp: Run PR ld/24322 test.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr24322.d: New file.
* testsuite/ld-x86-64/pr24322-x32.d: Likewise.
* testsuite/ld-x86-64/pr24322.d: Likewise.
* testsuite/ld-x86-64/pr24322a.s: Likewise.
* testsuite/ld-x86-64/pr24322b.s: Likewise.
---
bfd/elfxx-x86.c | 4 ++--
ld/testsuite/ld-i386/i386.exp | 1 +
ld/testsuite/ld-i386/pr24322.d | 13 +++++++++++++
ld/testsuite/ld-x86-64/pr24322-x32.d | 13 +++++++++++++
ld/testsuite/ld-x86-64/pr24322.d | 13 +++++++++++++
ld/testsuite/ld-x86-64/pr24322a.s | 27 +++++++++++++++++++++++++++
ld/testsuite/ld-x86-64/pr24322b.s | 4 ++++
ld/testsuite/ld-x86-64/x86-64.exp | 2 ++
8 files changed, 75 insertions(+), 2 deletions(-)
create mode 100644 ld/testsuite/ld-i386/pr24322.d
create mode 100644 ld/testsuite/ld-x86-64/pr24322-x32.d
create mode 100644 ld/testsuite/ld-x86-64/pr24322.d
create mode 100644 ld/testsuite/ld-x86-64/pr24322a.s
create mode 100644 ld/testsuite/ld-x86-64/pr24322b.s
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index d6b851ce78..ecffffc95d 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -2508,12 +2508,12 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
if (aprop != NULL)
{
number = aprop->u.number;
- aprop->u.number = number | features;
+ aprop->u.number = number & features;
updated = number != (unsigned int) aprop->u.number;
}
else
{
- bprop->u.number |= features;
+ bprop->u.number &= features;
updated = TRUE;
}
}
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index e51a4c30f6..dbe11b37f4 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -483,6 +483,7 @@ run_dump_test "pr23486c"
run_dump_test "pr23486d"
run_dump_test "pr23854"
run_dump_test "pr23930"
+run_dump_test "pr24322"
if { !([istarget "i?86-*-linux*"]
|| [istarget "i?86-*-gnu*"]
diff --git a/ld/testsuite/ld-i386/pr24322.d b/ld/testsuite/ld-i386/pr24322.d
new file mode 100644
index 0000000000..4506608f1d
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr24322.d
@@ -0,0 +1,13 @@
+#source: ../ld-x86-64/pr24322a.s
+#source: ../ld-x86-64/pr24322b.s
+#source: ../ld-x86-64/pr24322a.s
+#as: --32 -mx86-used-note=yes
+#ld: -z shstk -m elf_i386
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000024 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
+ x86 ISA used: <None>
+ x86 feature used: x86
diff --git a/ld/testsuite/ld-x86-64/pr24322-x32.d b/ld/testsuite/ld-x86-64/pr24322-x32.d
new file mode 100644
index 0000000000..d3fa16686e
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr24322-x32.d
@@ -0,0 +1,13 @@
+#source: pr24322a.s
+#source: pr24322b.s
+#source: pr24322a.s
+#as: --x32 -mx86-used-note=yes
+#ld: -z shstk -m elf32_x86_64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000024 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
+ x86 ISA used: <None>
+ x86 feature used: x86
diff --git a/ld/testsuite/ld-x86-64/pr24322.d b/ld/testsuite/ld-x86-64/pr24322.d
new file mode 100644
index 0000000000..b7716738a9
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr24322.d
@@ -0,0 +1,13 @@
+#source: pr24322a.s
+#source: pr24322b.s
+#source: pr24322a.s
+#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes
+#ld: -z shstk -melf_x86_64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000030 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
+ x86 ISA used: <None>
+ x86 feature used: x86
diff --git a/ld/testsuite/ld-x86-64/pr24322a.s b/ld/testsuite/ld-x86-64/pr24322a.s
new file mode 100644
index 0000000000..15989d6901
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr24322a.s
@@ -0,0 +1,27 @@
+ .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 0xc0000002 /* pr_type. */
+ .long 4f - 3f /* pr_datasz. */
+3:
+ .long 0x3
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
diff --git a/ld/testsuite/ld-x86-64/pr24322b.s b/ld/testsuite/ld-x86-64/pr24322b.s
new file mode 100644
index 0000000000..36812352a6
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr24322b.s
@@ -0,0 +1,4 @@
+ .text
+ .global _start
+_start:
+ ret
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index b03aaced91..8305ca509e 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -426,6 +426,8 @@ run_dump_test "pr23930"
run_dump_test "pr23930-x32"
run_dump_test "pr24151a"
run_dump_test "pr24151a-x32"
+run_dump_test "pr24322"
+run_dump_test "pr24322-x32"
if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
return
--
2.20.1