Commit Graph

11866 Commits

Author SHA1 Message Date
Mark Harmstone
b3aa594daa gas: add .cv_ucomp and .cv_scomp pseudo-directives
Add .cv_ucomp and .cv_scomp pseudo-directives for object files for
Windows targets, which encode compressed CodeView integers according to
the algorithm in CVCompressData in
https://github.com/Microsoft/microsoft-pdb/blob/master/include/cvinfo.h.
This is essentially Microsoft's answer to the LEB128, though used in far
fewer places.

CodeView uses these to encode the "binary annotations" in the
S_INLINESITE symbol, which express the relationship between code offsets
and line numbers in inlined functions. This has to be done in the
assembler as GCC doesn't know how many bytes each instruction takes up.
There's no equivalent for this for MSVC or LLVM, as in both cases the
assembler and compiler are integrated.

.cv_ucomp represents an unsigned big-endian integer between 0 and 0x1fffffff,
taking up 1, 2, or 4 bytes:

Value between 0 and 0x7f:

	0aaaaaaa -> 0aaaaaaa (identity-mapped)

Value between 0x80 and 0x3fff:

	00aaaaaa bbbbbbbb -> 10aaaaaa bbbbbbbb

Value between 0x4000 and 0x1fffffff:
	000aaaaa bbbbbbbb ccccccccc dddddddd ->
	110aaaaa bbbbbbbb ccccccccc dddddddd

.cv_scomp represents a signed big-endian integer between -0xfffffff and
0xfffffff, encoded according to EncodeSignedInt32 in cvinfo.h. The
absolute value of the integer is shifted left one bit, the LSB set
for a negative value, and the result expressed as if it were a
.cv_ucomp: cv_scomp(x) = cv_ucomp((abs(x) << 1) | (x < 0 ? 1 : 0))
2024-11-13 03:11:35 +00:00
Matthieu Longo
23cd66ea0e aarch64: testsuite: remove hard-coded instruction addresses 2024-11-08 11:35:46 +00:00
Matthieu Longo
e308b2999c aarch64: remove redundant register type R_N
The register type R_N is redundant with R_ZR_SP. This patch removes it,
and replaces its usage by R_ZR_SP.
2024-11-08 11:35:46 +00:00
Matthieu Longo
a924330947 aarch64: constify unchanged char* arguments 2024-11-08 11:35:46 +00:00
Andre Vieira
cfbbd40333 arm, objdump: print obsolote warning when 26-bit set in instructions
Arm has obsoleted the 26-bit addressing mode. Diagnose this when disasembling
these instructions by printing OBSOLETE.
2024-11-08 10:06:57 +00:00
Andre Vieira
2c9d089c90 arm, objdump: Make objdump use bfd's machine detection to drive disassembly
For any arm elf target, disable an old piece of code that forced disassembly to
disassemble for 'unknown architecture' which once upon a time meant it would
disassemble ANY arm instruction.  This is no longer true with the addition of
Armv8.1-M Mainline, as there are conflicting encodings for different thumb
instructions.

BFD however can detect what architecture the object file was assembled for
using information in the notes section.  So if available, we use that,
otherwise we default to the old 'unknown' behaviour.

With the changes above code, a mode changing 'bx lr' assembled for armv4 with
the option --fix-v4bx will result in an object file that is recognized by bfd
as one for the armv4 architecture.  The disassembler now disassembles this
encoding as a BX even for Armv4 architectures, but warns the user when
disassembling for Armv4 that this instruction is only valid from Armv4T
onwards.

Remove the unused and wrongfully defined ARM_ARCH_V8A_CRC, and
define and use a ARM_ARCH_V8R_CRC to make sure instructions enabled by
-march=armv8-r+crc are disassembled correctly.

Patch up some of the tests cases, see a brief explanation for each below.

inst.d:
This test checks the assembly & disassembly of basic instructions in armv3m. I
changed the expected behaviour for teqp, cmnp cmpp and testp instructions to
properly print p when disassembling, whereas before, in the 'unknown' case it
would disassemble these as UNPREDICTABLE as they were changed in later
architectures.

nops.d:
Was missing an -march, added one to make sure we were testing the right
behavior of NOP<c> instructions.

unpredictable.d:
Was missing an -march, added armv6 as that reproduced the behaviour being
tested.
2024-11-08 10:06:38 +00:00
Andre Simoes Dias Vieira
b6ccbbd5d3 arm: Skip two failing tests for wince & pe targets
We don't seem to support any m-profile assembly/disassembly tests for wince or
pe, so skipping the pacbti one too.

The pr29494 test needs to be skipped because it uses assembly syntax that is
not supported in wince/pe like for instance eabi_attribute directives.
2024-11-07 15:50:52 +00:00
Peter Bergner
56fe851ced PowerPC: Merge rfc2655 and rfc2656 test cases into one future test case
gas/
	* testsuite/gas/ppc/rfc02655.[ds]: Rename from this...
	* testsuite/gas/ppc/future.[ds]: ... to this.
	* testsuite/gas/ppc/rfc02656.[ds]: Delete.  Move tests to future.[ds].
	* testsuite/gas/ppc/ppc.exp: Update for file name changes.
2024-11-06 13:37:10 -06:00
Nelson Chu
6c4f88a10e gas/doc/riscv: Fixed misaligned instruction table
gas/
	* doc/c-riscv.texi: Fixed misaligned instruction table.
2024-10-31 11:45:57 +08:00
Jan Beulich
5330d85af1 x86: add a helper to copy insn operand info
We're doing such in fairly many places, and yet more are likely to
appear; centralize the logic, much like we already have
swap_2_operands().

While there also correct mis-indentation in adjacent code in
process_operands().
2024-10-30 12:13:22 +01:00
Jan Beulich
a3db0f57df x86/APX: support JMPABS also in assembler
Without this APX support isn't really complete.

For Intel syntax displacement form is needed, such that symbolic
operands won't need prefixing by "offset". (The other form is actually
not used at all in Intel syntax.)

For the record: To restrict displacement form to Intel syntax is not
something I actually agree with.
2024-10-30 12:12:54 +01:00
Jan Beulich
d0a9378d98 x86/APX: squash REX prefix when REX2 is being emitted
We should not (silently) emit a REX prefix ahead of a REX2-encoded insn;
such encodings are illegal. Best we can do is fold the REX bits into the
REX2 prefix, and then zap the REX one from i.prefix[].
2024-10-30 12:12:24 +01:00
Lulu Cai
287938873c LoongArch: Corrected to GNU style code 2024-10-29 15:56:52 +08:00
Jan Beulich
c1a4b47e2a gas: make fix_new_exp()'s "exp" parameter const
This really should be only an input; in particular it looks bogus that
O_add expressions are even altered. That altering and the recursion are
even pointless: Once expanding what the inner call would do (with
O_symbol) it becomes clear that this is no different than the default
case. Simplify the code accordingly, retaining the comment.
2024-10-29 08:08:29 +01:00
Jan Beulich
641cf0e2c0 gas: constify md_{short,long}opts and md_longopts_size
First of all make the declarations globally visible, such that producer
and consumer actually share them.

For the latter two simply add const (as PPC already had it,), while for
the former achieve the effect by converting to an array: There's no need
for the extra level of indirection.
2024-10-29 08:08:02 +01:00
Kito Cheng
a8ff55b5b4 RISC-V: Update the doc to match ISA manual
ISA manual use funct* rather than func*[1] (e.g. funct7 rather than func7),
and I realized that may something I typo at beginning when I write the patch
for `.insn` support...:P

[1] https://github.com/riscv/riscv-isa-manual/blob/main/src/rv32.adoc#integer-register-register-operations
2024-10-29 13:06:17 +08:00
Jim Lin
917ed12066 RISC-V: Fix typo in gas/testsuite/gas/riscv/mapping.s
gas/
        * gas/riscv/mapping.s: Fix typo.
        * gas/riscv/mapping-dis.d: Fix typo.
        * gas/riscv/mapping-symbols.d. Fix typo.
2024-10-28 11:13:44 +08:00
Alan Modra
86b26b453f Replace uses of asprintf with xasprintf
xasprintf has a nicer interface and behaves like xmalloc as far as
memory is concerned, ie. no need to check a return status and the
program exits with an error on OOM.

binutils/
	* dwarf.c (load_debug_sup_file): Replace asprintf with xasprintf.
	* nm.c (get_elf_symbol_type, get_coff_symbol_type): Likewise.
	* objdump.c (dump_ctf_indent_lines): Likewise.
	* readelf.c (display_lto_symtab, dump_ctf_indent_lines): Likewise.
	* windres.c (main): Likewise.
	* configure.ac: Remove asprintf from AC_CHECK_DECLS.
	* config.in: Regenerate.
	* configure: Regenerate.
gas/
	* config/tc-kvx.c (kvx_emit_single_noop): Simplify.
	* config/tc-riscv.c (md_assemblef): Replace asprintf with xasprintf.
	* read.c (s_nop, do_s_func): Likewise.
	* stabs.c (stabs_generate_asm_func): Likewise.
	(stabs_generate_asm_endfunc): Likewise.
	* configure.ac: Remove asprintf from AC_CHECK_DECLS.
	* config.in: Regenerate.
	* configure: Regenerate.
ld/
	* ldlang.c (lang_leave_overlay_section): Replace xmalloc+sprintf
	with xasprintf.  Localise vars.
	* lexsup.c (parse_args): Replace asprintf with xasprintf.
	* pe-dll.c (make_head, make_tail, make_one): Likewise.
	(make_singleton_name_thunk, make_import_fixup_entry): Likewise.
	(make_runtime_pseudo_reloc): Likewise.
	(pe_create_runtime_relocator_reference): Likewise.
	* configure.ac: Remove asprintf from AC_CHECK_DECLS.
	* config.in: Regenerate.
	* configure: Regenerate.
2024-10-24 17:58:00 +10:30
Lulu Cai
3790b9f7ff LoongArch: Force relocation for every reference to the global offset table
Local absolute symbols are resolved at assembly stage and the symbol
value is placed in the relocation addend. But non-zero addend will
cause an assertion failure during linking.

Forces emission of relocations to defer resolution of local abs symbols
until link time.

bfd/

        * elfnn-loongarch.c (loongarch_elf_relax_section): Determine
          absolute symbols in advance to avoid ld crash.

gas/

        * config/tc-loongarch.c (loongarch_force_relocation): New
          function to force relocation.
        * config/tc-loongarch.h (TC_FORCE_RELOCATION): New macros
          to force relocation.
        (loongarch_force_relocation): Function declaration.
        * testsuite/gas/loongarch/localpic.d: New test.
        * testsuite/gas/loongarch/localpic.s: New test.
2024-10-22 12:01:41 +08:00
MayShao-oc
8f0d880434 x86: Support x86 ZHAOXIN GMI instructions
gas/ChangeLog:

	* NEWS: Support ZHAOXIN GMI instructions.
	* config/tc-i386.c: Add gmi.
	* doc/c-i386.texi: Document gmi.
	* testsuite/gas/i386/i386.exp: Add gmi test.
	* testsuite/gas/i386/gmi.d: Ditto.
	* testsuite/gas/i386/gmi.s: Ditto.

opcodes/ChangeLog:

	* i386-dis.c: New comment.
	* i386-gen.c: Add gmi.
	* i386-opc.h (CpuGMI): New.
	* i386-opc.tbl: Add Zhaoxin GMI instructions.
	* i386-tbl.h: Regenerated.
	* i386-mnem.h: Ditto.
	* i386-init.h: Ditto.
2024-10-18 15:45:11 +08:00
Liwei Xu
3bac89e65f Support Intel AVX10.2 convert instructions
In this patch, we will support AVX10.2 convert instructions. All
of them are new instruction forms.

Among all the instructions, vcvtbiasph2[b,h]f8[,s] needs extra care.
Since Operand 2 could indicate memory size, we do not need suffix
under ATTmode. However, we could not fold all three templates but only
XMM/YMM since the dst operand size are the same for them. Also, a new
iterator <cvt8> is added to reduce redundancy.

gas/
	* testsuite/gas/i386/i386.exp: Add AVX10.2 tests.
	* testsuite/gas/i386/x86-64.exp: Ditto.
	* testsuite/gas/i386/avx10_2-256-cvt-intel.d: New.
	* testsuite/gas/i386/avx10_2-256-cvt.d: Ditto.
	* testsuite/gas/i386/avx10_2-256-cvt.s: Ditto.
	* testsuite/gas/i386/avx10_2-512-cvt-intel.d: Ditto.
	* testsuite/gas/i386/avx10_2-512-cvt.d: Ditto.
	* testsuite/gas/i386/avx10_2-512-cvt.s: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-256-cvt-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-256-cvt.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-256-cvt.s: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-512-cvt-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-512-cvt.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-512-cvt.s: Ditto.

opcodes/
	* i386-dis-evex-prefix.h: Add PREFIX_EVEX_0F3874,
	PREFIX_EVEX_MAP5_18, PREFIX_EVEX_MAP5_1B,
	PREFIX_EVEX_MAP5_1E and PREFIX_EVEX_MAP5_74.
	* i386-dis-evex.h: Add table pass for AVX10.2
	instructions.
	* i386-dis.c (MOD_EVEX_0F38B1): New.
	(PREFIX_EVEX_0F3874): Ditto.
	(PREFIX_EVEX_MAP5_18): Ditto.
	(PREFIX_EVEX_MAP5_1B): Ditto.
	(PREFIX_EVEX_MAP5_1E): Ditto.
	(PREFIX_EVEX_MAP5_74): Ditto.
	* i386-opc.tbl: Add AVX10.2 instructions.
	* i386-mnem.h: Regenerated.
	* i386-tbl.h: Ditto.

Co-authored-by: Kong Lingling <lingling.kong@intel.com>
Co-authored-by: Haochen Jiang <haochen.jiang@intel.com>
2024-10-16 10:25:35 +08:00
Cui, Lili
9c5b0ee4d5 x86: Refine instruction check in x86_check_tls_relocation
gas/ChangeLog:

        * config/tc-i386.c
	(x86_check_tls_relocation): Refine instruction check.
2024-10-15 14:17:57 +08:00
Haochen Jiang
990c7d444c x86/testsuite: Rename AVX10.2 media testcases
Change these testcase name to make them clearer.

gas/ChangeLog:

	* testsuite/gas/i386/avx10_2-256-1-intel.d: Renamed to...
	* testsuite/gas/i386/avx10_2-256-media-intel.d: ...this.
	* testsuite/gas/i386/avx10_2-256-1.d: Renamed to...
	* testsuite/gas/i386/avx10_2-256-media.d: ...this.
	* testsuite/gas/i386/avx10_2-256-1.s: Renamed to...
	* testsuite/gas/i386/avx10_2-256-media.s: ...this.
	* testsuite/gas/i386/avx10_2-512-1-intel.d: Renamed to...
	* testsuite/gas/i386/avx10_2-512-media-intel.d: ...this.
	* testsuite/gas/i386/avx10_2-512-1.d: Renamed to...
	* testsuite/gas/i386/avx10_2-512-media.d: ...this.
	* testsuite/gas/i386/avx10_2-512-1.s: Renamed to...
	* testsuite/gas/i386/avx10_2-512-media.s: ...this.
	* testsuite/gas/i386/x86-64-avx10_2-256-1-intel.d: Renamed to...
	* testsuite/gas/i386/x86-64-avx10_2-256-media-intel.d: ...this.
	* testsuite/gas/i386/x86-64-avx10_2-256-1.d: Renamed to...
	* testsuite/gas/i386/x86-64-avx10_2-256-media.d: ...this.
	* testsuite/gas/i386/x86-64-avx10_2-256-1.s: Renamed to...
	* testsuite/gas/i386/x86-64-avx10_2-256-media.s: ...this.
	* testsuite/gas/i386/x86-64-avx10_2-512-1-intel.d: Renamed to...
	* testsuite/gas/i386/x86-64-avx10_2-512-media-intel.d: ...this.
	* testsuite/gas/i386/x86-64-avx10_2-512-1.d: Renamed to...
	* testsuite/gas/i386/x86-64-avx10_2-512-media.d: ...this.
	* testsuite/gas/i386/x86-64-avx10_2-512-1.s: Renamed to...
	* testsuite/gas/i386/x86-64-avx10_2-512-media.s: ...this.
	* testsuite/gas/i386/i386.exp: Change testcase name.
	* testsuite/gas/i386/x86-64.exp: Ditto.
2024-10-15 09:48:50 +08:00
Jan Beulich
4444dac517 ia64/ELF: fix HPUX testsuite fallout
... from 1f1b5e506b ("bfd/ELF: restrict file alignment for object
files"), as noticed / reported by Alan.
2024-10-14 14:38:23 +02:00
Jan Beulich
b03815327a gas: drop SKIP_WHITESPACE_AFTER_NAME()
Exclusively all users should use restore_line_pointer() instead, at
which point SKIP_WHITESPACE() suffices as a check afterwards.
2024-10-14 14:37:29 +02:00
Lulu Cai
22c6209285 LoongArch: Fixed R_LARCH_[32/64]_PCREL generation bug
The enum BFD_RELOC_[32/64] was mistakenly used in the macro instead
of the relocation in fixp. This can cause the second relocation
of a pair to be deleted when -mthin-add-sub is enabled. Apply the
correct macro to fix this.

Also sets the initial value of -mthin-add-sub.
2024-10-14 09:15:16 +08:00
Jan Beulich
d55d7b35c4 x86: bring 64-bit-only cmdline option handling in sync
--64 and --x32 are already suppressed in --help output when BFD64 is not
defined. Also avoid recognizing these options in such configurations.
2024-10-11 08:20:33 +02:00
Jan Beulich
1f1b5e506b bfd/ELF: restrict file alignment for object files
While for executables properly aligning sections within the file can be
quite relevant, the same is of pretty little importance for relocatable
object files. Avoid passing "true" into
_bfd_elf_assign_file_position_for_section() when dealing with object
files, but compensate minimally by applying log_file_align in such
cases as a cap to the alignment put in place.
2024-10-11 08:19:34 +02:00
Haochen Jiang
873e7b6cf6 Support Intel AVX10.2 media instructions
In disassembler part, for vnni instructions, we extended previous
VEX part using %XE in disassembler to promote them to EVEX by reusing
the original VEX table. For vmpsadbw, we will also use %XE. However,
it is hard to reuse the VEX table, so we are using new ones.

In assmbler part, we put the vnni table entries with previous vnni
instructions since they are just promotion from AVX-VNNI-INT{8,16}.
Since we will prefer VEX encoding, we need to use the different table
order in template <vnni>, which prefers EVEX due to earlier introduction
for AVX512_VNNI than AVX_VNNI. This means a new <vnni>. For vdpphps
and vmpsadbw, we put them at the end of the table, with future AVX10.2
instructions.

Nit: I will remove the arch requirement for avx_vnni_int{8,16} in
evex-promote testcases after AVX10.2 implies AVX-VNNI-INT{8,16}.

gas/Changelog:

	* testsuite/gas/i386/i386.exp: Add AVX10.2 tests.
	* testsuite/gas/i386/x86-64.exp: Ditto.
	* testsuite/gas/i386/avx10_2-256-1-intel.d: New.
	* testsuite/gas/i386/avx10_2-256-1.d: Ditto.
	* testsuite/gas/i386/avx10_2-256-1.s: Ditto.
	* testsuite/gas/i386/avx10_2-512-1-intel.d: Ditto.
	* testsuite/gas/i386/avx10_2-512-1.d: Ditto.
	* testsuite/gas/i386/avx10_2-512-1.s: Ditto.
	* testsuite/gas/i386/avx10_2-promote.d: Ditto.
	* testsuite/gas/i386/avx10_2-promote.s: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-256-1-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-256-1.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-256-1.s: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-512-1-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-512-1.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-512-1.s: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-promote.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-promote.s: Ditto.

opcodes/Changelog:

	* i386-dis-evex-prefix.h: Adjust PREFIX_EVEX_0F3852.
	Add PREFIX_EVEX_0F3A42_W_0.
	* i386-dis-evex-w.h: Adjust EVEX_W_0F3A42.
	* i386-dis-evex.h: Add table pass for AVX10.2
	instructions.
	* i386-dis.c: Adjust PREFIX_VEX_0F3850_W_0, PREFIX_VEX_0F3851_W_0,
	PREFIX_VEX_0F38D2_W_0 and PREFIX_VEX_0F38D3_W_0.
	* i386-opc.tbl: Add AVX10.2 instructions.
	* i386-mnem.h: Regenerated.
	* i386-tbl.h: Ditto.

Co-authored-by: Lili Cui <lili.cui@intel.com>
2024-10-11 10:38:27 +08:00
Andreas Krebbel
a98a6fa2d8 s390: Add arch15 instructions
opcodes/
	* s390-mkopc.c (main) Accept arch15 as CPU string.
	* s390-opc.txt: Add arch15 instructions.

include/
	* opcode/s390.h (enum s390_opcode_cpu_val): Add
	S390_OPCODE_ARCH15.

gas/
	* config/tc-s390.c (s390_parse_cpu): New entry for arch15.
	* doc/c-s390.texi: Document arch15 march option.
	* doc/as.texi: Likewise.
	* testsuite/gas/s390/s390.exp: Run the arch15 related tests.
	* testsuite/gas/s390/zarch-arch15.d: Tests for arch15
	instructions.
	* testsuite/gas/s390/zarch-arch15.s: Likewise.

Signed-off-by: Andreas Krebbel <krebbel@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
2024-10-10 12:09:40 +02:00
Xiao Zeng
542d8137f9 RISC-V: Fix implicit dependency of Zabha and Zacas
1 Zabha depends on Zaamo:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/zabha.adoc>

2 Zacas depends on Zaamo:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/zacas.adoc>

bfd/ChangeLog:

	* elfxx-riscv.c: Zabha and Zacas implicitly depend on Zaamo.

gas/ChangeLog:

	* testsuite/gas/riscv/imply.d: Updated.

Signed-off-by: Xiao Zeng <zengxiao@eswincomputing.com>
2024-10-08 11:45:28 +08:00
Jan Beulich
85ef4a5ed8 gas: hide emulation struct format_ops instances when not needed
Most targets don't even support emulations, so this data (and certain
functions) are entirely dead code for them.
2024-10-04 09:42:45 +02:00
Jan Beulich
e9285aa046 x86: prune OBJ_MAYBE_... uses
With the removal of emulations, OBJ_MAYBE_... can no longer be defined.
Tidy code wherever they're used, which also includes the dropping of
most IS_ELF and uses and checks of OUTPUT_FLAVOR.

Where touching such constructs anyway, also drop TE_PEP checks when used
together with TE_PE ones (the former implies the latter).
2024-10-04 09:42:13 +02:00
Jan Beulich
46f44aa700 x86: drop largely defunct gas emulations
Both ELF and COFF have various sub-flavors, each of which would then
require its own emulation: Right now when configuring a COFF/PE
secondary target (with perhaps an ELF primary one), one gets plain COFF
emulation rather than COFF/PE one.

As such a multitude of emulations would be unwieldy (and likely fragile)
drop gas emulations altogether instead.
2024-10-04 09:41:38 +02:00
Jan Beulich
87d2a20152 include: de-duplicate i386.h and x86_64.h
Move common definitions to a new x86.h, thus allowing gas'es obj-coff.h
to include just that, getting rid of a TE_PEP compile-time dependency.
2024-10-04 09:39:36 +02:00
Jan Beulich
d6b42c3035 gas: drop generate_asm_lineno emulation hook
It's not wired up, so can't be used.
2024-10-04 09:38:05 +02:00
Jan Beulich
ccaa95c887 gas: don't use COFF-specific SF_SET_LOCAL() directly from read.c
Make this a proper obj-format hook instead.
2024-10-04 09:37:37 +02:00
Jan Beulich
833c28eefb gas/dw2gencfi: correct .sframe section conditional
While originally this was in preparation of a subsequent change making
SUPPORT_FRAME_LINKONCE potentially dependent on a global variable, the
construct appears unlikely to have been correct in the first place: The
variable would have been passed reliably uninitialized when
SUPPORT_FRAME_LINKONCE is build-time true.

While there correct indentation of the parameters passed to
get_cfi_seg().
2024-10-04 09:36:56 +02:00
Jan Beulich
c41215350b gas: put emul decls in emul.h
The individual struct emulation instances shouldn't be declared in a .c
file; it and the producers of the symbols want to both see the
declarations, so declarations and definitions don't go out of sync. Move
these declarations to emul.h.

While there also adjust the conditional around this_format: That symbol
is never #define-d anywhere, and it's needed only when USE_EMULATIONS is
defined. (Really, when obj-multi isn't in use, it also is effectively
only ever written to.)
2024-10-04 09:36:24 +02:00
Jan Beulich
2ced0b79da gas: drop unused fields from struct emulation
Neither .match not .bfd_name appear to ever have been used in the last
about 25 years. Purge them.
2024-10-04 09:35:56 +02:00
Alan Modra
444ae19249 segv in read_a_source_file
On some paths through read_a_source file, "s" may not be set.

	* read.c (read_a_source_file): Correct code ignoring comment.
2024-10-01 08:35:00 +09:30
Alan Modra
eb5903a8e2 gas buffer overflow with --listing-rhs-width
With listings enabled, gas keeps a small cache of source lines.  They
are stored in buffers of size LISTING_RHS_WIDTH, ie. 100.  Given
listing-rhs-width larger than 100 it is of course possible to overflow
the buffer.  Fix that by allocating as needed.  We could allocate all
buffers on the first call to print_source using listing_rhs_width, but
I chose not to do that in case some future assembly directive allows
changes to listing_rhs_width similarly to the way paper_width can
change during assembly.
2024-09-28 15:47:47 +09:30
Jan Beulich
dfa9ee01a4 x86: fix Solaris gas testsuite run
Commits 8015b1b0c1 ("x86-64: Never make R_X86_64_GOT64 section
relative"), d774bf9b36 ("x86: Add tls check in gas"), and
1b714c14e4 ("x86: Turn PLT32 to PC32 only for PC-relative
relocations") all should have adjusted the Solaris counterpart of the
reloc64 test as well.
2024-09-27 11:41:27 +02:00
Jan Beulich
9a788db16a RISC-V: odd data padding vs mapping symbols
Odd data padding has a $d label inserted at its beginning. When a $x...
label is removed instead, a replacement is inserted after the padding.
The same, however, needs to also happen when there's no $x to replace.
2024-09-27 11:41:00 +02:00
Jan Beulich
784e2ef54b RISC-V: correct alignment directive handling for text sections
.insn or data emitted inside text sections can lead to positions not
being at insn granularity. In such situations using alignment
directives should reliably enforce the requested alignment.
Specifically requests to align back to insn granularity may not be
ignored (where, as a subcase thereof, the ordering of ".option norvc"
and e.g. ".p2align 2" should not matter; so far the alignment directive
needs to come first to have any effect). Similarly ahead of emitting
NOPs alignment first needs to be forced back to insn granularity.

The new testcases actually point out a corner case issue in the
disassembler as well, which is being corrected at the same time: We
don't want to print "0x" without any subsequent digits.
2024-09-27 11:40:22 +02:00
Jan Beulich
ca6b6f9d6e x86: optimize {,V}INSERTPS with certain immediates
They are equivalent to simple moves or xors, which are up to 3 bytes
shorter to encode (and maybe/likely also cheaper to execute).
2024-09-27 11:23:12 +02:00
Jan Beulich
f079b0c4b2 x86: optimize {,V}EXTRACT{F,I}{128,32x{4,8},64x{2,4}} with immediate 0
They, too, are equivalent to simple moves, which are up to 3 bytes
shorter to encode (and maybe also cheaper to execute).
2024-09-27 11:22:34 +02:00
Jan Beulich
afd5b33bc7 x86: optimize {,V}EXTRACTPS with immediate 0
They are equivalent to simple moves, which are up to 2 bytes shorter to
encode (and maybe also cheaper to execute).
2024-09-27 11:21:51 +02:00
Jan Beulich
0fcb4bfcd4 x86: correct {,V}PEXTR{D,Q} optimization
A possible relocation associated with a memory operand also needs
moving.
2024-09-27 11:20:37 +02:00
Haochen Jiang
24979a6d5a x86/testsuite: Refine AVX10.2 rounding testcases
Using hard byte code is not a good idea in dump file. Add a label
for intel syntax test check to avoid that.

gas/ChangeLog:

	* testsuite/gas/i386/avx10_2-rounding-intel.d: Use label for
	test split.
	* testsuite/gas/i386/avx10_2-rounding.s: Add label to avoid
	hard coding in dump file.
2024-09-26 11:03:44 +08:00