aboutsummaryrefslogtreecommitdiff
path: root/gas
AgeCommit message (Collapse)AuthorFilesLines
2023-03-20x86: VexVVVV is now merely a booleanJan Beulich1-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.
2023-03-20x86: re-work build_modrm_byte()'s register assignmentJan Beulich1-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.
2023-03-20Changed ld and gas BPF testsCupertino Miranda1-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.
2023-03-17gas: apply md_register_arithmetic also to unary '+'Jan Beulich2-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().
2023-03-17gas: expose flag_macro_alternate globallyJan Beulich5-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".
2023-03-17gas: use flag_mri directly in macro processingJan Beulich4-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.
2023-03-17gas: isolate macro_strip_at to macro.cJan Beulich3-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.
2023-03-17gas: drop function pointer parameter from macro_init()Jan Beulich3-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.
2023-03-16configure: add new target aarch64-*-nto*Clément Chigot1-0/+1
This target has its own ld emulation based on aarch64elf.em.
2023-03-16BPF relocations review / refactoringCupertino Miranda1-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.
2023-03-14Fix assembler documentation regarding data directives.Nick Clifton2-1/+31
PR 30206 * doc/as.texi (Pseudo Ops): Document that data directives such as .byte and .int are not intended for encoding instructions.
2023-03-14gas/read.c: init more staticsAlan Modra1-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.
2023-03-14gas .include and .incbinAlan Modra5-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.
2023-03-14gas/dwarf2dbg.c init more staticsAlan Modra1-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.
2023-03-14gas/ecoff.c: don't use zero struct copies to initAlan Modra1-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.
2023-03-14gas/compress-debug.c init all of strmAlan Modra1-4/+2
* compress-debug.c (compress_init): Clear all of strm.
2023-03-10Arm64/gas: drop redundant feature prereqsJan Beulich1-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.
2023-03-10Arm64/gas: add missing prereq featuresJan Beulich1-6/+6
A number of newer features are really SIMD or FP extensions, but don't have this properly specified.
2023-03-10x86: decouple broadcast type and bytes fieldsJan Beulich1-5/+6
Keep both representing exclusively what was parsed from input, to avoid the need for (potentially bogus) calculations when processing .insn.
2023-03-10x86-64: adjust REX-prefix part of SSE2AVX testJan Beulich2-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).
2023-03-10x86: move more disp processing out of md_assemble()Jan Beulich1-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.)
2023-03-10x86: use set_rex_vrex() also for short-form handlingJan Beulich1-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.
2023-03-10eh static dataAlan Modra3-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.
2023-03-09gas: allow frag address wrapping in absolute sectionAlan Modra1-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.
2023-03-03x86: use swap_2_operands() in build_vex_prefix()Jan Beulich1-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.
2023-03-03x86: drop redundant calculation of EVEX broadcast sizeJan Beulich1-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.
2023-03-03gas: default .debug section compression method adjustmentsJan Beulich1-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.
2023-03-03x86: avoid .byte in testcases where possibleJan Beulich4-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.
2023-03-02More bounds checking in macro_expandAlan Modra1-4/+4
* macro.c (macro_expand): Ensure input string buffer is not read past end.
2023-03-02Using .mri in assemblyAlan Modra1-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.
2023-03-01Catch overflow in gas s_spaceAlan Modra1-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.
2023-03-01gas s_fill caused internal error in frag_newAlan Modra1-10/+20
Fix an internal error after "non-constant fill count for absolute section". * read.c (s_fill): Don't create frags after errors.
2023-03-01Memory leak in gas do_repeatAlan Modra1-0/+1
* read.c (do_repeat): Free sb on error path.
2023-02-28[Aarch64] Add Binutils support for MECRichard Ball6-0/+61
This change supports MEC which is part of RME (Realm Management Extension).
2023-02-27gas/testsuite: adjust another test for case insensitive file systemsClément Chigot1-1/+1
As 1fafeaac8503eea2f61c3a35f0eef183b7e7cc65, "line.s" and "Line.s" are identical in case insensitive file systems. Thus, gas doesn't trigger an input file switch. gas/ChangeLog: * testsuite/gas/elf/dwarf-5-macro.s: Change Line.s to Line2.s.
2023-02-27Do not change the timestamp when updating the gas asconfig file.Benson Muite3-2/+9
PR 28909 * doc/local.mk (asconfig.texi): Use "cp -p" to preserve timestamps. * Makefile.in: Regenerate.
2023-02-24x86: allow to request ModR/M encodingJan Beulich5-9/+296
Several insns have a (typically shorter) non-ModR/M and a (typically longer) ModR/M encoding. In most cases the former is used by default. This isn't too dissimilar from register-only insns sometimes having two encoding forms. In those cases {load} or {store} can be used to control the encoding used. Extend this to ModR/M-less encodings which have a ModR/M counterpart (note that BSWAP hasn't). For insn reading and writing their (explicit) memory operand, both prefixes are honored; otherwise only the applicable one is. Note that for some forms of XCHG, {store} has already been performing this function, apparently as an unnoticed side effect of adding D to the template.
2023-02-24x86: MONITOR/MWAIT are not SSE3 insnsJan Beulich17-28/+140
These have their own CPUID bit and hence they should also have their own separate control.
2023-02-24x86-64: don't permit LAHF/SAHF with "generic64"Jan Beulich12-5/+111
The feature isn't universally available on 64-bit CPUs. Note that in i386-gen.c:isa_dependencies[] I'm only adding it to models where I'm certain the functionality exists. For Nocona and Core I'm uncertain in particular.
2023-02-24x86: have insns acting on segment selector values allow for consistent operandsJan Beulich7-1/+246
While MOV to/from segment register as well as selector storing insns already permit 32- and 64-bit GPR operands, selector loading insns and ARPL do not. Split templates accordingly.
2023-02-24x86: restrict insn templates accepting negative 8-bit immediatesJan Beulich5-52/+66
For shifts (but not ordinary rotates) and other cases where an immediate describes e.g. a bit count or position, allowing negative operands is at best confusing. An extreme example would be the two rotate-through-carry insns, where a negative value would _not_ mean rotating the corresponding number of bits in the other direction. To refuse such, give meaning to the combination of Imm8 and Imm8S in templates (so far these weren't used together anywhere). The issue was with smallest_imm_type() blindly setting .imm8 for signed numbers determined to fit in a byte. VPROT{B,W,D,Q} is a little special: The rotate count there is a signed quantity, so Imm8 is replaced by Imm8S. Adjust affected testcases accordingly as well. Another small adjustment to the testsuite is necessary: AAM and AAD were never sensible to use with 0xffffff90 operands. This should have been an error.
2023-02-22x86-64: LAR and LSL don't need REX.WJan Beulich2-24/+24
Just like we suppress emitting REX.W for e.g. MOV from/to segment register, there's also no need for it for LAR and LSL - these can only ever return 32-bit values and hence always zero-extend their results anyway. While there also drop the redundant Word from the first operand of the second template each - this is already implied by Reg16.
2023-02-22x86: optimize BT{,C,R,S} $imm,%regJan Beulich8-0/+115
In 64-bit mode BT can have REX.W or a data size prefix dropped in certain cases. Outside of 64-bit mode all 4 insns can have the data size prefix dropped in certain cases.
2023-02-21gas/testsuite: adjust a test for case insensitive file systemsClément Chigot2-7/+7
When dealing with case insensitive file systems, ".file line.s" and ".file Line.s" are identical and thus gas won't change the current input file. However, in line.l test, it's expecting to trigger an input file switch. As the second filename doesn't matter in it, change it to fit for those file systems. gas/ChangeLog: * testsuite/gas/elf/line.l: Change Line.s to Line2.s. * testsuite/gas/elf/line.s: Adjust output.
2023-02-17PR30046, power cmpi leads to unknown architectureAlan Modra1-7/+7
PowerPC ELF always uses bfd_arch_powerpc, so we shouldn't allow the gas -mpwr, -mpwr2 or -mpwrx options to choose bfd_arch_rs6000. Given the possible values of ppc_cpu, I think the as_fatal at the end of ppc_arch will never be reached, so it can be deleted and the code simplified a little. PR 30046 * config/tc-ppc.c (ppc_arch): Return bfd_arch_powerpc for ELF. Delete dead code.
2023-02-16Delete PROGRESS macrosAlan Modra3-16/+0
I don't see much point in cluttering the source with the PROGRESS macros, which of course do nothing at all with the definitions in progress.h. progress.h is unchanged apart from the copyright comment since commit d4d4c53c68f0 in 1994. binutils/ * ar.c: Don't include progress.h, or invoke PROGRESS macros. * nm.c: Likewise. * objcopy.c: Likewise. * objdump.c: Likewise. gas/ * as.h: Don't include progress.h. * as.c: Don't invoke PROGRESS macros. * write.c: Likewise. include/ * progress.h: Delete. ld/ * ldmain.c: Don't include progress.h, or invoke PROGRESS macros.
2023-02-16gas_initAlan Modra1-19/+20
Rename gas_late_init to plain gas_init, to reinforce the idea that this is where the bulk of gas initialisation belongs. Also reorder some initialisation. * as.c (gas_init): Rename from gas_late_init. Open output file and arrange for dump_statistics to be called here rather than in main. Create .gasversion. local symbol earlier, because we can.
2023-02-16RISC-V: as_warn() already emits a newlineJan Beulich1-1/+1
Therefore there shouldn't be any at the end of the format string.
2023-02-16x86/gas: replace inappropriate assertion when parsing registersJan Beulich1-6/+8
PR gas/30117 Once a symbol had its expression evaluated, the "segment" of the symbol may be reg_section if a register is merely involved in the expression, not just when the expression references a "plain" register. Therefore the first of the assertions put in place by 4d1bb7955a8b was too strict. Convert it to an if() to deal with situations like this one found by fuzzing: x=s s=%eax+0 y=s or $6,x In non-debug builds this also avoids potentially silently generating bad code.
2023-02-15gas: buffer_and_nest() needs to pass nul-terminated string to temp_ilp()Jan Beulich1-5/+5
In 7545aa2dd2eb ("gas: improve interaction between read_a_source_file() and s_linefile()") I didn't pay attention to the dual purpose of the nul character previously used. This was to a fair degree because of the open-coding of certain operations. Insert the earlier found line terminator instead of a hard-coded newline, and do so early in this special case (bypassing the later general insertion point). Plus properly use sb_terminate() to mark the end of the string. (Note that saved_eol_char was misnamed: Without calling sb_terminate() there's simply random data at that position in the buffer.)