aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2024-06-11 20:55:05 -0700
committerH.J. Lu <hjl.tools@gmail.com>2024-06-14 13:38:19 -0700
commit93548ee191ff95cae0592363b579c6addb0b151d (patch)
treeb8c1a0fdb54efbfe148ee1af30c78c1137adf416 /ld
parent65e513dc95dcad1320c6bee4be1a10ed46f7d2cb (diff)
downloadgdb-93548ee191ff95cae0592363b579c6addb0b151d.zip
gdb-93548ee191ff95cae0592363b579c6addb0b151d.tar.gz
gdb-93548ee191ff95cae0592363b579c6addb0b151d.tar.bz2
x86: Add -z isa-level-report=[none|all|needed|used]
Add -z isa-level-report=[none|all|needed|used] to the x86 ELF linker to report needed and used x86-64 ISA levels. bfd/ PR ld/31868 * elf-linker-x86.h (elf_x86_isa_level_report): New. (elf_linker_x86_params): Add isa_level_report. * elfxx-x86.c (report_isa_level): New. (_bfd_x86_elf_link_setup_gnu_properties): Check -z isa-level-report=[none|all|needed|used] to report needed and used x86-64 ISA level. ld/ PR ld/31868 * NEWS: Mention -z isa-level-report=[none|all|needed|used]. * ld.texi: Document -z isa-level-report=[none|all|needed|used]. * emulparams/elf32_x86_64.sh: Source x86-64-level-report.sh. * emulparams/elf_i386.sh: Likewise. * emulparams/elf_x86_64.sh: Likewise. * emulparams/x86-64-level-report.sh: New file. * testsuite/ld-i386/pr31868a.d: Likewise. * testsuite/ld-i386/pr31868b.d: Likewise. * testsuite/ld-i386/pr31868c.d: Likewise. * testsuite/ld-x86-64/pr31868a-x32.d: Likewise. * testsuite/ld-x86-64/pr31868a.d: Likewise. * testsuite/ld-x86-64/pr31868a.l: Likewise. * testsuite/ld-x86-64/pr31868a.s: Likewise. * testsuite/ld-x86-64/pr31868b-x32.d: Likewise. * testsuite/ld-x86-64/pr31868b.d: Likewise. * testsuite/ld-x86-64/pr31868b.l: Likewise. * testsuite/ld-x86-64/pr31868b.s: Likewise. * testsuite/ld-x86-64/pr31868c-x32.d: Likewise. * testsuite/ld-x86-64/pr31868c.d: Likewise. * testsuite/ld-x86-64/pr31868c.l: Likewise. * testsuite/ld-i386/i386.exp: Run PR ld/31868 tests. * testsuite/ld-x86-64/x86-64.exp: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Diffstat (limited to 'ld')
-rw-r--r--ld/NEWS3
-rw-r--r--ld/emulparams/elf32_x86_64.sh1
-rw-r--r--ld/emulparams/elf_i386.sh1
-rw-r--r--ld/emulparams/elf_x86_64.sh1
-rw-r--r--ld/emulparams/x86-64-level-report.sh25
-rw-r--r--ld/ld.texi15
-rw-r--r--ld/testsuite/ld-i386/i386.exp3
-rw-r--r--ld/testsuite/ld-i386/pr31868a.d12
-rw-r--r--ld/testsuite/ld-i386/pr31868b.d12
-rw-r--r--ld/testsuite/ld-i386/pr31868c.d12
-rw-r--r--ld/testsuite/ld-x86-64/pr31868a-x32.d12
-rw-r--r--ld/testsuite/ld-x86-64/pr31868a.d12
-rw-r--r--ld/testsuite/ld-x86-64/pr31868a.l4
-rw-r--r--ld/testsuite/ld-x86-64/pr31868a.s60
-rw-r--r--ld/testsuite/ld-x86-64/pr31868b-x32.d12
-rw-r--r--ld/testsuite/ld-x86-64/pr31868b.d12
-rw-r--r--ld/testsuite/ld-x86-64/pr31868b.l2
-rw-r--r--ld/testsuite/ld-x86-64/pr31868b.s60
-rw-r--r--ld/testsuite/ld-x86-64/pr31868c-x32.d12
-rw-r--r--ld/testsuite/ld-x86-64/pr31868c.d12
-rw-r--r--ld/testsuite/ld-x86-64/pr31868c.l2
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp6
22 files changed, 291 insertions, 0 deletions
diff --git a/ld/NEWS b/ld/NEWS
index 585ec09..e0b9341 100644
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,5 +1,8 @@
-*- text -*-
+* Add -z isa-level-report=[none|all|needed|used] to the x86 ELF linker
+ to report needed and used x86-64 ISA levels.
+
* Add --rosegment option which changes the -z separate-code option so that
only one read-only segment is created (instead of two). (The option name
is misleading, but it matches the name used by LLD and GOLD).
diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh
index f6c6de9..6a92eec 100644
--- a/ld/emulparams/elf32_x86_64.sh
+++ b/ld/emulparams/elf32_x86_64.sh
@@ -6,6 +6,7 @@ source_sh ${srcdir}/emulparams/call_nop.sh
source_sh ${srcdir}/emulparams/cet.sh
source_sh ${srcdir}/emulparams/x86-report-relative.sh
source_sh ${srcdir}/emulparams/x86-64-level.sh
+source_sh ${srcdir}/emulparams/x86-64-level-report.sh
source_sh ${srcdir}/emulparams/x86-64-plt.sh
source_sh ${srcdir}/emulparams/static.sh
source_sh ${srcdir}/emulparams/dt-relr.sh
diff --git a/ld/emulparams/elf_i386.sh b/ld/emulparams/elf_i386.sh
index 3f12435..6f698bb 100644
--- a/ld/emulparams/elf_i386.sh
+++ b/ld/emulparams/elf_i386.sh
@@ -5,6 +5,7 @@ source_sh ${srcdir}/emulparams/call_nop.sh
source_sh ${srcdir}/emulparams/cet.sh
source_sh ${srcdir}/emulparams/x86-report-relative.sh
source_sh ${srcdir}/emulparams/x86-64-level.sh
+source_sh ${srcdir}/emulparams/x86-64-level-report.sh
source_sh ${srcdir}/emulparams/static.sh
source_sh ${srcdir}/emulparams/dt-relr.sh
SCRIPT_NAME=elf
diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh
index 466da2c..9244974 100644
--- a/ld/emulparams/elf_x86_64.sh
+++ b/ld/emulparams/elf_x86_64.sh
@@ -6,6 +6,7 @@ source_sh ${srcdir}/emulparams/call_nop.sh
source_sh ${srcdir}/emulparams/cet.sh
source_sh ${srcdir}/emulparams/x86-report-relative.sh
source_sh ${srcdir}/emulparams/x86-64-level.sh
+source_sh ${srcdir}/emulparams/x86-64-level-report.sh
source_sh ${srcdir}/emulparams/x86-64-lam.sh
source_sh ${srcdir}/emulparams/x86-64-plt.sh
source_sh ${srcdir}/emulparams/static.sh
diff --git a/ld/emulparams/x86-64-level-report.sh b/ld/emulparams/x86-64-level-report.sh
new file mode 100644
index 0000000..5185277
--- /dev/null
+++ b/ld/emulparams/x86-64-level-report.sh
@@ -0,0 +1,25 @@
+PARSE_AND_LIST_OPTIONS_X86_64_LEVEL_REPORT='
+ fprintf (file, _("\
+ -z isa-level-report=[none|all|needed|used] (default: none)\n\
+ Report x86-64 ISA level\n"));
+'
+PARSE_AND_LIST_ARGS_CASE_Z_X86_64_LEVEL_REPORT='
+ else if (strncmp (optarg, "isa-level-report=", 17) == 0)
+ {
+ if (strcmp (optarg + 17, "none") == 0)
+ params.isa_level_report = isa_level_report_none;
+ else if (strcmp (optarg + 17, "all") == 0)
+ params.isa_level_report = (isa_level_report_needed
+ | isa_level_report_used);
+ else if (strcmp (optarg + 17, "needed") == 0)
+ params.isa_level_report = isa_level_report_needed;
+ else if (strcmp (optarg + 17, "used") == 0)
+ params.isa_level_report = isa_level_report_used;
+ else
+ einfo (_("%F%P: invalid option for -z isa-level-report=: %s\n"),
+ optarg + 17);
+ }
+'
+
+PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_X86_64_LEVEL_REPORT"
+PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_X86_64_LEVEL_REPORT"
diff --git a/ld/ld.texi b/ld/ld.texi
index 9f3fbbd..cc0a37d 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -1683,6 +1683,21 @@ Specify the x86-64 ISA level needed in .note.gnu.property section.
@option{x86-64-v4} generates @code{GNU_PROPERTY_X86_ISA_1_V4}.
Supported for Linux/i386 and Linux/x86_64.
+@item isa-level-report=none
+@itemx isa-level-report=all
+@itemx isa-level-report=needed
+@itemx isa-level-report=used
+Specify how to report x86-64 ISA levels in input relocatable files.
+@option{isa-level-report=none}, which is the default, will make the
+linker not report x86-64 ISA levels in input files.
+@option{isa-level-report=all} will make the linker report needed and
+used x86-64 ISA levels in input files.
+@option{isa-level-report=needed} will make the linker report needed
+x86-64 ISA levels in input files.
+@option{isa-level-report=used} will make the linker report used
+x86-64 ISA levels in input files.
+Supported for Linux/i386 and Linux/x86_64.
+
@end table
Other keywords are ignored for Solaris compatibility.
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 9401988..f96c514 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -541,6 +541,9 @@ run_dump_test "tlsdesc2"
run_dump_test "report-reloc-1"
run_dump_test "pr27998a"
run_dump_test "pr27998b"
+run_dump_test "pr31868a"
+run_dump_test "pr31868b"
+run_dump_test "pr31868c"
proc undefined_weak {cflags ldflags} {
set testname "Undefined weak symbol"
diff --git a/ld/testsuite/ld-i386/pr31868a.d b/ld/testsuite/ld-i386/pr31868a.d
new file mode 100644
index 0000000..070d70f
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr31868a.d
@@ -0,0 +1,12 @@
+#source: ../ld-x86-64/pr31868a.s
+#source: ../ld-x86-64/pr31868b.s
+#as: --32
+#ld: -r -melf_i386 -z isa-level-report=all
+#warning_output:../ld-x86-64/pr31868a.l
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ ]+Owner[ ]+Data size[ ]+Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, <unknown: 10>, <unknown: 20>
+ x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4, <unknown: 10>, <unknown: 40>
diff --git a/ld/testsuite/ld-i386/pr31868b.d b/ld/testsuite/ld-i386/pr31868b.d
new file mode 100644
index 0000000..375c11a
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr31868b.d
@@ -0,0 +1,12 @@
+#source: ../ld-x86-64/pr31868a.s
+#source: ../ld-x86-64/pr31868b.s
+#as: --32
+#ld: -r -melf_i386 -z isa-level-report=needed
+#warning_output:../ld-x86-64/pr31868b.l
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ ]+Owner[ ]+Data size[ ]+Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, <unknown: 10>, <unknown: 20>
+ x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4, <unknown: 10>, <unknown: 40>
diff --git a/ld/testsuite/ld-i386/pr31868c.d b/ld/testsuite/ld-i386/pr31868c.d
new file mode 100644
index 0000000..dc8543a
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr31868c.d
@@ -0,0 +1,12 @@
+#source: ../ld-x86-64/pr31868a.s
+#source: ../ld-x86-64/pr31868b.s
+#as: --32
+#ld: -r -melf_i386 -z isa-level-report=used
+#warning_output:../ld-x86-64/pr31868c.l
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ ]+Owner[ ]+Data size[ ]+Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, <unknown: 10>, <unknown: 20>
+ x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4, <unknown: 10>, <unknown: 40>
diff --git a/ld/testsuite/ld-x86-64/pr31868a-x32.d b/ld/testsuite/ld-x86-64/pr31868a-x32.d
new file mode 100644
index 0000000..90f16ee
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr31868a-x32.d
@@ -0,0 +1,12 @@
+#source: pr31868a.s
+#source: pr31868b.s
+#as: --x32
+#warning_output: pr31868a.l
+#ld: -r -m elf32_x86_64 -z isa-level-report=all
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ ]+Owner[ ]+Data size[ ]+Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, <unknown: 10>, <unknown: 20>
+ x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4, <unknown: 10>, <unknown: 40>
diff --git a/ld/testsuite/ld-x86-64/pr31868a.d b/ld/testsuite/ld-x86-64/pr31868a.d
new file mode 100644
index 0000000..54839bb
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr31868a.d
@@ -0,0 +1,12 @@
+#source: pr31868a.s
+#source: pr31868b.s
+#as: --64 -defsym __64_bit__=1
+#warning_output: pr31868a.l
+#ld: -r -m elf_x86_64 -z isa-level-report=all
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ ]+Owner[ ]+Data size[ ]+Description
+ GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, <unknown: 10>, <unknown: 20>
+ x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4, <unknown: 10>, <unknown: 40>
diff --git a/ld/testsuite/ld-x86-64/pr31868a.l b/ld/testsuite/ld-x86-64/pr31868a.l
new file mode 100644
index 0000000..1244dfd
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr31868a.l
@@ -0,0 +1,4 @@
+tmpdir/pr31868a.o: x86 ISA needed: x86-64-baseline, x86-64-v3, <unknown: 10>, <unknown: 20>
+tmpdir/pr31868a.o: x86 ISA used: x86-64-v3, x86-64-v4, <unknown: 40>
+tmpdir/pr31868b.o: x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3
+tmpdir/pr31868b.o: x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v4, <unknown: 10>
diff --git a/ld/testsuite/ld-x86-64/pr31868a.s b/ld/testsuite/ld-x86-64/pr31868a.s
new file mode 100644
index 0000000..e39405b
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr31868a.s
@@ -0,0 +1,60 @@
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length. */
+ .long 4f - 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 0xc0010002 /* pr_type. */
+ .long 3f - 2f /* pr_datasz. */
+2:
+ .long 0x4c
+3:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+4:
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length. */
+ .long 4f - 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 0xc0008002 /* pr_type. */
+ .long 3f - 2f /* pr_datasz. */
+2:
+ .long 0x35
+3:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+4:
diff --git a/ld/testsuite/ld-x86-64/pr31868b-x32.d b/ld/testsuite/ld-x86-64/pr31868b-x32.d
new file mode 100644
index 0000000..d88efce
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr31868b-x32.d
@@ -0,0 +1,12 @@
+#source: pr31868a.s
+#source: pr31868b.s
+#as: --x32
+#warning_output: pr31868b.l
+#ld: -r -m elf32_x86_64 -z isa-level-report=needed
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ ]+Owner[ ]+Data size[ ]+Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, <unknown: 10>, <unknown: 20>
+ x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4, <unknown: 10>, <unknown: 40>
diff --git a/ld/testsuite/ld-x86-64/pr31868b.d b/ld/testsuite/ld-x86-64/pr31868b.d
new file mode 100644
index 0000000..6ead70e
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr31868b.d
@@ -0,0 +1,12 @@
+#source: pr31868a.s
+#source: pr31868b.s
+#as: --64 -defsym __64_bit__=1
+#warning_output: pr31868b.l
+#ld: -r -m elf_x86_64 -z isa-level-report=needed
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ ]+Owner[ ]+Data size[ ]+Description
+ GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, <unknown: 10>, <unknown: 20>
+ x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4, <unknown: 10>, <unknown: 40>
diff --git a/ld/testsuite/ld-x86-64/pr31868b.l b/ld/testsuite/ld-x86-64/pr31868b.l
new file mode 100644
index 0000000..1380bef
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr31868b.l
@@ -0,0 +1,2 @@
+tmpdir/pr31868a.o: x86 ISA needed: x86-64-baseline, x86-64-v3, <unknown: 10>, <unknown: 20>
+tmpdir/pr31868b.o: x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3
diff --git a/ld/testsuite/ld-x86-64/pr31868b.s b/ld/testsuite/ld-x86-64/pr31868b.s
new file mode 100644
index 0000000..afa529e
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr31868b.s
@@ -0,0 +1,60 @@
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length. */
+ .long 4f - 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 0xc0008002 /* pr_type. */
+ .long 3f - 2f /* pr_datasz. */
+2:
+ .long 0x7
+3:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+4:
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length. */
+ .long 4f - 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 0xc0010002 /* pr_type. */
+ .long 3f - 2f /* pr_datasz. */
+2:
+ .long 0x1b
+3:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+4:
diff --git a/ld/testsuite/ld-x86-64/pr31868c-x32.d b/ld/testsuite/ld-x86-64/pr31868c-x32.d
new file mode 100644
index 0000000..a38afd5
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr31868c-x32.d
@@ -0,0 +1,12 @@
+#source: pr31868a.s
+#source: pr31868b.s
+#as: --x32
+#warning_output: pr31868c.l
+#ld: -r -m elf32_x86_64 -z isa-level-report=used
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ ]+Owner[ ]+Data size[ ]+Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, <unknown: 10>, <unknown: 20>
+ x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4, <unknown: 10>, <unknown: 40>
diff --git a/ld/testsuite/ld-x86-64/pr31868c.d b/ld/testsuite/ld-x86-64/pr31868c.d
new file mode 100644
index 0000000..3e6a65d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr31868c.d
@@ -0,0 +1,12 @@
+#source: pr31868a.s
+#source: pr31868b.s
+#as: --64 -defsym __64_bit__=1
+#warning_output: pr31868c.l
+#ld: -r -m elf_x86_64 -z isa-level-report=used
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+[ ]+Owner[ ]+Data size[ ]+Description
+ GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA needed: x86-64-baseline, x86-64-v2, x86-64-v3, <unknown: 10>, <unknown: 20>
+ x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v3, x86-64-v4, <unknown: 10>, <unknown: 40>
diff --git a/ld/testsuite/ld-x86-64/pr31868c.l b/ld/testsuite/ld-x86-64/pr31868c.l
new file mode 100644
index 0000000..7de0be6
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr31868c.l
@@ -0,0 +1,2 @@
+tmpdir/pr31868a.o: x86 ISA used: x86-64-v3, x86-64-v4, <unknown: 40>
+tmpdir/pr31868b.o: x86 ISA used: x86-64-baseline, x86-64-v2, x86-64-v4, <unknown: 10>
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 6546fff..dddac43 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -531,6 +531,12 @@ run_dump_test "dt-relr-1b-x32"
run_dump_test "pr30787"
run_dump_test "pr31047"
run_dump_test "pr31047-x32"
+run_dump_test "pr31868a"
+run_dump_test "pr31868a-x32"
+run_dump_test "pr31868b"
+run_dump_test "pr31868b-x32"
+run_dump_test "pr31868c"
+run_dump_test "pr31868c-x32"
if { ![skip_sframe_tests] } {
run_dump_test "sframe-simple-1"