From b4a3a7b44c98a9f78a27bd34d0d98741a0446e23 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 31 Aug 2018 04:31:08 -0700 Subject: [PATCH] x86: Extend assembler to generate GNU property notes Add -mx86-used-note=[yes|no] option to generate (or not) GNU property notes with GNU_PROPERTY_X86_FEATURE_2_USED and GNU_PROPERTY_X86_ISA_1_USED properties. If the assembly input contains no instructions, set the GNU_PROPERTY_X86_UINT32_VALID bit in GNU_PROPERTY_X86_FEATURE_2_USED property. Add a --enable-x86-used-note configure time option to set the default behavior. Set the default if the configure option is not used to "no". * NEWS: Mention -mx86-used-note=[no|yes]. * configure.ac: Add --enable-x86-used-note. Define DEFAULT_X86_USED_NOTE. * config.in: Regenerated. * configure: Likewise. * config/tc-i386.c (x86_isa_1_used): New. (x86_feature_2_used): Likewise. (x86_used_note): Likewise. (_i386_insn): Add has_regmmx, has_regxmm, has_regymm and has_regzmm. (build_modrm_byte): Set i.has_regmmx, i.has_regzmm. i.has_regymm and i.has_regxmm. (x86_cleanup): New function. (output_insn): Update x86_isa_1_used and x86_feature_2_used. (OPTION_X86_USED_NOTE): New. (md_longopts): Add -mx86-used-note=. (md_parse_option): Handle OPTION_X86_USED_NOTE. (md_show_usage): Display -mx86-used-note=. * config/tc-i386.h (x86_cleanup): New prototype. (md_cleanup): New. * doc/c-i386.texi: Document -mx86-used-note=. --- gas/ChangeLog | 24 ++++ gas/NEWS | 5 + gas/config.in | 4 + gas/config/tc-i386.c | 303 +++++++++++++++++++++++++++++++++++++++++-- gas/config/tc-i386.h | 5 + gas/configure | 28 +++- gas/configure.ac | 21 +++ gas/doc/c-i386.texi | 9 ++ 8 files changed, 385 insertions(+), 14 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 231253a6015..2c0ac5889ee 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,27 @@ +2018-08-31 H.J. Lu + + * NEWS: Mention -mx86-used-note=[no|yes]. + * configure.ac: Add --enable-x86-used-note. Define + DEFAULT_X86_USED_NOTE. + * config.in: Regenerated. + * configure: Likewise. + * config/tc-i386.c (x86_isa_1_used): New. + (x86_feature_2_used): Likewise. + (x86_used_note): Likewise. + (_i386_insn): Add has_regmmx, has_regxmm, has_regymm and + has_regzmm. + (build_modrm_byte): Set i.has_regmmx, i.has_regzmm. + i.has_regymm and i.has_regxmm. + (x86_cleanup): New function. + (output_insn): Update x86_isa_1_used and x86_feature_2_used. + (OPTION_X86_USED_NOTE): New. + (md_longopts): Add -mx86-used-note=. + (md_parse_option): Handle OPTION_X86_USED_NOTE. + (md_show_usage): Display -mx86-used-note=. + * config/tc-i386.h (x86_cleanup): New prototype. + (md_cleanup): New. + * doc/c-i386.texi: Document -mx86-used-note=. + 2018-08-30 Jose E. Marchesi * testsuite/gas/sparc/leon.d: Disassemble v8 code also in sparc64 diff --git a/gas/NEWS b/gas/NEWS index d045bbbc726..87fe10a474d 100644 --- a/gas/NEWS +++ b/gas/NEWS @@ -1,5 +1,10 @@ -*- text -*- +* Add -mx86-used-note=[yes|no] option to generate (or not) x86 GNU property + notes. Add a --enable-x86-used-note configure time option to set the + default behavior. Set the default if the configure option is not used + to "no". + * Add support for the MIPS Loongson EXTensions R2 (EXT2) instructions. * Add support for the MIPS Loongson EXTensions (EXT) instructions. diff --git a/gas/config.in b/gas/config.in index aba70fb1e72..1170689ef18 100644 --- a/gas/config.in +++ b/gas/config.in @@ -50,6 +50,10 @@ /* Define to 1 if you want to generate x86 relax relocations by default. */ #undef DEFAULT_GENERATE_X86_RELAX_RELOCATIONS +/* Define to 1 if you want to generate GNU x86 used ISA and feature properties + by default. */ +#undef DEFAULT_X86_USED_NOTE + /* Supported emulations. */ #undef EMULATIONS diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index b64fef9c1c4..bb1d1725d4c 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -188,6 +188,13 @@ static void s_bss (int); #endif #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) static void handle_large_common (int small ATTRIBUTE_UNUSED); + +/* GNU_PROPERTY_X86_ISA_1_USED. */ +static unsigned int x86_isa_1_used; +/* GNU_PROPERTY_X86_FEATURE_2_USED. */ +static unsigned int x86_feature_2_used; +/* Generate x86 used ISA and feature properties. */ +static unsigned int x86_used_note = DEFAULT_X86_USED_NOTE; #endif static const char *default_arch = DEFAULT_ARCH; @@ -332,6 +339,18 @@ struct _i386_insn unsigned int prefixes; unsigned char prefix[MAX_PREFIXES]; + /* Has MMX register operands. */ + bfd_boolean has_regmmx; + + /* Has XMM register operands. */ + bfd_boolean has_regxmm; + + /* Has YMM register operands. */ + bfd_boolean has_regymm; + + /* Has ZMM register operands. */ + bfd_boolean has_regzmm; + /* RM and SIB are the modrm byte and the sib byte where the addressing modes of this insn are encoded. */ modrm_byte rm; @@ -7054,6 +7073,21 @@ build_modrm_byte (void) { i.rm.reg = i.op[dest].regs->reg_num; i.rm.regmem = i.op[source].regs->reg_num; + if (i.op[dest].regs->reg_type.bitfield.regmmx + || i.op[source].regs->reg_type.bitfield.regmmx) + i.has_regmmx = TRUE; + else if (i.op[dest].regs->reg_type.bitfield.regsimd + || i.op[source].regs->reg_type.bitfield.regsimd) + { + if (i.types[dest].bitfield.zmmword + || i.types[source].bitfield.zmmword) + i.has_regzmm = TRUE; + else if (i.types[dest].bitfield.ymmword + || i.types[source].bitfield.ymmword) + i.has_regymm = TRUE; + else + i.has_regxmm = TRUE; + } if ((i.op[dest].regs->reg_flags & RegRex) != 0) i.rex |= REX_R; if ((i.op[dest].regs->reg_flags & RegVRex) != 0) @@ -7393,17 +7427,32 @@ build_modrm_byte (void) unsigned int vex_reg = ~0; for (op = 0; op < i.operands; op++) - if (i.types[op].bitfield.reg - || i.types[op].bitfield.regmmx - || i.types[op].bitfield.regsimd - || i.types[op].bitfield.regbnd - || i.types[op].bitfield.regmask - || i.types[op].bitfield.sreg2 - || i.types[op].bitfield.sreg3 - || i.types[op].bitfield.control - || i.types[op].bitfield.debug - || i.types[op].bitfield.test) - break; + { + if (i.types[op].bitfield.reg + || i.types[op].bitfield.regbnd + || i.types[op].bitfield.regmask + || i.types[op].bitfield.sreg2 + || i.types[op].bitfield.sreg3 + || i.types[op].bitfield.control + || i.types[op].bitfield.debug + || i.types[op].bitfield.test) + break; + if (i.types[op].bitfield.regsimd) + { + if (i.types[op].bitfield.zmmword) + i.has_regzmm = TRUE; + else if (i.types[op].bitfield.ymmword) + i.has_regymm = TRUE; + else + i.has_regxmm = TRUE; + break; + } + if (i.types[op].bitfield.regmmx) + { + i.has_regmmx = TRUE; + break; + } + } if (vex_3_sources) op = dest; @@ -7783,12 +7832,219 @@ output_interseg_jump (void) md_number_to_chars (p + size, (valueT) i.op[0].imms->X_add_number, 2); } +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) +void +x86_cleanup (void) +{ + char *p; + asection *seg = now_seg; + subsegT subseg = now_subseg; + asection *sec; + unsigned int alignment, align_size_1; + unsigned int isa_1_descsz, feature_2_descsz, descsz; + unsigned int isa_1_descsz_raw, feature_2_descsz_raw; + unsigned int padding; + + if (!IS_ELF || !x86_used_note) + return; + + x86_isa_1_used |= GNU_PROPERTY_X86_UINT32_VALID; + x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_X86; + + /* The .note.gnu.property section layout: + + Field Length Contents + ---- ---- ---- + n_namsz 4 4 + n_descsz 4 The note descriptor size + n_type 4 NT_GNU_PROPERTY_TYPE_0 + n_name 4 "GNU" + n_desc n_descsz The program property array + .... .... .... + */ + + /* Create the .note.gnu.property section. */ + sec = subseg_new (NOTE_GNU_PROPERTY_SECTION_NAME, 0); + bfd_set_section_flags (stdoutput, sec, + (SEC_ALLOC + | SEC_LOAD + | SEC_DATA + | SEC_HAS_CONTENTS + | SEC_READONLY)); + + if (get_elf_backend_data (stdoutput)->s->elfclass == ELFCLASS64) + { + align_size_1 = 7; + alignment = 3; + } + else + { + align_size_1 = 3; + alignment = 2; + } + + bfd_set_section_alignment (stdoutput, sec, alignment); + elf_section_type (sec) = SHT_NOTE; + + /* GNU_PROPERTY_X86_ISA_1_USED: 4-byte type + 4-byte data size + + 4-byte data */ + isa_1_descsz_raw = 4 + 4 + 4; + /* Align GNU_PROPERTY_X86_ISA_1_USED. */ + isa_1_descsz = (isa_1_descsz_raw + align_size_1) & ~align_size_1; + + feature_2_descsz_raw = isa_1_descsz; + /* GNU_PROPERTY_X86_FEATURE_2_USED: 4-byte type + 4-byte data size + + 4-byte data */ + feature_2_descsz_raw += 4 + 4 + 4; + /* Align GNU_PROPERTY_X86_FEATURE_2_USED. */ + feature_2_descsz = ((feature_2_descsz_raw + align_size_1) + & ~align_size_1); + + descsz = feature_2_descsz; + /* Section size: n_namsz + n_descsz + n_type + n_name + n_descsz. */ + p = frag_more (4 + 4 + 4 + 4 + descsz); + + /* Write n_namsz. */ + md_number_to_chars (p, (valueT) 4, 4); + + /* Write n_descsz. */ + md_number_to_chars (p + 4, (valueT) descsz, 4); + + /* Write n_type. */ + md_number_to_chars (p + 4 * 2, (valueT) NT_GNU_PROPERTY_TYPE_0, 4); + + /* Write n_name. */ + memcpy (p + 4 * 3, "GNU", 4); + + /* Write 4-byte type. */ + md_number_to_chars (p + 4 * 4, + (valueT) GNU_PROPERTY_X86_ISA_1_USED, 4); + + /* Write 4-byte data size. */ + md_number_to_chars (p + 4 * 5, (valueT) 4, 4); + + /* Write 4-byte data. */ + md_number_to_chars (p + 4 * 6, (valueT) x86_isa_1_used, 4); + + /* Zero out paddings. */ + padding = isa_1_descsz - isa_1_descsz_raw; + if (padding) + memset (p + 4 * 7, 0, padding); + + /* Write 4-byte type. */ + md_number_to_chars (p + isa_1_descsz + 4 * 4, + (valueT) GNU_PROPERTY_X86_FEATURE_2_USED, 4); + + /* Write 4-byte data size. */ + md_number_to_chars (p + isa_1_descsz + 4 * 5, (valueT) 4, 4); + + /* Write 4-byte data. */ + md_number_to_chars (p + isa_1_descsz + 4 * 6, + (valueT) x86_feature_2_used, 4); + + /* Zero out paddings. */ + padding = feature_2_descsz - feature_2_descsz_raw; + if (padding) + memset (p + isa_1_descsz + 4 * 7, 0, padding); + + /* We probably can't restore the current segment, for there likely + isn't one yet... */ + if (seg && subseg) + subseg_set (seg, subseg); +} +#endif + static void output_insn (void) { fragS *insn_start_frag; offsetT insn_start_off; +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) + if (IS_ELF && x86_used_note) + { + if (i.tm.cpu_flags.bitfield.cpucmov) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_CMOV; + if (i.tm.cpu_flags.bitfield.cpusse) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_SSE; + if (i.tm.cpu_flags.bitfield.cpusse2) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_SSE2; + if (i.tm.cpu_flags.bitfield.cpusse3) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_SSE3; + if (i.tm.cpu_flags.bitfield.cpussse3) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_SSSE3; + if (i.tm.cpu_flags.bitfield.cpusse4_1) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_SSE4_1; + if (i.tm.cpu_flags.bitfield.cpusse4_2) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_SSE4_2; + if (i.tm.cpu_flags.bitfield.cpuavx) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX; + if (i.tm.cpu_flags.bitfield.cpuavx2) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX2; + if (i.tm.cpu_flags.bitfield.cpufma) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_FMA; + if (i.tm.cpu_flags.bitfield.cpuavx512f) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512F; + if (i.tm.cpu_flags.bitfield.cpuavx512cd) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512CD; + if (i.tm.cpu_flags.bitfield.cpuavx512er) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512ER; + if (i.tm.cpu_flags.bitfield.cpuavx512pf) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512PF; + if (i.tm.cpu_flags.bitfield.cpuavx512vl) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512VL; + if (i.tm.cpu_flags.bitfield.cpuavx512dq) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512DQ; + if (i.tm.cpu_flags.bitfield.cpuavx512bw) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512BW; + if (i.tm.cpu_flags.bitfield.cpuavx512_4fmaps) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_4FMAPS; + if (i.tm.cpu_flags.bitfield.cpuavx512_4vnniw) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_4VNNIW; + if (i.tm.cpu_flags.bitfield.cpuavx512_bitalg) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_BITALG; + if (i.tm.cpu_flags.bitfield.cpuavx512ifma) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_IFMA; + if (i.tm.cpu_flags.bitfield.cpuavx512vbmi) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_VBMI; + if (i.tm.cpu_flags.bitfield.cpuavx512_vbmi2) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_VBMI2; + if (i.tm.cpu_flags.bitfield.cpuavx512_vnni) + x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_VNNI; + + if (i.tm.cpu_flags.bitfield.cpu8087 + || i.tm.cpu_flags.bitfield.cpu287 + || i.tm.cpu_flags.bitfield.cpu387 + || i.tm.cpu_flags.bitfield.cpu687 + || i.tm.cpu_flags.bitfield.cpufisttp) + x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_X87; + /* Don't set GNU_PROPERTY_X86_FEATURE_2_MMX for prefetchtXXX nor + Xfence instructions. */ + if (i.tm.base_opcode != 0xf18 + && i.tm.base_opcode != 0xf0d + && i.tm.base_opcode != 0xfae + && (i.has_regmmx + || i.tm.cpu_flags.bitfield.cpummx + || i.tm.cpu_flags.bitfield.cpua3dnow + || i.tm.cpu_flags.bitfield.cpua3dnowa)) + x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_MMX; + if (i.has_regxmm) + x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_XMM; + if (i.has_regymm) + x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_YMM; + if (i.has_regzmm) + x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_ZMM; + if (i.tm.cpu_flags.bitfield.cpufxsr) + x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_FXSR; + if (i.tm.cpu_flags.bitfield.cpuxsave) + x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_XSAVE; + if (i.tm.cpu_flags.bitfield.cpuxsaveopt) + x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_XSAVEOPT; + if (i.tm.cpu_flags.bitfield.cpuxsavec) + x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_XSAVEC; + } +#endif + /* Tie dwarf2 debug info to the address at the start of the insn. We can't do this after the insn has been output as the current frag may have been closed off. eg. by frag_var. */ @@ -10581,6 +10837,7 @@ const char *md_shortopts = "qnO::"; #define OPTION_MAMD64 (OPTION_MD_BASE + 22) #define OPTION_MINTEL64 (OPTION_MD_BASE + 23) #define OPTION_MFENCE_AS_LOCK_ADD (OPTION_MD_BASE + 24) +#define OPTION_X86_USED_NOTE (OPTION_MD_BASE + 25) struct option md_longopts[] = { @@ -10592,6 +10849,7 @@ struct option md_longopts[] = #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) {"x32", no_argument, NULL, OPTION_X32}, {"mshared", no_argument, NULL, OPTION_MSHARED}, + {"mx86-used-note", required_argument, NULL, OPTION_X86_USED_NOTE}, #endif {"divide", no_argument, NULL, OPTION_DIVIDE}, {"march", required_argument, NULL, OPTION_MARCH}, @@ -10659,6 +10917,17 @@ md_parse_option (int c, const char *arg) case OPTION_MSHARED: shared = 1; break; + + case OPTION_X86_USED_NOTE: + if (strcasecmp (arg, "yes") == 0) + x86_used_note = 1; + else if (strcasecmp (arg, "no") == 0) + x86_used_note = 0; + else + as_fatal (_("invalid -mx86-used-note= option: `%s'"), arg); + break; + + #endif #if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \ || defined (TE_PE) || defined (TE_PEP) || defined (OBJ_MACH_O)) @@ -11196,9 +11465,19 @@ md_show_usage (FILE *stream) -mnaked-reg don't require `%%' prefix for registers\n")); fprintf (stream, _("\ -madd-bnd-prefix add BND prefix for all valid branches\n")); +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) fprintf (stream, _("\ -mshared disable branch optimization for shared code\n")); -# if defined (TE_PE) || defined (TE_PEP) + fprintf (stream, _("\ + -mx86-used-note=[no|yes] ")); + if (DEFAULT_X86_USED_NOTE) + fprintf (stream, _("(default: yes)\n")); + else + fprintf (stream, _("(default: no)\n")); + fprintf (stream, _("\ + generate x86 used ISA and feature properties\n")); +#endif +#if defined (TE_PE) || defined (TE_PEP) fprintf (stream, _("\ -mbig-obj generate big object files\n")); #endif diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index 833047980bb..5426301025c 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -316,6 +316,11 @@ extern bfd_vma x86_64_section_letter (int, const char **); #define md_elf_section_letter(LETTER, PTR_MSG) x86_64_section_letter (LETTER, PTR_MSG) #define md_elf_section_word(STR, LEN) x86_64_section_word (STR, LEN) +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) +extern void x86_cleanup (void); +#define md_cleanup() x86_cleanup () +#endif + #ifdef TE_PE #define O_secrel O_md1 diff --git a/gas/configure b/gas/configure index 7dc72c08b05..35effb4006d 100755 --- a/gas/configure +++ b/gas/configure @@ -808,6 +808,7 @@ enable_compressed_debug_sections enable_x86_relax_relocations enable_elf_stt_common enable_generate_build_notes +enable_x86_used_note enable_werror enable_build_warnings with_cpu @@ -1469,6 +1470,7 @@ Optional Features: --enable-generate-build-notes generate GNU Build notes if none are provided by the input + --enable-x86-used-note generate GNU x86 used ISA and feature properties --enable-werror treat compile warnings as errors --enable-build-warnings enable build-time compiler warnings --disable-nls do not use Native Language Support @@ -11335,7 +11337,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11338 "configure" +#line 11340 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11441,7 +11443,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11444 "configure" +#line 11446 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12111,6 +12113,19 @@ esac fi +# Decide if the x86 ELF assembler should default to generating GNU x86 +# used ISA and feature properties. +ac_default_generate_x86_used_note=unset +# Provide a configuration option to override the default. +# Check whether --enable-x86-used-note was given. +if test "${enable_x86_used_note+set}" = set; then : + enableval=$enable_x86_used_note; case "${enableval}" in + yes) ac_default_generate_x86_used_note=1 ;; + no) ac_default_generate_x86_used_note=0 ;; +esac +fi + + using_cgen=no @@ -13039,6 +13054,15 @@ cat >>confdefs.h <<_ACEOF _ACEOF +if test ${ac_default_generate_x86_used_note} = unset; then + ac_default_generate_x86_used_note=0 +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_X86_USED_NOTE $ac_default_generate_x86_used_note +_ACEOF + + if test x$ac_default_compressed_debug_sections = xyes ; then $as_echo "#define DEFAULT_FLAG_COMPRESS_DEBUG 1" >>confdefs.h diff --git a/gas/configure.ac b/gas/configure.ac index 79714eb3dca..d8fddfb19e4 100644 --- a/gas/configure.ac +++ b/gas/configure.ac @@ -113,6 +113,19 @@ AC_ARG_ENABLE(generate_build_notes, esac])dnl +# Decide if the x86 ELF assembler should default to generating GNU x86 +# used ISA and feature properties. +ac_default_generate_x86_used_note=unset +# Provide a configuration option to override the default. +AC_ARG_ENABLE(x86-used-note, + AS_HELP_STRING([--enable-x86-used-note], + [generate GNU x86 used ISA and feature properties]), +[case "${enableval}" in + yes) ac_default_generate_x86_used_note=1 ;; + no) ac_default_generate_x86_used_note=0 ;; +esac])dnl + + using_cgen=no AM_BINUTILS_WARNINGS @@ -613,6 +626,14 @@ AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_BUILD_NOTES, [Define to 1 if you want to generate GNU Build attribute notes by default, if none are contained in the input.]) +if test ${ac_default_generate_x86_used_note} = unset; then + ac_default_generate_x86_used_note=0 +fi +AC_DEFINE_UNQUOTED(DEFAULT_X86_USED_NOTE, + $ac_default_generate_x86_used_note, + [Define to 1 if you want to generate GNU x86 used ISA and feature + properties by default.]) + if test x$ac_default_compressed_debug_sections = xyes ; then AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.]) fi diff --git a/gas/doc/c-i386.texi b/gas/doc/c-i386.texi index c9eb178aa50..64e33977d7b 100644 --- a/gas/doc/c-i386.texi +++ b/gas/doc/c-i386.texi @@ -400,6 +400,15 @@ R_X86_64_REX_GOTPCRELX, in 64-bit mode. relocations. The default can be controlled by a configure option @option{--enable-x86-relax-relocations}. +@cindex @samp{-mx86-used-note=} option, i386 +@cindex @samp{-mx86-used-note=} option, x86-64 +@item -mx86-used-note=@var{no} +@itemx -mx86-used-note=@var{yes} +These options control whether the assembler should generate +GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_FEATURE_2_USED +GNU property notes. The default can be controlled by the +@option{--enable-x86-used-note} configure option. + @cindex @samp{-mevexrcig=} option, i386 @cindex @samp{-mevexrcig=} option, x86-64 @item -mevexrcig=@var{rne} -- 2.30.2