Discussion:
[PATCH] x86: Don't mask out the GNU_PROPERTY_X86_UINT32_VALID bit
H.J. Lu
2018-08-27 22:46:17 UTC
Permalink
Since only the GNU_PROPERTY_X86_UINT32_VALID bit may be set in data-only
relocatable objects which don't contain any instructions, linker
shouldn't mask out the GNU_PROPERTY_X86_UINT32_VALID bit when merging
GNU_PROPERTY_X86_XXX bits. Otherwise, linker output doesn't contain
GNU_PROPERTY_X86_XXX property with any data-only relocatable inputs.
This patch keeps the GNU_PROPERTY_X86_UINT32_VALID bit and updates
readelf to print "<None>" if GNU_PROPERTY_X86_XXX property only has
the GNU_PROPERTY_X86_UINT32_VALID bit.

bfd/

* elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Don't mask
out the GNU_PROPERTY_X86_UINT32_VALID bit.

binutils/

* readelf.c (decode_x86_isa): Print <None> if bitmask only
contains the GNU_PROPERTY_X86_UINT32_VALID bit.
(decode_x86_feature_1): Likewise.
(decode_x86_feature_2): Likewise.
(print_gnu_property_note): Don't mask out the
GNU_PROPERTY_X86_UINT32_VALID bit.
* testsuite/binutils-all/i386/pr21231b.d: Updated.
* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.

gas/

* testsuite/gas/i386/i386.exp: Run property-1 and
x86-64-property-1.
* testsuite/gas/i386/property-1.d: New file.
* testsuite/gas/i386/property-1.s: Likewise.
* testsuite/gas/i386/x86-64-property-1.d: Likewise.

ld/

* testsuite/ld-i386/i386.exp: Run property-x86-5.
* testsuite/ld-i386/property-x86-5.d: New file.
* testsuite/ld-x86-64/property-x86-5-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-5.d: Likewise.
* testsuite/ld-x86-64/property-x86-5a.s: Likewise.
* testsuite/ld-x86-64/property-x86-5b.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run property-x86-5 and
property-x86-5-x32.
---
bfd/ChangeLog | 5 ++
bfd/elfxx-x86.c | 5 +-
binutils/ChangeLog | 11 ++++
binutils/readelf.c | 36 ++++++++++---
.../testsuite/binutils-all/i386/pr21231b.d | 2 +-
.../testsuite/binutils-all/x86-64/pr21231b.d | 2 +-
gas/ChangeLog | 8 +++
gas/testsuite/gas/i386/i386.exp | 2 +
gas/testsuite/gas/i386/property-1.d | 7 +++
gas/testsuite/gas/i386/property-1.s | 31 +++++++++++
gas/testsuite/gas/i386/x86-64-property-1.d | 9 ++++
ld/ChangeLog | 11 ++++
ld/testsuite/ld-i386/i386.exp | 1 +
ld/testsuite/ld-i386/property-x86-5.d | 11 ++++
ld/testsuite/ld-x86-64/property-x86-5-x32.d | 11 ++++
ld/testsuite/ld-x86-64/property-x86-5.d | 11 ++++
ld/testsuite/ld-x86-64/property-x86-5a.s | 52 +++++++++++++++++++
ld/testsuite/ld-x86-64/property-x86-5b.s | 31 +++++++++++
ld/testsuite/ld-x86-64/x86-64.exp | 2 +
19 files changed, 234 insertions(+), 14 deletions(-)
create mode 100644 gas/testsuite/gas/i386/property-1.d
create mode 100644 gas/testsuite/gas/i386/property-1.s
create mode 100644 gas/testsuite/gas/i386/x86-64-property-1.d
create mode 100644 ld/testsuite/ld-i386/property-x86-5.d
create mode 100644 ld/testsuite/ld-x86-64/property-x86-5-x32.d
create mode 100644 ld/testsuite/ld-x86-64/property-x86-5.d
create mode 100644 ld/testsuite/ld-x86-64/property-x86-5a.s
create mode 100644 ld/testsuite/ld-x86-64/property-x86-5b.s

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 3af19d5cb0..b6e93633c5 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2018-08-27 H.J. Lu <***@intel.com>
+
+ * elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Don't mask
+ out the GNU_PROPERTY_X86_UINT32_VALID bit.
+
2018-08-25 H.J. Lu <***@intel.com>

PR ld/23499
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index d44ec5ad94..fc99b28c07 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -2378,10 +2378,7 @@ _bfd_x86_elf_parse_gnu_properties (bfd *abfd, unsigned int type,
return property_corrupt;
}
prop = _bfd_elf_get_property (abfd, type, datasz);
- /* Mask out GNU_PROPERTY_X86_UINT32_VALID and combine properties
- of the same type. */
- prop->u.number |= (bfd_h_get_32 (abfd, ptr)
- & ~GNU_PROPERTY_X86_UINT32_VALID);
+ prop->u.number |= bfd_h_get_32 (abfd, ptr);
prop->pr_kind = property_number;
return property_number;
}
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 82d59fbfed..0f6314860c 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,14 @@
+2018-08-27 H.J. Lu <***@intel.com>
+
+ * readelf.c (decode_x86_isa): Print <None> if bitmask only
+ contains the GNU_PROPERTY_X86_UINT32_VALID bit.
+ (decode_x86_feature_1): Likewise.
+ (decode_x86_feature_2): Likewise.
+ (print_gnu_property_note): Don't mask out the
+ GNU_PROPERTY_X86_UINT32_VALID bit.
+ * testsuite/binutils-all/i386/pr21231b.d: Updated.
+ * testsuite/binutils-all/x86-64/pr21231b.d: Likewise.
+
2018-08-27 H.J. Lu <***@intel.com>

* readelf.c (decode_x86_compat_isa): Break multi-statement line.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index d5fef92a7f..d2ee7a3433 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -17031,6 +17031,14 @@ decode_x86_compat_isa (unsigned int bitmask)
static void
decode_x86_isa (unsigned int bitmask)
{
+ if (bitmask == GNU_PROPERTY_X86_UINT32_VALID)
+ {
+ printf (_("<None>"));
+ return;
+ }
+ else
+ bitmask &= ~GNU_PROPERTY_X86_UINT32_VALID;
+
while (bitmask)
{
unsigned int bit = bitmask & (- bitmask);
@@ -17122,6 +17130,14 @@ decode_x86_isa (unsigned int bitmask)
static void
decode_x86_feature_1 (unsigned int bitmask)
{
+ if (bitmask == GNU_PROPERTY_X86_UINT32_VALID)
+ {
+ printf (_("<None>"));
+ return;
+ }
+ else
+ bitmask &= ~GNU_PROPERTY_X86_UINT32_VALID;
+
while (bitmask)
{
unsigned int bit = bitmask & (- bitmask);
@@ -17147,6 +17163,14 @@ decode_x86_feature_1 (unsigned int bitmask)
static void
decode_x86_feature_2 (unsigned int bitmask)
{
+ if (bitmask == GNU_PROPERTY_X86_UINT32_VALID)
+ {
+ printf (_("<None>"));
+ return;
+ }
+ else
+ bitmask &= ~GNU_PROPERTY_X86_UINT32_VALID;
+
while (bitmask)
{
unsigned int bit = bitmask & (- bitmask);
@@ -17243,14 +17267,10 @@ print_gnu_property_note (Filedata * filedata, Elf_Internal_Note * pnote)
if (datasz == 4)
{
bitmask = byte_get (ptr, 4);
- if (filedata->file_header.e_type == ET_EXEC
- || filedata->file_header.e_type == ET_DYN)
- {
- if ((bitmask & GNU_PROPERTY_X86_UINT32_VALID))
- bitmask &= ~GNU_PROPERTY_X86_UINT32_VALID;
- else
- printf ("Invalid ");
- }
+ if ((filedata->file_header.e_type == ET_EXEC
+ || filedata->file_header.e_type == ET_DYN)
+ && !(bitmask & GNU_PROPERTY_X86_UINT32_VALID))
+ printf ("Invalid ");
}
else
bitmask = 0;
diff --git a/binutils/testsuite/binutils-all/i386/pr21231b.d b/binutils/testsuite/binutils-all/i386/pr21231b.d
index 55d878fdb9..3fad846e73 100644
--- a/binutils/testsuite/binutils-all/i386/pr21231b.d
+++ b/binutils/testsuite/binutils-all/i386/pr21231b.d
@@ -8,5 +8,5 @@ Displaying notes found in: .note.gnu.property
GNU 0x0000002c NT_GNU_PROPERTY_TYPE_0
Properties: stack size: 0x800000
no copy on protected
- x86 ISA used: CMOV, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, FMA, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ, AVX512BW, AVX512_4FMAPS, AVX512_4VNNIW, AVX512_BITALG, AVX512_IFMA, AVX512_VBMI, AVX512_VBMI2, AVX512_VNNI, <unknown: 1000000>, <unknown: 2000000>, <unknown: 4000000>, <unknown: 8000000>, <unknown: 10000000>, <unknown: 20000000>, <unknown: 40000000>, <unknown: 80000000>
+ x86 ISA used: CMOV, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, FMA, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ, AVX512BW, AVX512_4FMAPS, AVX512_4VNNIW, AVX512_BITALG, AVX512_IFMA, AVX512_VBMI, AVX512_VBMI2, AVX512_VNNI, <unknown: 1000000>, <unknown: 2000000>, <unknown: 4000000>, <unknown: 8000000>, <unknown: 10000000>, <unknown: 20000000>, <unknown: 40000000>
x86 ISA needed: CMOV, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, FMA, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ
diff --git a/binutils/testsuite/binutils-all/x86-64/pr21231b.d b/binutils/testsuite/binutils-all/x86-64/pr21231b.d
index f433685e69..150a8ca7d4 100644
--- a/binutils/testsuite/binutils-all/x86-64/pr21231b.d
+++ b/binutils/testsuite/binutils-all/x86-64/pr21231b.d
@@ -8,5 +8,5 @@ Displaying notes found in: .note.gnu.property
GNU 0x00000038 NT_GNU_PROPERTY_TYPE_0
Properties: stack size: 0x800000
no copy on protected
- x86 ISA used: CMOV, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, FMA, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ, AVX512BW, AVX512_4FMAPS, AVX512_4VNNIW, AVX512_BITALG, AVX512_IFMA, AVX512_VBMI, AVX512_VBMI2, AVX512_VNNI, <unknown: 1000000>, <unknown: 2000000>, <unknown: 4000000>, <unknown: 8000000>, <unknown: 10000000>, <unknown: 20000000>, <unknown: 40000000>, <unknown: 80000000>
+ x86 ISA used: CMOV, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, FMA, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ, AVX512BW, AVX512_4FMAPS, AVX512_4VNNIW, AVX512_BITALG, AVX512_IFMA, AVX512_VBMI, AVX512_VBMI2, AVX512_VNNI, <unknown: 1000000>, <unknown: 2000000>, <unknown: 4000000>, <unknown: 8000000>, <unknown: 10000000>, <unknown: 20000000>, <unknown: 40000000>
x86 ISA needed: CMOV, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, FMA, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 42523c8a30..ef02ae4095 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,11 @@
+2018-08-27 H.J. Lu <***@intel.com>
+
+ * testsuite/gas/i386/i386.exp: Run property-1 and
+ x86-64-property-1.
+ * testsuite/gas/i386/property-1.d: New file.
+ * testsuite/gas/i386/property-1.s: Likewise.
+ * testsuite/gas/i386/x86-64-property-1.d: Likewise.
+
2018-08-23 Kito Cheng <***@andestech.com>

* config/tc-riscv.c (arg_lookup): Checking
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index aa1a0f298d..088fece0e7 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -535,6 +535,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]]
run_dump_test "nop-6"

run_dump_test "evex-no-scale-32"
+ run_dump_test "property-1"

if { [gas_64_check] } then {
run_dump_test "att-regs"
@@ -1032,6 +1033,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
run_dump_test "x86-64-nop-6"

run_dump_test "evex-no-scale-64"
+ run_dump_test "x86-64-property-1"
}

set ASFLAGS "$old_ASFLAGS"
diff --git a/gas/testsuite/gas/i386/property-1.d b/gas/testsuite/gas/i386/property-1.d
new file mode 100644
index 0000000000..3a4530bc5d
--- /dev/null
+++ b/gas/testsuite/gas/i386/property-1.d
@@ -0,0 +1,7 @@
+#name: i386 property 1
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: <None>
diff --git a/gas/testsuite/gas/i386/property-1.s b/gas/testsuite/gas/i386/property-1.s
new file mode 100644
index 0000000000..8857c11496
--- /dev/null
+++ b/gas/testsuite/gas/i386/property-1.s
@@ -0,0 +1,31 @@
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .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:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ /* GNU_PROPERTY_X86_ISA_1_USED */
+ .long 0xc0010000 /* pr_type. */
+ .long 5f - 4f /* pr_datasz. */
+4:
+ /* GNU_PROPERTY_X86_UINT32_VALID */
+ .long 0x80000000
+5:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+3:
diff --git a/gas/testsuite/gas/i386/x86-64-property-1.d b/gas/testsuite/gas/i386/x86-64-property-1.d
new file mode 100644
index 0000000000..5fc1c858b3
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-property-1.d
@@ -0,0 +1,9 @@
+#name: x86-64 property 1
+#source: property-1.s
+#as: -defsym __64_bit__=1
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: <None>
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 96232df3f3..0cf02abde2 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,14 @@
+2018-08-27 H.J. Lu <***@intel.com>
+
+ * testsuite/ld-i386/i386.exp: Run property-x86-5.
+ * testsuite/ld-i386/property-x86-5.d: New file.
+ * testsuite/ld-x86-64/property-x86-5-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-5.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-5a.s: Likewise.
+ * testsuite/ld-x86-64/property-x86-5b.s: Likewise.
+ * testsuite/ld-x86-64/x86-64.exp: Run property-x86-5 and
+ property-x86-5-x32.
+
2018-08-26 Alan Modra <***@gmail.com>

PR 23571
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index d1aa350f7e..8a5bdf0cfe 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -433,6 +433,7 @@ run_dump_test "pr20515"
run_dump_test "property-x86-3"
run_dump_test "property-x86-4a"
run_dump_test "property-x86-4b"
+run_dump_test "property-x86-5"
run_dump_test "property-x86-ibt1a"
run_dump_test "property-x86-ibt1b"
run_dump_test "property-x86-ibt2"
diff --git a/ld/testsuite/ld-i386/property-x86-5.d b/ld/testsuite/ld-i386/property-x86-5.d
new file mode 100644
index 0000000000..e1b3a5b54f
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-5.d
@@ -0,0 +1,11 @@
+#source: ../ld-x86-64/property-x86-5a.s
+#source: ../ld-x86-64/property-x86-5b.s
+#as: --32
+#ld: -m elf_i386
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA needed: CMOV
+ x86 ISA used: <None>
diff --git a/ld/testsuite/ld-x86-64/property-x86-5-x32.d b/ld/testsuite/ld-x86-64/property-x86-5-x32.d
new file mode 100644
index 0000000000..4a60736cd3
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-5-x32.d
@@ -0,0 +1,11 @@
+#source: property-x86-5a.s
+#source: property-x86-5b.s
+#as: --x32
+#ld: -m elf32_x86_64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA needed: CMOV
+ x86 ISA used: <None>
diff --git a/ld/testsuite/ld-x86-64/property-x86-5.d b/ld/testsuite/ld-x86-64/property-x86-5.d
new file mode 100644
index 0000000000..b7f8cbd88d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-5.d
@@ -0,0 +1,11 @@
+#source: property-x86-5a.s
+#source: property-x86-5b.s
+#as: --64 -defsym __64_bit__=1
+#ld: -m elf_x86_64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA needed: CMOV
+ x86 ISA used: <None>
diff --git a/ld/testsuite/ld-x86-64/property-x86-5a.s b/ld/testsuite/ld-x86-64/property-x86-5a.s
new file mode 100644
index 0000000000..7b5b823e12
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-5a.s
@@ -0,0 +1,52 @@
+ .text
+ .globl _start
+_start:
+ .byte 0
+
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .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:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ /* GNU_PROPERTY_X86_ISA_1_NEEDED */
+ .long 0xc0008000 /* pr_type. */
+ .long 5f - 4f /* pr_datasz. */
+4:
+ .long 0x1
+5:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ /* GNU_PROPERTY_X86_ISA_1_USED */
+ .long 0xc0010000 /* pr_type. */
+ .long 5f - 4f /* pr_datasz. */
+4:
+ /* GNU_PROPERTY_X86_UINT32_VALID */
+ .long 0x80000000
+5:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+3:
diff --git a/ld/testsuite/ld-x86-64/property-x86-5b.s b/ld/testsuite/ld-x86-64/property-x86-5b.s
new file mode 100644
index 0000000000..8857c11496
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-5b.s
@@ -0,0 +1,31 @@
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .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:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ /* GNU_PROPERTY_X86_ISA_1_USED */
+ .long 0xc0010000 /* pr_type. */
+ .long 5f - 4f /* pr_datasz. */
+4:
+ /* GNU_PROPERTY_X86_UINT32_VALID */
+ .long 0x80000000
+5:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+3:
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 41f40e7581..5c1f90c9d3 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -353,6 +353,8 @@ run_dump_test "property-x86-4b"
run_dump_test "property-x86-3-x32"
run_dump_test "property-x86-4a-x32"
run_dump_test "property-x86-4b-x32"
+run_dump_test "property-x86-5"
+run_dump_test "property-x86-5-x32"
run_dump_test "property-x86-ibt1a"
run_dump_test "property-x86-ibt1b"
run_dump_test "property-x86-ibt1a-x32"
--
2.17.1
Loading...