aboutsummaryrefslogtreecommitdiff
path: root/gas
AgeCommit message (Collapse)AuthorFilesLines
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.)
2023-02-14gas: correct symbol name comparison in .startof./.sizeof. handlingJan Beulich3-2/+7
In 162c6aef1f3a ("gas: fold symbol table entries generated for .startof.() / .sizeof.()") I screwed up quite badly, inverting the case sensitive and case insensitive comparison functions.
2023-02-14gas: improve interaction between read_a_source_file() and s_linefile()Jan Beulich2-6/+10
read_a_source_file() would bump line numbers only when seeing a newline, whereas is_end_of_line[] indicates further end-of-line characters, in particular the nul character. s_linefile() attempts to compensate for the bump, but was too aggressive with this so far: It should only adjust when a newline ends the line. To facilitate such a check, the check for nothing else on the line needs to move ahead, which luckily is easily possible: The relevant two conditions match, and the function can simply return from the body of that earlier instance of the conditional. The more strict treatment in s_linefile() then requires an adjustment to buffer_and_nest()'s invocation of the function: The line terminator now needs to be a newline, not nul.
2023-02-13PR30120: fix x87 fucomp misassembledMichael Matz2-3/+20
this fixes the entry for 'fucomp' to use the correct Reg value (otherwise it's assembled as 'fucom').
2023-02-13stabs.c static stateAlan Modra3-46/+71
Move all the function local static state variables to file scope, in order to tidy memory on exit and to reinit everything for that annoying oss-fuzz. Also fix a couple memory leaks. * read.h (read_begin, read_end): Declare. * read.c (read_begin): Call stabs_begin. (read_end): Call stabs_end. * stabs.c (stabs_begin, stabs_end): New functions. (in_dot_func_p): Delete, use current_function_label instead. (cached_sec): Move from s_stab_generic. (last_asm_file, file_label_count): Move from generate_asm_file. (line_label_count, prev_lineno, prev_line_file): Move from stabs_generate_asm_lineno. (void_emitted_p): Move from stabs_generate_asm_func. (endfunc_label_count): Move from stabs_generate_asm_endfunc. (stabs_generate_asm_lineno): Simplify setting of prev_line_file. (stabs_generate_asm_func): Don't leak current_function_label. (stabs_generate_asm_endfunc): Likewise.
2023-02-13Split off gas init to functionsAlan Modra1-72/+87
With some slight reordering. * as.c (gas_early_init, gas_late_init): New functions, split.. (main): ..from here.
2023-02-11objdump -D of bss sections and -s with -jAlan Modra2-2/+2
There is some inconsistency between the behaviour of objdump -D and objdump -s, both supposedly operating on all sections by default. objdump -s ignores bss sections, while objdump -D dissassembles the zeros. Fix this by making objdump -D ignore bss sections too. Furthermore, "objdump -s -j .bss" doesn't dump .bss as it should, since the user is specifically asking to look at all those zeros. This change does find some tests that used objdump -D with expected output in bss-style sections. I've updated all the msp430 tests that just wanted to find a non-empty section to look at section headers instead, making the tests slightly more stringent. The ppc xcoff and spu tests are fixed by adding -j options to objdump, which makes the tests somewhat more lenient. binutils/ * objdump.c (disassemble_section): Ignore sections without contents, unless overridden by -j. (dump_section): Allow -j to override the default of not displaying sections without contents. * doc/binutils.texi (objdump options): Update -D, -s and -j description. gas/ * testsuite/gas/ppc/xcoff-tls-32.d: Select wanted objdump sections with -j. * testsuite/gas/ppc/xcoff-tls-64.d: Likewise. ld/ * testsuite/ld-msp430-elf/main-bss-lower.d, * testsuite/ld-msp430-elf/main-bss-upper.d, * testsuite/ld-msp430-elf/main-const-lower.d, * testsuite/ld-msp430-elf/main-const-upper.d, * testsuite/ld-msp430-elf/main-text-lower.d, * testsuite/ld-msp430-elf/main-text-upper.d, * testsuite/ld-msp430-elf/main-var-lower.d, * testsuite/ld-msp430-elf/main-var-upper.d: Expect -wh output. * testsuite/ld-msp430-elf/msp430-elf.exp: Use objdump -wh rather than objdump -D or objdump -d with tests checking for non-empty given sections. * testsuite/ld-spu/ear.d, * testsuite/ld-spu/icache1.d, * testsuite/ld-spu/ovl.d, * testsuite/ld-spu/ovl2.d: Select wanted objdump sections.
2023-02-10Local label checks in integer_constantAlan Modra1-9/+0
"Local labels are never absolute" says the comment. Except when they are. Testcase .offset 0: a=0b I don't see any particular reason to disallow local labels inside struct definitions, so delete the comment and assertions. * expr.c (integer_constant): Delete local label assertions.