[PATCH] x86: Add -z isa-level-report=[none|all|needed|used]
H.J. Lu
hjl.tools@gmail.com
Thu Jun 13 11:57:14 GMT 2024
If there are no objections, I will check it in next week.
On Wed, Jun 12, 2024, 12:02 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> 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>
> ---
> bfd/elf-linker-x86.h | 11 +++
> bfd/elfxx-x86.c | 123 +++++++++++++++++++++++---
> ld/NEWS | 3 +
> ld/emulparams/elf32_x86_64.sh | 1 +
> ld/emulparams/elf_i386.sh | 1 +
> ld/emulparams/elf_x86_64.sh | 1 +
> ld/emulparams/x86-64-level-report.sh | 25 ++++++
> ld/ld.texi | 15 ++++
> ld/testsuite/ld-i386/i386.exp | 3 +
> ld/testsuite/ld-i386/pr31868a.d | 12 +++
> ld/testsuite/ld-i386/pr31868b.d | 12 +++
> ld/testsuite/ld-i386/pr31868c.d | 12 +++
> ld/testsuite/ld-x86-64/pr31868a-x32.d | 12 +++
> ld/testsuite/ld-x86-64/pr31868a.d | 12 +++
> ld/testsuite/ld-x86-64/pr31868a.l | 4 +
> ld/testsuite/ld-x86-64/pr31868a.s | 60 +++++++++++++
> ld/testsuite/ld-x86-64/pr31868b-x32.d | 12 +++
> ld/testsuite/ld-x86-64/pr31868b.d | 12 +++
> ld/testsuite/ld-x86-64/pr31868b.l | 2 +
> ld/testsuite/ld-x86-64/pr31868b.s | 60 +++++++++++++
> ld/testsuite/ld-x86-64/pr31868c-x32.d | 12 +++
> ld/testsuite/ld-x86-64/pr31868c.d | 12 +++
> ld/testsuite/ld-x86-64/pr31868c.l | 2 +
> ld/testsuite/ld-x86-64/x86-64.exp | 6 ++
> 24 files changed, 412 insertions(+), 13 deletions(-)
> create mode 100644 ld/emulparams/x86-64-level-report.sh
> create mode 100644 ld/testsuite/ld-i386/pr31868a.d
> create mode 100644 ld/testsuite/ld-i386/pr31868b.d
> create mode 100644 ld/testsuite/ld-i386/pr31868c.d
> create mode 100644 ld/testsuite/ld-x86-64/pr31868a-x32.d
> create mode 100644 ld/testsuite/ld-x86-64/pr31868a.d
> create mode 100644 ld/testsuite/ld-x86-64/pr31868a.l
> create mode 100644 ld/testsuite/ld-x86-64/pr31868a.s
> create mode 100644 ld/testsuite/ld-x86-64/pr31868b-x32.d
> create mode 100644 ld/testsuite/ld-x86-64/pr31868b.d
> create mode 100644 ld/testsuite/ld-x86-64/pr31868b.l
> create mode 100644 ld/testsuite/ld-x86-64/pr31868b.s
> create mode 100644 ld/testsuite/ld-x86-64/pr31868c-x32.d
> create mode 100644 ld/testsuite/ld-x86-64/pr31868c.d
> create mode 100644 ld/testsuite/ld-x86-64/pr31868c.l
>
> diff --git a/bfd/elf-linker-x86.h b/bfd/elf-linker-x86.h
> index 03086fc7ce3..61bffa9c202 100644
> --- a/bfd/elf-linker-x86.h
> +++ b/bfd/elf-linker-x86.h
> @@ -28,6 +28,14 @@ enum elf_x86_prop_report
> prop_report_shstk = 1 << 3 /* Report missing SHSTK property. */
> };
>
> +/* ISA level report control. */
> +enum elf_x86_isa_level_report
> +{
> + isa_level_report_none = 0, /* Do nothing. */
> + isa_level_report_needed = 1 << 0, /* Needed x86-64 ISA level. */
> + isa_level_report_used = 1 << 1 /* Used x86-64 ISA level.
> */
> +};
> +
> /* Used to pass x86-specific linker options from ld to bfd. */
> struct elf_linker_x86_params
> {
> @@ -67,6 +75,9 @@ struct elf_linker_x86_params
> /* X86-64 ISA level needed. */
> unsigned int isa_level;
>
> + /* Report needed and used x86-64 ISA levels. */
> + enum elf_x86_isa_level_report isa_level_report;
> +
> /* Report missing IBT and SHSTK properties. */
> enum elf_x86_prop_report cet_report;
>
> diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
> index 8564391029a..28ec6d21184 100644
> --- a/bfd/elfxx-x86.c
> +++ b/bfd/elfxx-x86.c
> @@ -4017,6 +4017,50 @@ _bfd_x86_elf_merge_gnu_properties (struct
> bfd_link_info *info,
> return updated;
> }
>
> +/* Report x86-64 ISA level. */
> +
> +static void
> +report_isa_level (struct bfd_link_info *info, bfd *abfd,
> + unsigned int bitmask, bool needed)
> +{
> + if (!bitmask)
> + return;
> +
> + if (needed)
> + info->callbacks->einfo (_("%pB: x86 ISA needed: "), abfd);
> + else
> + info->callbacks->einfo (_("%pB: x86 ISA used: "), abfd);
> +
> + while (bitmask)
> + {
> + unsigned int bit = bitmask & (- bitmask);
> +
> + bitmask &= ~ bit;
> + switch (bit)
> + {
> + case GNU_PROPERTY_X86_ISA_1_BASELINE:
> + info->callbacks->einfo ("x86-64-baseline");
> + break;
> + case GNU_PROPERTY_X86_ISA_1_V2:
> + info->callbacks->einfo ("x86-64-v2");
> + break;
> + case GNU_PROPERTY_X86_ISA_1_V3:
> + info->callbacks->einfo ("x86-64-v3");
> + break;
> + case GNU_PROPERTY_X86_ISA_1_V4:
> + info->callbacks->einfo ("x86-64-v4");
> + break;
> + default:
> + info->callbacks->einfo (_("<unknown: %x>"), bit);
> + break;
> + }
> + if (bitmask)
> + info->callbacks->einfo (", ");
> + }
> +
> + info->callbacks->einfo ("\n");
> +}
> +
> /* Set up x86 GNU properties. Return the first relocatable ELF input
> with GNU properties if found. Otherwise, return NULL. */
>
> @@ -4155,11 +4199,12 @@ _bfd_x86_elf_link_setup_gnu_properties
> }
> }
>
> - if (htab->params->cet_report
> - || htab->params->lam_u48_report
> - || htab->params->lam_u57_report)
> + bool check_feature_1 = (htab->params->cet_report
> + || htab->params->lam_u48_report
> + || htab->params->lam_u57_report);
> + if (check_feature_1 || htab->params->isa_level_report)
> {
> - /* Report missing IBT, SHSTK and LAM properties. */
> + /* Report missing IBT, SHSTK, ISA level and LAM properties. */
> bfd *abfd;
> const char *warning_msg = _("%P: %pB: warning: missing %s\n");
> const char *error_msg = _("%X%P: %pB: error: missing %s\n");
> @@ -4167,7 +4212,6 @@ _bfd_x86_elf_link_setup_gnu_properties
> const char *lam_u48_msg = NULL;
> const char *lam_u57_msg = NULL;
> const char *missing;
> - elf_property_list *p;
> bool missing_ibt, missing_shstk;
> bool missing_lam_u48, missing_lam_u57;
> bool check_ibt
> @@ -4176,6 +4220,10 @@ _bfd_x86_elf_link_setup_gnu_properties
> bool check_shstk
> = (htab->params->cet_report
> && (htab->params->cet_report & prop_report_shstk));
> + bool report_needed_level
> + = (htab->params->isa_level_report & isa_level_report_needed) != 0;
> + bool report_used_level
> + = (htab->params->isa_level_report & isa_level_report_used) != 0;
>
> if (htab->params->cet_report)
> {
> @@ -4203,23 +4251,63 @@ _bfd_x86_elf_link_setup_gnu_properties
> if (!(abfd->flags & (DYNAMIC | BFD_PLUGIN | BFD_LINKER_CREATED))
> && bfd_get_flavour (abfd) == bfd_target_elf_flavour)
> {
> - for (p = elf_properties (abfd); p; p = p->next)
> - if (p->property.pr_type == GNU_PROPERTY_X86_FEATURE_1_AND)
> - break;
> + elf_property_list *p1;
> + elf_property_list *p_feature_1 = NULL;
> + elf_property_list *p_isa_1_needed = NULL;
> + elf_property_list *p_isa_1_used = NULL;
> + bool find_feature_1 = check_feature_1;
> + bool find_needed_level = report_needed_level;
> + bool find_used_level = report_used_level;
> +
> + for (p1 = elf_properties (abfd); p1; p1 = p1->next)
> + {
> + switch (p1->property.pr_type)
> + {
> + case GNU_PROPERTY_X86_FEATURE_1_AND:
> + if (find_feature_1)
> + {
> + p_feature_1 = p1;
> + find_feature_1 = false;
> + }
> + break;
> + case GNU_PROPERTY_X86_ISA_1_NEEDED:
> + if (find_needed_level)
> + {
> + p_isa_1_needed = p1;
> + find_needed_level = false;
> + }
> + break;
> + case GNU_PROPERTY_X86_ISA_1_USED:
> + if (find_used_level)
> + {
> + p_isa_1_used = p1;
> + find_used_level = false;
> + }
> + break;
> + default:
> + break;
> + }
> +
> + if (!find_feature_1
> + && !find_needed_level
> + && !find_used_level)
> + break;
> + }
> +
>
> missing_ibt = check_ibt;
> missing_shstk = check_shstk;
> missing_lam_u48 = !!lam_u48_msg;
> missing_lam_u57 = !!lam_u57_msg;
> - if (p)
> + if (p_feature_1)
> {
> - missing_ibt &= !(p->property.u.number
> + missing_ibt &= !(p_feature_1->property.u.number
> & GNU_PROPERTY_X86_FEATURE_1_IBT);
> - missing_shstk &= !(p->property.u.number
> + missing_shstk &= !(p_feature_1->property.u.number
> & GNU_PROPERTY_X86_FEATURE_1_SHSTK);
> - missing_lam_u48 &= !(p->property.u.number
> + missing_lam_u48 &= !(p_feature_1->property.u.number
> & GNU_PROPERTY_X86_FEATURE_1_LAM_U48);
> - missing_lam_u57 &= !(p->property.u.number
> + missing_lam_u57 &= !(p_feature_1->property.u.number
> & GNU_PROPERTY_X86_FEATURE_1_LAM_U57);
> }
> if (missing_ibt || missing_shstk)
> @@ -4242,6 +4330,15 @@ _bfd_x86_elf_link_setup_gnu_properties
> missing = _("LAM_U57 property");
> info->callbacks->einfo (lam_u57_msg, abfd, missing);
> }
> +
> + if (p_isa_1_needed)
> + report_isa_level (info, abfd,
> + p_isa_1_needed->property.u.number,
> + true);
> + if (p_isa_1_used)
> + report_isa_level (info, abfd,
> + p_isa_1_used->property.u.number,
> + false);
> }
> }
>
> diff --git a/ld/NEWS b/ld/NEWS
> index 00eb46047d1..16e3b8bb88a 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 --section-ordering-file <FILE> option to add extra mapping of input
> sections to output sections.
>
> diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh
> index f6c6de9cc9e..6a92eec129d 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 3f124356d02..6f698bb0b06 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 466da2c48ca..92449745c7a 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 00000000000..518527767a4
> --- /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 ef3706fa7ac..b75dc44bb93 100644
> --- a/ld/ld.texi
> +++ b/ld/ld.texi
> @@ -1668,6 +1668,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 18d1c9198ca..94e6655f862 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 00000000000..070d70fc199
> --- /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 00000000000..375c11aa52e
> --- /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 00000000000..dc8543a3621
> --- /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 00000000000..90f16ee78b8
> --- /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 00000000000..54839bb4ebc
> --- /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 00000000000..1244dfd1a57
> --- /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 00000000000..e39405bac53
> --- /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 00000000000..d88efce4b40
> --- /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 00000000000..6ead70e0a90
> --- /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 00000000000..1380befde48
> --- /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 00000000000..afa529e9976
> --- /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 00000000000..a38afd55a84
> --- /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 00000000000..3e6a65d98ab
> --- /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 00000000000..7de0be6c2b1
> --- /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 6546fff4efc..dddac4375e1 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"
> --
> 2.45.2
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20240613/d2a3888b/attachment-0001.htm>
More information about the Binutils
mailing list