aboutsummaryrefslogtreecommitdiff
path: root/gas
AgeCommit message (Collapse)AuthorFilesLines
2023-02-03x86: drop LOCK from XCHG when optimizingJan Beulich6-6/+24
Like with segment overrides on LEA, optimize away such a redundant instruction prefix.
2023-02-03x86-64: respect {nooptimize} when building VEX prefixJan Beulich3-1/+7
Swapping operands for commutative insns occurs outside of optimize_encoding() and hence needs explicit checking for a request to avoid any optimizations.
2023-02-03x86: respect {nooptimize} for LEAJan Beulich8-2/+16
Dropping a meaningless segment prefix occurs outside of optimize_encoding() and hence needs explicit checking for a request to avoid any optimizations.
2023-02-03x86-64: respect MOVABS when choosing alternative encodingsJan Beulich1-1/+2
The alternative encoding is valid for MOV, but there's no such thing for MOVABS.
2023-02-03RISC-V: don't disassemble unrecognized insns as .byteJan Beulich2-16/+16
Insn width granularity being 16 bits, producing byte granular output isn't very useful. With there being a way to specific otherwise unknown insns to the assembler, use that same representation (to be precise: its <length>,<encoding> flavor) for disassembly.
2023-02-02[gas] Update .loc syntax comment in dwarf2dbg.cTom de Vries1-1/+1
I noticed that a comment in gas/dwarf2dbg.c describing .loc syntax was missing the "view VALUE" option. Fix this by adding the missing option.
2023-02-02gas: use "stack trace" instead of "unwind" for SFrameIndu Bhagat11-33/+35
SFrame format is meant for generating stack traces only. gas/ * as.c: Replace the use of "unwind" with "stack trace". * config/tc-aarch64.c: Likewise. * config/tc-aarch64.h: Likewise. * config/tc-i386.c: Likewise. * config/tc-i386.h: Likewise. * gen-sframe.c: Likewise. * gen-sframe.h: Likewise. * testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.s: Likewise. * testsuite/gas/cfi-sframe/cfi-sframe-common-8.s: Likewise. * testsuite/gas/cfi-sframe/common-empty-2.s: Likewise. * testsuite/gas/cfi-sframe/common-empty-3.s: Likewise.
2023-02-02obj-elf.h BYTES_IN_WORDAlan Modra1-1/+0
Don't define this. It is defined just before elf-bfd.h is included, but doesn't have any relevance there. Instead is for aout64.h where the default is 4 anyway.
2023-02-02gas obj_endAlan Modra8-28/+69
Provide a way for config/obj-* to clean up at end of assembly, and do so for ELF. * obj.h (struct format_ops): Add "end". * config/obj-aout.c (aout_format_ops): Init new field. * config/obj-coff.c (coff_format_ops): Likewise. * config/obj-ecoff.c (ecoff_format_ops): Likewise. * config/obj-elf.c (elf_format_ops): Likewise. (elf_begin): Move later in file. Clear some more variables. (comment_section): Make file scope. (free_section_idx): Rewrite. (elf_adjust_symtab): Expand str_htab_create call and use free_section_idx as delete function. (elf_frob_file_after_relocs): Don't clean up groups.indexes here. (elf_end): New function. * config/obj-elf.h (obj_end): Define. * config/obj-multi.h (obj_end): Define. * output-file.c (output_file_close): Call obj_end.
2023-02-01Fix compilation of the assembler with sanitization enabled.Nick Clifton2-2/+7
* dwarf2dbg.c (emit_inc_line_addr): Use unsigned constants when checking addr_delta.
2023-02-01Recursion in as_info_whereAlan Modra1-2/+0
This function has a gas_assert, ie. possible call to as_abort, which calls as_report_context, which calls as_info_where. * messages.c (as_info_where): Don't gas_assert.
2023-02-01[gas] Emit v2 .debug_line for -gdwarf-2Tom de Vries4-24/+26
Currently, when using -gdwarf-2, gas emits a v3 .debug_line contribution. Fix this by emitting a v2 .debug_line contribution instead. gas/ChangeLog: 2023-01-31 Tom de Vries <tdevries@suse.de> PR 23941 * dwarf2dbg.c (DWARF2_LINE_VERSION): Set to 2 for -gdwarf-2. (DWARF2_LINE_OPCODE_BASE): Handle DWARF2_LINE_VERSION == 2. (dwarf2_directive_loc): Bump dwarf_level when encountering v3 .loc options. (out_debug_line): Don't output v3 standard opcodes for v2. * testsuite/gas/i386/debug1.d: Update. * testsuite/gas/i386/dwarf2-line-1.d: Update. * testsuite/gas/i386/dwarf2-line-4.d: Update.
2023-01-31gas/ppc: Additional tests for DFP instructionsAndrew Burgess3-0/+186
I noticed that some of the Power6 DFP instructions were not covered by the assembler tests. I've added a new test file which I believe covers all the DFP Power6 instructions. The existing gas/testsuite/gas/ppc/power6.d test is called: POWER6 tests (includes DFP and Altivec) And does cover some of the DFP instructions. But, given the number of additional instructions I'm adding I opted to add a whole new test file. I've left the original power6.d unchanged, so there is now some overlap, but I don't think that should hurt much.
2023-01-31RISC-V: make C-extension JAL available again for (32-bit) assemblyJan Beulich4-0/+53
Along with the normal JAL alias, the C-extension one should have been moved as well by 839189bc932e ("RISC-V: re-arrange opcode table for consistent alias handling"), for the assembler to actually be able to use it where/when possible. Since neither this nor any other compressed branch insn was being tested so far, take the opportunity and introduce a new testcase covering those.
2023-01-27x86: move reg_operands adjustmentJan Beulich1-13/+10
Ideally we'd do away with this somewhat questionable adjustment (leaving i.types[] untouched). That's non-trivial though as it looks, so only - move the logic into process_operands(), putting it closer to related logic and eliminating a conditional for operand-less insns, - make it consistent (i.e. also affect %xmm0), eliminating an ugly special case later in the function.
2023-01-27x86: drop dead SSE2AVX-related codeJan Beulich1-22/+8
All (there are just two) SSE2AVX templates with %xmm0 as first operand also specify VEX3SOURCES. Hence there's no need for an "else" to the respective if(), and the if() itself can become an assertion.
2023-01-27x86: use ModR/M for FPU insns with operandsJan Beulich1-22/+34
This is the correct way of expressing things; encoding the ModR/M byte directly in base_opcode has always been bogus.
2023-01-27x86/Intel: improve special casing of certain insnsJan Beulich1-21/+15
Now that we have identifiers for the mnemonic strings we can avoid opcode based comparisons, for (in many cases) being more expensive and (in a few cases) being a little fragile and not self-documenting.
2023-01-27Call bfd_close_all_done in output_file_closeAlan Modra1-1/+1
bfd_cache_close_all is good for closing file descriptors, but doesn't do the cleanup of bfd memory as in bfd_close_all_done. PR 13056 * output-file.c (output_file_close): Call bfd_close_all_done, not bfd_cache_close_all.
2023-01-27gas macro memory leaksAlan Modra4-52/+45
This tidies memory allocated for entries in macro_hash. Freeing the macro name requires a little restructuring of the define_macro interface due to the name being used in the error message, and exposed the fact that the name and other fields were not initialised by the iq2000 backend. There is also a fix for .macro .macro .endm .macro .macro .endm which prior to this patch reported mac.s:1: Warning: attempt to redefine pseudo-op `.macro' ignored mac.s:3: Error: Macro `.macro' was already defined rather than reporting the attempt to redefine twice. * macro.c (macro_del_f): New function. (macro_init): Use it when creating macro_hash. (free_macro): Free macro name too. (define_macro): Return the macro_entry, remove idx, file, line and namep params. Call as_where. Report errors here. Delete macro from macro_hash on attempt to redefined pseudo-op. (delete_macro): Don't call free_macro. * macro.h (define_macro): Update prototype. * read.c (s_macro): Adjust to suit. * config/tc-iq2000.c (iq2000_add_macro): Init all fields of macro_entry.
2023-01-27gas/testsuite: Add -gcodeview test for aarch64-w64-mingw32Mark Harmstone4-0/+350
This is a copy of the x86 gas -gcodeview test, with changes made for the differing instruction lengths between x86 and aarch64.
2023-01-27gas: Add CodeView constant for aarch64Mark Harmstone2-6/+14
Adds the correct constant to the S_COMPILE3 CodeView record when assembling aarch64-w64-mingw32 with the -gcodeview flag.
2023-01-27Free gas/dwarf2dbg.c dirsAlan Modra1-0/+2
Entries are allocated with xmemdup0. * dwarf2dbg.c (dwarf2_cleanup): Free dirs entries.
2023-01-27Sanity check dwarf5 form of .fileAlan Modra1-0/+2
There's a comment a few lines earlier saying that demand_copy_C_string has already reported an error if it returns NULL. Given the proximity I decided not to duplicate the comment. * dwarf2dbg.c (dwarf2_directive_filename): Check return of demand_copy_C_string for file.
2023-01-27resolve gas shift expressions with large exponents to zeroAlan Modra1-2/+12
* expr.c (resolve_expression <O_left_shift, O_right_shift>): Resolve shifts exceeding bits in a valueT to zero.
2023-01-23Add support for secidx relocations to aarch64-w64-mingw32Mark Harmstone1-0/+26
This patch adds support for the .secidx directive and its corresponding relocation to aarch64-w64-mingw32. As with x86, this is a two-byte LE integer which gets filled in with the 1-based index of the output section that a symbol ends up in. This is needed for PDBs, which represent addresses as a .secrel32, .secidx pair. The test is substantially the same as for amd64, but with changes made for padding and alignment.
2023-01-20Add OpenBSD ARM GAS support.Frederic Cambus2-1/+5
2023-01-20x86: avoid strcmp() in a few placesJan Beulich1-11/+11
Now that we have identifiers for the mnemonic strings we can avoid strcmp() in a number of places, comparing the offsets into the mnemonic string table instead. While doing this also - convert a leftover strncmp() to startswith() (apparently an oversight when rebasing the original patch introducing the startswith() uses), - use the new shorthand for current_templates->start also elsewhere in md_assemble() (valid up to the point where match_template() is called).
2023-01-20x86: move insn mnemonics to a separate tableJan Beulich3-3/+4
Using full pointers to reference the insn mnemonic strings is not very efficient. With overall string size presently just slightly over 20k, even a 16-bit value would suffice. Use "unsigned int" for now, as there's no good use we could presently make of the otherwise saved 16 bits. For 64-bit builds this reduces table size by 6.25% (prior to the recent ISA extension additions it would have been 12.5%), with a similar effect on cache occupation of table entries accessed. For PIE builds of gas this also reduces the number of base relocations quite a bit (obviously independent of bitness).
2023-01-20x86: abstract out obtaining of a template's mnemonicJan Beulich2-75/+79
In preparation for changing the representation of the "name" field introduce a wrapper function. This keeps the mechanical change separate from the functional one.
2023-01-19Reinitialise macro_nestAlan Modra1-0/+1
* input-scrub.c (input_scrub_begin): Init macro_nest.
2023-01-17gas: arm: Change warning message to not reference specific A-class ↵Stam Markianos-Wright5-224/+224
architecture revision We noticed that a warning message about the use of scalar fp16 instructions being UNPREDICTABLE when conditionalized in an IT block referenced the specific A-class architecture revision ARMv8.2-A. Many of these instructions are now also part of ARMv8.1-M, so the warning message had become misleading. Here we just change the message to not specify an architecture revision at all and update all testing accordingly. This was done with a simple find-n-replace within the binutils sources. No tests have regressed for the arm target. gas/ChangeLog: * config/tc-arm.c (do_scalar_fp16_v82_encode): Remove ARMv8.2-A from the warning message. (do_neon_movhf): Likewise * testsuite/gas/arm/armv8-2-fp16-scalar-bad.l: Likewise * testsuite/gas/arm/mve-vaddsub-it-bad.l: Likewise * testsuite/gas/arm/mve-vcvtne-it-bad.l: Likewise * testsuite/gas/arm/mve-vcvtne-it.d: Likewise
2023-01-17gas: arm: Fix a further IT-predicated vcvt issue in the presense of MVE vcvtnStam Markianos-Wright5-12/+82
Previously we had experienced issues with assembling a "VCVTNE" instruction in the presence of the MVE architecture extension, because it could be interpreted both as: * The base instruction VCVT + NE for IT predication when inside an IT block. * The MVE instruction VCVTN + E in the Else of a VPT block. Given a C reproducer of: ``` int test_function(float value) { int ret_val = 10; if (value != 0.0) { ret_val = (int) value; } return ret_val; } ``` GCC generates a VCVTNE instruction based on the `truncsisf2_vfp` pattern, which will look like: `vcvtne.s32.f32 s-reg, s-reg` This still triggers an error due to being misidentified as "vcvtn+e" Similar errors were found with other type combinations and instruction patterns (these have all been added to the testing of this patch). This class of errors was previously worked around by: https://sourceware.org/pipermail/binutils/2020-August/112728.html which addressed this by looking at the operand types, however, that isn't adequate to cover all the extra cases that have been found. Instead, we add some special-casing logic earlier when the instructions are parsed that is conditional on whether we are in a VPT block or not, when the instruction is parsed. gas/ChangeLog: * config/tc-arm.c (opcode_lookup): Add special vcvtn handling. * testsuite/gas/arm/mve-vcvtne-it-bad.l: Add further testing. * testsuite/gas/arm/mve-vcvtne-it-bad.s: Likewise. * testsuite/gas/arm/mve-vcvtne-it.d: Likewise. * testsuite/gas/arm/mve-vcvtne-it.s: Likewise.
2023-01-16Tidy gas/expr.c static stateAlan Modra7-107/+123
* expr.c (seen, nr_seen): Make file scope. (expr_begin): Clear seen, nr_seen, and expr_symbol_lines. (expr_end): New function. * expr.h (expr_end): Declare. * output-file.c (output_file_close): Call expr_end. * config/tc-hppa.c (expr_end): Rename to expr_parse_end. * config/tc-mips.c: Likewise. * config/tc-riscv.c: Likewise. * config/tc-sparc.c: Likewise.
2023-01-16PR29991, MicroMIPS flag erased after align directivesAlan Modra5-0/+35
PR 29991 * config/tc-mips.c (s_align): Call file_mips_check_options and mips_mark_labels. * testsuite/gas/mips/align-after-label.s, * testsuite/gas/mips/mips-align-after-label.d, * testsuite/gas/mips/micromips-align-after-label.d: New test. * testsuite/gas/mips/mips.exp: Run it.
2023-01-16Updated translations for the gas and binutils sub-directoriesNick Clifton2-2648/+2844
2023-01-12Use __func__ rather than __FUNCTION__Alan Modra3-14/+14
We already use C99's __func__ in places, use it more generally. This patch doesn't change uses in the testsuite. I've also left one in gold.h that is protected by GCC_VERSION < 4003. If any of the remaining uses bothers anyone I invite patches. bfd/ * bfd-in.h: Replace __FUNCTION__ with __func__. * elf32-bfin.c: Likewise. * elfnn-aarch64.c: Likewise. * elfxx-sparc.c: Likewise. * bfd-in2.h: Regenerate. gas/ * config/tc-cris.c: Replace __FUNCTION__ with __func__. * config/tc-m68hc11.c: Likewise. * config/tc-msp430.c: Likewise. gold/ * dwp.h: Replace __FUNCTION__ with __func__. * gold.h: Likewise, except for use inside GCC_VERSION < 4003. ld/ * emultempl/pe.em: Replace __FUNCTION__ with __func__. * emultempl/pep.em: Likewise. * pe-dll.c: Likewise.
2023-01-11gas/RISC-V: adjust assembler for opcode table re-orderingJan Beulich1-0/+11
PR gas/29940 With the single-operand JAL entry now sitting ahead of the two-operand one, the parsing of a two-operand insn would first try to parse an 'a'- style operand, resulting in the insertion of bogus (and otherwise unused) undefined symbols in the symbol table, having register names. Since 'a' is used as 1st operand only with J and JAL, and since JAL is the only insn _also_ allowing for a register as 1st operand (and then there being a 2nd one), special case this parsing aspect right there. Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
2023-01-11Tidy some global bfd state used by gasAlan Modra1-0/+2
* subsegs.c (subsegs_end): Clear abs and und userdata.
2023-01-11now_seg after closing output fileAlan Modra1-0/+2
now_seg, a pointer into the output file sections, isn't valid after the output file is closed. gas doesn't and shouldn't use now_seg after this point of course, but let's be safe. * output-file.c (output_file_close): Clear now_seg and now_subseg.
2023-01-10gas: Restore tc_pe_dwarf2_emit_offset for pe-aarch64Mark Harmstone2-0/+16
Restores tc_pe_dwarf2_emit_offset in tc-aarch64.c, which is needed to make sure that DWARF offsets are encoded correctly (they're secrels in COFF). There were remnants of this there before, but they were removed by Jedidiah's original patch - presumably because we didn't yet have .secrel32.
2023-01-10Add aarch64-w64-mingw32 targetMark Harmstone2-2/+2
This adds a mingw target for aarch64, including windres and dlltool. Note that the old value of jmp_aarch64_bytes was wrong, and this does the same thing as MSVC does.
2023-01-10Add .secrel32 for pe-aarch64Mark Harmstone2-19/+60
Adds the .secrel32 pseudo-directive and its corresponding relocation.
2023-01-10Add pe-aarch64 relocationsMark Harmstone3-21/+395
This adds the remaining pe-aarch64 relocations, and gets them working. It also brings in the constant directives from ELF, as otherwise .word would be 2 rather than 4 bytes, and .xword and .dword wouldn't be defined.
2023-01-06sframe: fix the defined SFRAME_FRE_TYPE_*_LIMIT constantsIndu Bhagat1-6/+6
An earlier commit 3f107464 defined the SFRAME_FRE_TYPE_*_LIMIT constants. These constants are used (by gas and libsframe) to pick an SFrame FRE type based on the function size. Those constants, however, were buggy, causing the generated SFrame sections to be bloated as SFRAME_FRE_TYPE_ADDR2/SFRAME_FRE_TYPE_ADDR4 got chosen more often than necessary. gas/ * sframe-opt.c (sframe_estimate_size_before_relax): Use typecast. (sframe_convert_frag): Likewise. libsframe/ * sframe.c (sframe_calc_fre_type): Use a more appropriate type for argument. Adjust the check for SFRAME_FRE_TYPE_ADDR4_LIMIT to keep it warning-free but meaningful. include/ * sframe-api.h (sframe_calc_fre_type): Use a more appropriate type for the argument. * sframe.h (SFRAME_FRE_TYPE_ADDR1_LIMIT): Correct the constant. (SFRAME_FRE_TYPE_ADDR2_LIMIT): Likewise. (SFRAME_FRE_TYPE_ADDR4_LIMIT): Likewise.
2023-01-03Fix a translation problem in the x86 assembler.Nick Clifton2-7/+25
PR 29952 * config/tc-i386.c (md_assemble): Avoid constructing translatable strings.
2023-01-03Updated translations for various languages and sub-directoriesNick Clifton3-5281/+5672
2023-01-02obsolete target tidyAlan Modra13-42/+9
Delete a few files only used for obsolete targets, and tidy config, xfails and other pieces of support specific to those targets. And since I was editing target triplets in test files, fix the nm alpha-linuxecoff fails.
2023-01-01Update year range in copyright notice of binutils filesAlan Modra578-582/+582
The newer update-copyright.py fixes file encoding too, removing cr/lf on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2022-12-31Update version number and regenerate filesNick Clifton2-2619/+2800