summaryrefslogtreecommitdiff
path: root/gas
Commit message (Collapse)AuthorAgeFilesLines
* aarch64: Consolidate ZA tile range checksRichard Sandiford2023-03-306-163/+127
| | | | | | | | Now that all parsing of ZA tile names goes through parse_typed_reg, we can check there for out-of-range tile numbers. The other check performed by parse_sme_zada_operand was to reject .q, but that can now be done via F_STRICT instead. (.q tiles are valid in other contexts, so they shouldn't be rejected in parse_typed_reg.)
* aarch64: Reuse parse_typed_reg for ZA tilesRichard Sandiford2023-03-301-51/+47
| | | | | | | This patch reuses the general parse_typed_reg for ZA tiles. This involves adding a way of suppressing the usual treatment of register indices, since ZA indices look very different from Advanced SIMD and SVE vector indices.
* aarch64: Rework parse_typed_reg interfaceRichard Sandiford2023-03-301-71/+53
| | | | | | | | | | | | parse_typed_reg returned a register number and passed the register type back using a pointer parameter. It seems simpler to return the register entry instead, since that has both pieces of information in one place. The patch also replaces the boolean in_reg_list parameter with a mask of flags. This hopefully makes calls easier to read (more self-documenting than "true" or "false"), but more importantly, it allows a later patch to add a second flag.
* aarch64: Move vectype_to_qualifier further upRichard Sandiford2023-03-301-75/+75
| | | | | | This patch just moves vectype_to_qualifier further up, so that a later patch can call it at an earlier point in the file. No behavioural change intended.
* aarch64: Add REG_TYPE_ZATHVRichard Sandiford2023-03-301-14/+9
| | | | | | This patch adds a multi-register type that includes both REG_TYPE_ZATH and REG_TYPE_ZATV. This slightly simplifies the existing code, but the main purpose is to enable later patches.
* aarch64: Rename REG_TYPE_ZA* to REG_TYPE_ZAT*Richard Sandiford2023-03-301-10/+11
| | | | | | | | The ZA tile registers were called REG_TYPE_ZA, REG_TYPE_ZAH and REG_TYPE_ZAV. However, a later patch wants to make plain "za" a register type too, and REG_TYPE_ZA is the obvious name for that. This patch therefore adds "T" (tile) to the existing names.
* aarch64: Use aarch64_operand_error more widelyRichard Sandiford2023-03-301-22/+8
| | | | | | | | GAS's aarch64_instruction had its own cut-down error record, but it's better for later patches if it reuses the binutils-wide aarch64_operand_error instead. The main difference is that aarch64_operand_error can store arguments to the error while aarch64_instruction couldn't.
* aarch64: Fix SVE2 register/immediate distinctionRichard Sandiford2023-03-303-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | GAS refuses to interpret register names like x0 as unadorned immediates, due to the obvious potential for confusion with register operands. (An explicit #x0 is OK.) For compatibility reasons, we can't extend the set of registers that GAS rejects for existing instructions. For example: mov x0, z0 was valid code before SVE was added, so it needs to stay valid code even when SVE is enabled. But we can make GAS reject newer registers in newer instructions. The SVE instruction: and z0.s, z0.s, z0.h is therefore invalid, rather than z0.h being an immediate. This patch extends the SVE behaviour to SVE2. The old call to AARCH64_CPU_HAS_FEATURE was technically the wrong way around, although it didn't matter in practice for base SVE instructions since their avariants only set SVE.
* aarch64: Restrict range of PRFM opcodesRichard Sandiford2023-03-304-17/+17
| | | | | | | In the register-index forms of PRFM, the unallocated prefetch opcodes 24-31 have been reused for the encoding of the new RPRFM instruction. The PRFM opcode space is now capped at 23 for these forms. The other forms of PRFM are unaffected.
* aarch64: Fix PSEL opcode maskRichard Sandiford2023-03-302-0/+8
| | | | | The opcode mask for PSEL was missing some bits, which meant that some upcoming SME2 opcodes would be misinterpreted as PSELs.
* aarch64: Add sme-i16i64 and sme-f64f64 aliasesRichard Sandiford2023-03-304-6/+160
| | | | | | | Most extension flags are named after the associated architectural FEAT_* flags, but sme-i64 and sme-f64 were exceptions. This patch adds sme-i16i64 and sme-f64f64 aliases, but keeps the old names too for compatibility.
* Avoid undefined behaviour in m68hc11 md_beginAlan Modra2023-03-281-17/+15
| | | | | | | | | | | | | | | | | | Given p = A where p is a pointer to some type and A is an array of that type, then the expression p - 1 + 1 evokes undefined behaviour according to the C standard. gcc-13 -fsanitize=address,undefined complains about this, but not where the undefined behaviour actually occurs at tc-m68hc11.c:646. Instead you get an error: "tc-m68hc11.c:708:20: runtime error: store to address 0x62600000016c with insufficient space for an object of type 'int'". Which is a lie. There most definitely is space there. Oh well, diagnostics are sometimes hard to get right. The UB is easy to avoid. PR 30279 * config/tc-m68hc11.c (md_begin): Avoid undefined pointer decrement. Remove unnecessary cast.
* Tidy tc-ppc.c XCOFF auxent accessAlan Modra2023-03-271-45/+48
| | | | | | | | | | | It's better not to drill down into u.auxent but instead use a pointer to the combined_entry_type. That way the fix_scnlen field is available, and no one looking at the codes needs to wonder whether coffsymbol (symbol_get_bfdsym (sym))->native[i + 1] is the same auxent. * config/tc-ppc.c (ppc_frob_symbol): Tidy XCOFF auxent access. (ppc_adjust_symtab): Likewise.
* Use stdint types in coff internal_auxentAlan Modra2023-03-272-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | long is a poor choice of type to store 32-bit values read from objects files by H_GET_32. H_GET_32 doesn't sign extend so tests like that in gdb/coffread.c for "negative" values won't work if long is larger than 32 bits. If long is 32-bit then code needs to be careful to not accidentally index negative array elements. (I'd rather see a segfault on an unmapped 4G array index than silently reading bogus data.) long is also a poor choice for x_sect.s_scnlen, which might have 64-bit values. It's better to use unsigned exact width types to avoid surprises. I decided to change the field names too, which makes most of this patch simply renaming. Besides that there are a few places where casts are no longer needed, and where printf format strings or tests need adjusting. include/ * coff/internal.h (union internal_auxent): Use unsigned stdint types. Rename l fields to u32 and u64 as appropriate. bfd/ * coff-bfd.c, * coff-rs6000.c, * coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c, * coffswap.h, * peXXigen.c, * xcofflink.c: Adjust to suit internal_auxent changes. binutils/ * rdcoff.c: Adjust to suit internal_auxent changes. gas/ * config/obj-coff.h, * config/tc-ppc.c: Adjust to suit internal_auxent changes. gdb/ * coffread.c, * xcoffread.c: Adjust to suit internal_auxent changes. ld/ * pe-dll.c: Adjust to suit internal_auxent changes.
* gas: expand_irp memory leaksAlan Modra2023-03-221-2/+10
| | | | * macro.c (expand_irp): Free memory on error return paths.
* x86: Check unbalanced braces in memory referenceH.J. Lu2023-03-215-1/+15
| | | | | | | | | | | | | | | | | | | Check unbalanced braces in memory reference to avoid assembler crash caused by commit e87fb6a6d0cdfc0e9c471b7825c20c238c2cf506 Author: Jan Beulich <jbeulich@suse.com> Date: Wed Oct 5 09:16:24 2022 +0200 x86/gas: support quoted address scale factor in AT&T syntax PR gas/30248 * config/tc-i386.c (i386_att_operand): Check unbalanced braces in memory reference. * testsuite/gas/i386/i386.exp: Run pr30248. * testsuite/gas/i386/pr30248.d: New file. * testsuite/gas/i386/pr30248.err: Likewise. * testsuite/gas/i386/pr30248.s: Likewise.
* x86: drop identifier_chars[]Jan Beulich2023-03-201-22/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It tries to resemble what's underlying is_part_of_name(), but doesn't quite achieve that: '$' for example is unconditionally marked as part of symbol names, but was included as identifier char for Intel syntax only. Note that i386_att_operand() checks for the immediate prefix first, so the wider coverage by starts_memory_operand() is has no real effect there, but it does matter for something like mov %fs:$dollar, %eax which previously wasn't accepted (but which clearly is a memory reference - there's no point in forcing people to parenthesize the symbol name). Similarly including '%' as an identfier for Intel syntax had no real significance to the rest of the assembler. If '%' was to be valid in (unquoted) symbol names, LEX_PCT would need to be defined. Note further that this also addresses the latent issue of a sub-target defining LEX_AT or LEX_QM to zero: That would make '@' and/or '?' no valid part of symbol names, but would have included them in what is_identifier_char() considers a valid part of a name. (There's a minor related issue which is actually being eliminated: te-interix.h allows '@' only in the middle of symbol names, yet starts_memory_operand() specifically looks at the first character of [possibly] a symbol name.) In parse_real_register() there's no point also checking is_name_ender() as at this point no character is marked solely LEX_END_NAME by any sub- target. Checking is_name_beginner() is also pointless as the hash lookup will fail anyway for a zero-length name. While touching the check in parse_real_register() also drop the "allow_naked_reg" part of the condition: This has only led to inconsistent error messages.
* x86/AT&T: restrict recognition of the "absolute branch" prefix characterJan Beulich2023-03-201-2/+4
| | | | | | | | | | | | | While in principle merely rejecting this for .insn would be sufficient for the purposes there, be more generic and reject it for anything that isn't going to be a branch: All elements of same-mnemonic template groups either are branches, or are not, and the few cases possibly requiring a 2nd parsing pass aren't affected either. This then also improves diagnostics for misuses like inc *%eax incl %fs:*(%eax) add *$1, %eax
* x86: VexVVVV is now merely a booleanJan Beulich2023-03-201-1/+1
| | | | | | | | | | With the SDM long having dropped the NDS/NDD/DDS concept of identifying encoding variants, we can finally do away with this concept as well. Of the few consumers of the attribute, only an assertion was still checking for a particular value, which we don't really need to retain. When touching lines anyway, modernize other aspects as well. This often improves similarity to adjacent lines.
* x86: re-work build_modrm_byte()'s register assignmentJan Beulich2023-03-201-287/+112
| | | | | | | | | | | | | | | | | | The function has accumulated a number of special cases for no real reason. Some were necessary because insn attributes (SwapSources in particular) weren't suitably utilized instead. Note that the addition of SwapSources actually increases consistency among the templates: Like others which already have the attribute, these are all insns where the VEX.VVVV-encoded register comes first (or last when looking at the SDM). Note that the vexvvvv attribute now has merely boolean meaning anymore, in line with the SDM long having dropped the NDS/NDD/DDS concept of identifying encoding variants. The fallout will be taken care of subsequently, though, to not further clutter the change here. As to the TILEZERO special case: If more instructions like this appeared, a new attribute would likely be the way to go. But as long as it's only a single insn, going from the mnemonic is cheaper.
* Changed ld and gas BPF testsCupertino Miranda2023-03-201-1/+1
| | | | | | Recent BPF patch removed and renamed the list of relocations based on the limitations of BPF instruction set. This patch is a correction to the tests.
* gas: apply md_register_arithmetic also to unary '+'Jan Beulich2023-03-172-11/+16
| | | | | | | | | | | | | | Even a unary '+' has to be considered arithmetic; at least on x86 in Intel Syntax mode otherwise bogus insn operands may be accepted. Convert this specific case to binary + (i.e. 0 + <register>). (An implication is that md_operator(,1,) would need to deal with arch- specific equivalents of unary '+' is a similar way, if such an arch- specific variant would be specified in the first place.) To avoid duplicating what make_expr_symbol() does to construct a constant-zero expression, simply make its previously local variable a file-scope static one. This way there's also no need to invoke clean_up_expression().
* gas: expose flag_macro_alternate globallyJan Beulich2023-03-175-33/+20
| | | | | | | | Yet again with the removal of gasp about 20 years ago this extra level of indirection isn't necessary anymore either. Drop macro.c's local variable and make as.c's global. While doing the conversion, switch the variable to "bool".
* gas: use flag_mri directly in macro processingJan Beulich2023-03-174-39/+23
| | | | | | Again with the removal of gasp about 20 years ago the extra level of indirection isn't necessary anymore. Drop macro.c's local variable and use the global flag directly.
* gas: isolate macro_strip_at to macro.cJan Beulich2023-03-173-9/+4
| | | | | | | This removes a leftover from i960 support; with that nothing is left which would set macro_strip_at to non-zero, so the variable is converted to a #define (retaining the logic in case a new user would appear) and macro_init()'s respective parameter is dropped.
* gas: drop function pointer parameter from macro_init()Jan Beulich2023-03-173-40/+16
| | | | | | With the removal of gasp (about 20 years ago) the need for this kind- of-hook has disappeared. Go a step beyond merely moving the to be called function: Inline its contents right at the sole call site.
* configure: add new target aarch64-*-nto*Clément Chigot2023-03-161-0/+1
| | | | This target has its own ld emulation based on aarch64elf.em.
* BPF relocations review / refactoringCupertino Miranda2023-03-161-7/+0
| | | | | | | | | | | | | | | | | | | | | - Removed not needed relocations. - Renamed relocations to match llvm and linux kernel. Relocation changes: R_BPF_INSN_64 => R_BPF_64_64 R_BPF_INSN_DISP32 => R_BPF_64_32 R_BPF_DATA_32 => R_BPF_64_ABS32 R_BPF_DATA_64 => R_BPF_64_ABS64 ChangeLog: * bfd/bpf-reloc.def: Created file with BPF_HOWTO macro entries. * bfd/reloc.c: Removed non needed relocations. * bfd/bfd-in2.h: regenerated. * bfd/libbfd.h: regenerated. * bfd/elf64-bpf.c: Changed relocations. * include/elf/bpf.h: Adapted relocation values/names. * gas/config/tc-bpf.c: Changed relocation mapping.
* Fix assembler documentation regarding data directives.Nick Clifton2023-03-142-1/+31
| | | | | PR 30206 * doc/as.texi (Pseudo Ops): Document that data directives such as .byte and .int are not intended for encoding instructions.
* gas/read.c: init more staticsAlan Modra2023-03-141-62/+85
| | | | | | | | | * read.c (current_name, current_label, dwarf_file, dwarf_line): Move to file scope. (pobegin): Tidy pop_override_ok. (read_a_source_file): Make last_eol an auto var. (s_reloc): Constify bfd_relocs. (read_begin): Init more variables.
* gas .include and .incbinAlan Modra2023-03-145-105/+66
| | | | | | | | | | | | | | | | | | This fixes a bug in .include and .incbin where given an absolute path the -I dirs would be searched for the path. * read.c (include_dir_count, include_dir_maxlen): Make them size_t. (search_and_open): New function. (s_incbin, s_include): Use search_and_open. (init_include_dir): New function. (add_include_dir): Don't set initial "." dir here. * read.h (include_dir_count, include_dir_maxlen): Update. (init_include_dir, search_and_open): Declare. * as.c (gas_early_init): Call init_include_dir. * config/tc-rx.c (rx_include): Avoid warning by using size_t. * config/tc-tic54x.c (tic54x_set_default_include): Simplify and use notes for include path. (tic54x_mlib): Use search_and_open.
* gas/dwarf2dbg.c init more staticsAlan Modra2023-03-141-11/+17
| | | | | | | * dwarf2dbg.c (dw2_line, dw2_filename): Move to file scope and.. (dwarf2_gen_line_info): ..renamed from here. (label_num, last_used, last_used_dir_len): Move to file scope. (dwarf2_init): Init moved statics, except last_used_dir_len.
* gas/ecoff.c: don't use zero struct copies to initAlan Modra2023-03-141-18/+9
| | | | | | | | | | It might have made sense once upon a time, but doesn't nowadays when compilers expand memset inline. * ecoff.c (add_aux_sym_tir, allocate_scope, allocate_vlinks), (allocate_shash, allocate_thash, allocate_tag, allocate_forward), (allocate_thead, allocate_lineno_list): Use memset rather than copying zero struct.
* gas/compress-debug.c init all of strmAlan Modra2023-03-141-4/+2
| | | | * compress-debug.c (compress_init): Clear all of strm.
* Arm64/gas: drop redundant feature prereqsJan Beulich2023-03-101-11/+4
| | | | | | | | | Logic exists to deal with prereqs or prereqs, and in many cases transitive prereqs are already not spelled out explicitly. Drop further ones: - FP is already a prereq to F16, - SIMD and F16 are already prereqs to COMPNUM, and - SVE2 and BFLOAT16 are already prereqs to SME.
* Arm64/gas: add missing prereq featuresJan Beulich2023-03-101-6/+6
| | | | | A number of newer features are really SIMD or FP extensions, but don't have this properly specified.
* x86: decouple broadcast type and bytes fieldsJan Beulich2023-03-101-5/+6
| | | | | Keep both representing exclusively what was parsed from input, to avoid the need for (potentially bogus) calculations when processing .insn.
* x86-64: adjust REX-prefix part of SSE2AVX testJan Beulich2023-03-102-46/+46
| | | | | | | | Before altering how build_modrm_byte() works, arrange for this part of the testcase to actually use distinguishable source and destination register numbers, such that incorrect propagation of, in particular, the high bit encodings (from REX to VEX) can be noticed (in turn specifically assertions [not] triggering in the respective code).
* x86: move more disp processing out of md_assemble()Jan Beulich2023-03-101-43/+46
| | | | | | | | | | | | | | Put it in optimize_disp() such that it can then be re-used by .insn handling. The movement makes it necessary (or at least very desirable, to avoid introducing a fragile cast) to convert to local variable to "unsigned", which in turn requires an adjustment to the pre-existing loop header. Having the caller pass in the specific template under consideration has another benefit then: We can replace the two uses of current_templates in the function as well, thus no longer looking at some merely "related" template. (This may allow further tightening, but if so that's to be the subject of another change.)
* x86: use set_rex_vrex() also for short-form handlingJan Beulich2023-03-101-21/+20
| | | | | | This is benign for all existing insns, but is going to be needed for handling of .insn operands. The earlier use requires moving up the function, to avoid the need for a forward declaration.
* eh static dataAlan Modra2023-03-103-21/+31
| | | | | | | | | | | | | | Fix another case of oss-fuzz tripping over gas static state, ie. starting over testing another input file with rubbish left uncleared in bss. size_end_sym pointed at garbage. * ehopt.c (get_cie_info): Delete forward declaration. (struct frame_data): Move to file scope. (frame): New static, packaged.. (check_eh_frame): ..eh_frame_data and debug_frame_data. (eh_begin): New function. * as.c (gas_init): Call eh_begin. * as.h (eh_begin): Declare.
* gas: allow frag address wrapping in absolute sectionAlan Modra2023-03-091-1/+2
| | | | | | | | | | | | | This: .struct -1 x: .fill 1 y: results in an internal error in frag_new due to abs_section_offset wrapping from -1 to 0. Frags in the absolute section don't do much so I think we can allow the address wrap. * frags.c (frag_new): Allow address wrap in absolute section.
* x86: use swap_2_operands() in build_vex_prefix()Jan Beulich2023-03-031-17/+3
| | | | | | | | Open-coding part of what may eventually be needed is somewhat risky. Let's use the function we have, taking care of all pieces of data which may need swapping, no matter that - right now i.flags[] and i.reloc[] aren't relevant here (yet), - EVEX masking and embedded broadcast aren't applicable.
* x86: drop redundant calculation of EVEX broadcast sizeJan Beulich2023-03-031-3/+0
| | | | | | | In commit a5748e0d8c50 ("x86/Intel: allow MASM representation of embedded broadcast") I replaced the calculation of i.broadcast.bytes in check_VecOperands() not paying attention to the immediately following call to get_broadcast_bytes() doing exactly that (again) first thing.
* gas: default .debug section compression method adjustmentsJan Beulich2023-03-031-2/+7
| | | | | | | | | | | | While commit b0c295e1b8d0 ("add --enable-default-compressed-debug- sections-algorithm configure option") adjusted flag_compress_debug's initializer, it didn't alter the default used when the command line option was specified with an (optional!) argument. This rendered help text inconsistent with actual behavior in certain configurations. As to help text - the default reported there clearly shouldn't be affected by a possible earlier --compress-debug-sections= option, so flag_compress_debug can't be used when emitting usage information.
* x86: avoid .byte in testcases where possibleJan Beulich2023-03-034-220/+152
| | | | | | In the course of using the upcoming .insn directive to eliminate various .byte uses in testcases I've come across these, which needlessly use more .byte than necessary even without the availability of .insn.
* More bounds checking in macro_expandAlan Modra2023-03-021-4/+4
| | | | | * macro.c (macro_expand): Ensure input string buffer is not read past end.
* Using .mri in assemblyAlan Modra2023-03-021-7/+8
| | | | | | | | | | | | | | | | Changing mri mode between macro definition and use isn't good. This .macro x .endm .mri 1 x leads to a segfault. Fixed with the following patch, but I suppose what should really happen is that macros be marked as being mri mode when defined, and that determine whether the magic NARG parameter be supplied at expansion. Nobody has complained about this in 30 years so I'm not inclined to change gas behaviour to that extent. * macro.c (macro_expand): Don't segfault in mri mode if NARG formal isn't found.
* Catch overflow in gas s_spaceAlan Modra2023-03-011-11/+21
| | | | | | | | | Also fix an error introduced in 1998 in reporting a zero count for negative counts. * read.c (s_space): Use unsigned multiply, and catch overflow. Correct order of tests for invalid repeat counts. Ensure ignored directives don't affect mri_pending_align.
* gas s_fill caused internal error in frag_newAlan Modra2023-03-011-10/+20
| | | | | | | Fix an internal error after "non-constant fill count for absolute section". * read.c (s_fill): Don't create frags after errors.