Commit Graph

11443 Commits

Author SHA1 Message Date
Lulu Cai
f35f0ceddf LoongArch: Add gas testsuit for lsx/lasx instructions
Test the LSX/LASX instructions. Only LA64 supports
these instructions.
2024-03-05 19:55:31 +08:00
Lulu Cai
10b6919c1f LoongArch: Add gas testsuit for lbt/lvz instructions
Test the LBT/LVZ instructions. Only LA64 supports
these instructions.
2024-03-05 19:55:31 +08:00
Lulu Cai
30dbbdc55a LoongArch: Add gas testsuit for alias instructions
Test the alias instructions.
2024-03-05 19:55:31 +08:00
Jens Remus
5c97cb1c80 s390: Be more verbose about missing operand type
Provide expected operand type in s390-specific assembler operand parsing
error message:

"error: operand <operand-number>: missing <operand-type> operand"

With <operand-type> being one of:
- base register
- displacement
- [vector] index register
- length
- access register
- control register
- floating-point register
- general-purpose register
- vector register
- [un]signed number

gas/
	* config/tc-s390.c: Provide missing operand type in error
	message.
	* testsuite/gas/s390/zarch-base-index-0-err.l: Update test case
	result validation patterns to operand number in operand syntax
	error messages.
	* testsuite/gas/s390/zarch-omitted-base-index-err.l: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
ac6582253b s390: Provide operand number in assembler warning and error messages
Prepend the operand number "operand %d:" to the s390-specific assembler
operand parsing warning and error messages.

While at it reword the custom operand out of range error message text to
be closer to the one used by as_bad_value_out_of_range(). Additionally
reword the invalid FPR pair warning message to make it nicer.

gas/
	* config/tc-s390.c: Print operand number in error messages.
	* testsuite/gas/s390/zarch-base-index-0-err.l: Update test case
	verification patterns to accept syntax error messages now
	containing the operand number.
	* testsuite/gas/s390/zarch-omitted-base-index-err.l: Likewise.
	* testsuite/gas/s390/zarch-warn-areg-zero.l: Likewise.
	* testsuite/gas/s390/zarch-z9-109-err.l: Likewise.
	* testsuite/gas/s390/zarch-z900-err.l: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
aacf780bca s390: Allow to explicitly omit base register operand in assembly
The base register operand B may be omitted in D(B) by coding D and in
D(L,B) by coding D(L). The index register operand X may be omitted in
D(X,B) by coding D(B) or explicitly omitted by coding D(,B). In both
cases the omitted base register operand value defaults to zero.

Allow to explicitly omit the base register operand B in D(X,B) and
D(L,B) by coding D(X,) and D(L,). Default the omitted base register
operand value to zero.

gas/
	* config/tc-s390.c: Allow to explicitly omit the base register
	operand in assembly.
	* NEWS: Mention that the base register now may be omitted on
	s390.
	* gas/testsuite/gas/s390/zarch-base-index-0.s: Update test cases
	for change to allow to explicitly omit the base register
	operand in assembly.
	* gas/testsuite/gas/s390/zarch-base-index-0.d: Likewise.
	* gas/testsuite/gas/s390/zarch-base-index-0-err.s: Likewise.
	* gas/testsuite/gas/s390/zarch-base-index-0-err.l: Likewise.
	* gas/testsuite/gas/s390/zarch-omitted-base-index.s: Likewise.
	* gas/testsuite/gas/s390/zarch-omitted-base-index.d: Likewise.
	* gas/testsuite/gas/s390/zarch-omitted-base-index-err.s:
	Likewise.
	* gas/testsuite/gas/s390/zarch-omitted-base-index-err.l:
	Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
75a28d1a97 s390: Print base register 0 as "0" in disassembly
Base and index register 0 have no effect in address computation:

"A value of zero in the B [base] or X [index] field specifies that no
base or index is to be applied, and, thus, general register 0 cannot be
designated as containing a base address or index."
IBM z/Architecture Principles of Operation [1], chapter "Organization",
section "General Registers".

Index register 0 is omitted in the s390 disassembly. Base register 0 is
omitted in D(B), D(L,B) and D(X,B) - the latter only if the index
register is zero.

To make it more apparent print base register 0 as "0" instead of "%r0",
whenever it would still be printed in the disassembly.

[1]: IBM z/Architecture Principles of Operation, SA22-7832-13,
     https://publibfp.dhe.ibm.com/epubs/pdf/a227832d.pdf

opcodes/
	* s390-dis.c: Print base register 0 as "0" in disassembly.

binutils/
	* NEWS: Mention base register 0 now being printed as "0" in s390
	disassembly.

gas/
	* testsuite/gas/s390/zarch-base-index-0.d: Update test case
	output verification patterns to accept "0" as base base
	register due to disassembler output format change.
	* gas/testsuite/gas/s390/zarch-omitted-base-index.d: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
dfa4ac9728 s390: Warn when register name type does not match operand
Print a warning message when the register type of a specified register
name does not match with the operand's register type:

operand {#}: expected {access|control|floating-point|general|vector}
  register name [as {base|index} register]

Introduce a s390-specific assembler option "warn-regtype-mismatch"
with the values "strict", "relaxed", and "no" as well as an option
"no-warn-regtype-mismatch" which control whether the assembler
performs register name type checks and generates above warning messages.

warn-regtype-mismatch=strict:
  Perform strict register name type checks.

warn-regtype-mismatch=relaxed:
  Perform relaxed register name type checks, which allow floating-point
  register (FPR) names %f0 to %f15 to be specified as argument to vector
  register (VR) operands and vector register (VR) names %v0 to %v15 to
  be specified as argument to floating-point register (FPR) operands.
  This is acceptable as the FPRs are embedded into the lower halves of
  the VRs. Make "relaxed" the default, as GCC generates assembler code
  using FPR and VR interchangeably, which would cause assembler warnings
  to be generated with "strict".

warn-regtype-mismatch=no:
no-warn-regtype-mismatch:
  Disable any register name type checks.

Tag .insn pseudo mnemonics as such, to skip register name type checks
on those. They need to be skipped, as there do not exist .insn pseudo
mnemonics for every possible operand register type combination. Keep
track of the currently parsed operand number to provide it as reference
in warning messages.

To verify that the introduction of this change does not unnecessarily
affect the compilation of existing code the GNU Binutils, GNU C Library,
and Linux Kernel have been build with the new assembler, verifying that
the assembler did not generate any of the new warning messages.

gas/
	* config/tc-s390.c: Handle new assembler options
	"[no]warn-regtype-mismatch[=strict|relaxed|no". Annotate
	parsed register expressions with register type. Keep track of
	operand number being parsed. Print warning message in case of
	register type mismatch between instruction operand and parsed
	register expression.
	* doc/as.texi: Document new s390-specific assembler options
	"[no-]warn-regtype-mismatch[=strict|relaxed|no]".
	* NEWS: Mention new s390-specific register name type checks and
	related assembler option "warn-regtype-mismatch=strict|
	relaxed|no".
	* testsuite/gas/s390/s390.exp: Add test cases for new assembler
	option "warn-regtype-mismatch={strict|relaxed}".
	* testsuite/gas/s390/esa-g5.s: Fix register types in tests for
	didbr, diebr, tbdr, and tbedr.
	* testsuite/gas/s390/zarch-z13.s: Fix register types in tests
	for vgef, vgeg, vscef, and vsceg.
	* testsuite/gas/s390/zarch-warn-regtype-mismatch-strict.s:
	Tests for assembler option "warn-regtype-mismatch=strict".
	* testsuite/gas/s390/zarch-warn-regtype-mismatch-strict.l:
	Likewise.
	* gas/testsuite/gas/s390/zarch-warn-regtype-mismatch-relaxed.s:
	Tests for assembler option "warn-regtype-mismatch=relaxed".
	* gas/testsuite/gas/s390/zarch-warn-regtype-mismatch-relaxed.l:
	Likewise.
	* gas/testsuite/gas/s390/zarch-omitted-base-index-err.s: Update
	test cases for assembler option "warn-regtype-mismatch"
	defaulting to "relaxed".
	* testsuite/gas/s390/zarch-omitted-base-index-err.l: Likewise.

include/
	* opcode/s390.h (S390_INSTR_FLAG_PSEUDO_MNEMONIC): Add
	instruction flag to tag .insn pseudo-mnemonics.

opcodes/
	* s390-opc.c (s390_opformats): Tag .insn pseudo-mnemonics as
	such.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
0a4b39672b s390: Revise s390-specific assembler option descriptions
Reorder, reword, and complete the s390-specific option descriptions.
Align the formatting of s390-specific assembler options to that of the
general assembler options in "as --help".

While at it change a warning message to use the term "z/Architecture"
instead of the deprecated "esame" (ESA Modal Extensions or ESAME) one.

gas/
	* config/tc-s390.c: Revise s390-specific assembler option
	descriptions.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
c3d72d73f8 s390: Add test case for disassembler option warn-areg-zero
gas/
	* testsuite/gas/s390/s390.exp: Add test cases for s390-specific
	assembler option "warn-areg-zero".
	* testsuite/gas/s390/zarch-warn-areg-zero.s: Likewise.
	* testsuite/gas/s390/zarch-warn-areg-zero.l: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
bd0ee1ee41 s390: Add test cases for base/index register 0
While at it add comments to logic to omit base and/or index register 0
in s390 disassembly.

opcodes/
	* s390-dis.c: Add comments related to omitting base and/or index
	register 0 in disassembly.
gas/
	* testsuite/gas/s390/s390.exp: Add test cases for base and/or
	index register 0.
	* testsuite/gas/s390/zarch-base-index-0.s: Add test cases for
	base and/or index register 0.
	* testsuite/gas/s390/zarch-base-index-0.d: Likewise.
	* testsuite/gas/s390/zarch-base-index-0-err.s: Add error test
	cases for base and/or index register 0.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
a0af167da2 s390: Add comments to assembler operand parsing logic
gas/
	* config/tc-s390.c: Add comments to assembler operand parsing
	logic.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
566d4098fd s390: Assemble processor specific test cases for their processor
Assemble the esa-g5 test case with -march=g5.
Assemble the zarch-z900 test case with -march=z900.

gas/
	* testsuite/gas/s390/s390.exp: Assemble processor specific test
	cases for their respective processor (-march=<processor>).

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
9c021aef48 s390: Correct setting of highgprs flag in ELF output
The combination of an architecture size of 32 bits and z/Architecture
mode requires the highgprs flag to be set in the ELF output. It causes
the high-halves of the general purpose registers (GPRs) to be preserved
at run-time, so that the code can use 64-bit GPRs.

The architecture size of 32 bits can either be the default in case of
a default architecture name of "s390" or due to specification of the
option -m31 (to generate the 31-bit file format).
The z/Architecture mode can either be the default or due to
specification of the option -mzarch (to assemble for z/Architecture
mode). It can also be selected using the pseudo commands
".machinemode zarch" and ".machinemode zarch_nohighgprs". The latter
not causing the highgprs flag to be set.

The highgprs flag was only set when the following s390-specific
assembler options were given in the following specific order:
"-m31 -mzarch".

The highgprs flag was erroneously not set when:
- the order of above options was inverse (i.e. "-mzarch -m31"),
- the architecture mode defaulted to z/Architecture mode and
  option "-m31" was specified,
- the architecture size defaulted to 32 bits due to a default
  architecture name of "s390" and option -mzarch was specified,
- the architecture size defaulted to 32 bits and the architecture
  mode defaulted to z/Architecture due to the specified processor
  (e.g. "-march=z900" or follow-on processor).

Determine whether to set the highgprs flag in init_default_arch() after
having processed all assembler options in md_parse_option(). This
ensures the flag is set in all of the above cases it was erroneously not
set. Add test cases for highgprs flag, including ones that use
.machinemode to switch the architecture mode.

gas/
	* config/tc-s390.c: Correct setting of highgprs flag in ELF
	output.
	* testsuite/gas/s390/s390.exp: Add test cases for highgprs
	flag.
	* testsuite/gas/s390/blank.s: Empty assembler source used in
	test cases for "highgprs" flag.
	* testsuite/gas/s390/esa-highgprs-0.d: Add test case for
	highgprs flag.
	* testsuite/gas/s390/zarch-highgprs-0.d: Likewise.
	* testsuite/gas/s390/zarch-highgprs-1.d: Likewise.
	* testsuite/gas/s390/esa-highgprs-machinemode-0.s: Add test case
	for highgprs flag when using .machinemode to switch
	architecture mode.
	* testsuite/gas/s390/esa-highgprs-machinemode-0.d: Likewise.
	* testsuite/gas/s390/esa-highgprs-machinemode-1.s: Likewise.
	* testsuite/gas/s390/esa-highgprs-machinemode-1.d: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
dd327181e9 s390: Do not erroneously use base operand value for length operand
The base register operand B may optionally be omitted in D(B) by coding
D and in D(L,B) by coding D(L). The index register operand X may
optionally be omitted in D(X,B) by coding D(,B) or D(B). Both base and
index register operands may optionally be omitted in D(X,B) by coding D.
In any case the omitted base and/or index register operand value
defaults to zero.

When parsing an erroneously omitted length L operand in D(L,B) by coding
D(,B) the base register operand B was erroneously consumed as length
operand. When using a register name for the base register operand this
was detected and reported as error. But when not using a register name
the base register operand value was erroneously used as length operand
value.

Correct the parsing of an omitted optional base or index register to not
erroneously use the base register operand value as length, when
erroneously omitting the length operand.

While at it rename the variable used to remember whether the base or
index register operand was omitted to enhance code readability.
Additionally add test cases for the optional omission of base and/or
index register operands.

Example assembler source:
	mvc	16(1,%r1),32(%r2)
	mvc	16(1),32(%r2)
	mvc	16(,1),32(%r2)		# undetected syntax error

Disassembly of bad assembly without commit shows the base register
operand value was erroneously used as length operand value:
   0:   d2 00 10 10 20 20       mvc     16(1,%r1),32(%r2)
   6:   d2 00 00 10 20 20       mvc     16(1,%r0),32(%r2)
   c:   d2 00 00 10 20 20       mvc     16(1,%r0),32(%r2)

Assembler messages with commit:
3: Error: operand 1: missing operand

gas/
	* config/tc-s390.c: Correct parsing of omitted base register.
	* testsuite/gas/s390/s390.exp: Add test cases for omitted base
	and/or index register.
	* testsuite/gas/s390/zarch-omitted-base-index.s: Test cases for
	omitted optional base or index register.
	* testsuite/gas/s390/zarch-omitted-base-index.d: Likewise.
	* testsuite/gas/s390/zarch-omitted-base-index-err.s: Test cases
	for omitted base and/or index register.
	* testsuite/gas/s390/zarch-omitted-base-index-err.l: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
6130dcb9e5 s390: Enhance handling of syntax errors in assembler
Do not consume any unexpected character including newline ('\n') when
detecting a syntax error when parsing an operand block with parenthesis.
This resolves the unfavorable assembler messages from the example below,
including consuming the newline at the end of the current statement and
reporting the next statement as junk.

While at it change the only pre-increment of the current instruction
string pointer into a post-increment to align with the other instances.

Example assembler source:
	mvi	16(),32		# syntax error
	a	%r1,16(%r2	# syntax error
	a	%r1,16(%r2)
	mvc	16(1,),32(%r2)	# syntax error
	mvc	16(1,%r1,32(%r2	# syntax error

Assembler messages without commit:
1: Error: bad expression
1: Error: syntax error; missing ')' after base register
1: Error: syntax error; expected ','
1: Error: junk at end of line: `32'
2: Error: syntax error; missing ')' after base register
2: Error: junk at end of line: `a %r1,16(%r2)'
4: Error: bad expression
4: Error: syntax error; missing ')' after base register
4: Error: syntax error; expected ','
4: Error: operand out of range (32 is not between 0 and 15)
4: Error: syntax error; missing ')' after base register
4: Error: junk at end of line: `%r2)'
5: Error: syntax error; missing ')' after base register
5: Error: syntax error; expected ','
5: Error: operand out of range (32 is not between 0 and 15)
5: Error: syntax error; missing ')' after base register
5: Error: junk at end of line: `%r2'

Assembler messages with commit:
1: Error: bad expression
1: Error: syntax error; missing ')' after base register
2: Error: syntax error; missing ')' after base register
4: Error: bad expression
4: Error: syntax error; missing ')' after base register
5: Error: syntax error; missing ')' after base register
5: Error: syntax error; missing ')' after base register

gas/
	* config/tc-s390.c: Do not erroneously consume newline when
	parsing an addressing operand with parentheses.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jens Remus
5159682a61 s390: Lower severity of assembler syntax errors from fatal to error
Report s390 assembler syntax errors as error instead of fatal error.
This allows the assembler to continue and potentially report further
syntax errors in the source. This should not cause syntax errors to
be erroneously accepted, as both error and fatal error cause the
assembler to return with a non-zero return code.

The following syntax errors are changed from fatal to error:
- invalid length field specified
- odd numbered general purpose register specified as register pair
- invalid floating point register pair.  Valid fp register pair operands
  are 0, 1, 4, 5, 8, 9, 12 or 13.

gas/
	* config/tc-s390.c: Lower severity of assembler syntax errors
	from fatal to error.
	* testsuite/gas/s390/zarch-z9-109-err.l: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Jan Beulich
fabb73d1bb x86: adjust which Dwarf2 register numbers to use
Consumers can't know which execution mode is in effect for a certain
piece of code; they can only go from object file properties. Hence which
register numbers to encode ought to depend solely on object file type.

In tc_x86_frame_initial_instructions() do away with parsing a register
name: We have a symbolic constant already for the 64-bit case, and the
32-bit number isn't going to change either. Said constant's definition
needs moving, though, to be available also for non-ELF. While moving
also adjust the comment to clarify that it's applicable to 64-bit mode
only.
2024-03-01 09:25:59 +01:00
Jan Beulich
77b07380de gas/NEWS: drop mention of Arm64's SVE2.1 and SME2.1
... plus the SME part of B16B16. As per

https://sourceware.org/pipermail/binutils/2024-February/132408.html

SVE2.1 support is both incomplete and buggy. SME2.1 "support" goes as
far as a single instruction (a subset of movaz forms) only. The SME part
of B16B16 is entirely missing.
2024-03-01 09:23:34 +01:00
Jan Beulich
09de03fce5 x86/APX: honor -mevexwig= for byte-size insns
These uniformly ignore EVEX.W, and hence what we emit ought to be
controllable by the command line option.
2024-03-01 09:22:46 +01:00
Jan Beulich
c73a37b268 x86/APX: optimize certain XOR and SUB forms
While most logic in optimize_encoding() is already covering APX by way
of the earlier NDD->REX2 conversion, there's a remaining set of cases
which wants handling separately.
2024-03-01 09:21:40 +01:00
Jan Beulich
6804f42c67 x86/APX: correct .insn opcode space determination when REX2 is needed
In this case spaces 0f38 and 0f3a may not be put in place. To achieve
the intended effect, operand parsing (but not operand processing) needs
pulling ahead, so we know whether eGRP-s are in use.
2024-03-01 09:20:56 +01:00
Jan Beulich
eb3f3841da x86/APX: respect {vex}/{vex3}
Even when an EVEX encoding is available, use of such a prefix ought to
be respected (resulting in an error) rather than ignored. As requested
during review already, introduce a new encoding enumerator to record use
of eGPR-s, and update state transitions accordingly.

The optimize_encoding() change also addresses an internal assembler
error that was previously raised when respective memory operands used
eGPR-s for addressing.

While this results in a change of diagnostic issued for VEX-encoded
insns, the new one is at least no worse than the prior one.
2024-03-01 09:19:58 +01:00
Srinath Parvathaneni
4b067447e1 aarch64: Fix the 2nd operand in gcsstr and gcssttr instructions.
The assembler wrongly expects plain register name instead of
memory-form 2nd operand for gcsstr and gcssttr instructions.
This patch fixes the issue.
2024-02-29 21:06:35 +00:00
Tatsuyuki Ishi
04d352509c RISC-V: Add assembly support for TLSDESC.
gas/
    * tc-riscv.c (percent_op_*): Add support for %tlsdesc_hi,
    %tlsdesc_load_lo, %tlsdesc_add_lo and %tlsdesc_call. percent_op_rtype
    renamed to percent_op_relax_only as this matcher is extended to handle
    jalr as well which is not R-type.
    (riscv_ip): Apply the percent_op_relax_only rename and update comment.
    (md_apply_fix): Add TLSDESC_* to relaxable list. Add TLSDESC_HI20 to
    TLS relocation check list.
    * testsuite/gas/riscv/tlsdesc.*: New test cases for TLSDESC relocation
    generation.
opcodes/
    * riscv-opc.c (riscv_opcodes): Add a new syntax for jalr with
    %tlsdesc_call annotations.
2024-02-29 15:02:51 +08:00
Alan Modra
62143ef92c PR23877, bad value (n32r5900) for default CPU
Catching this at configure time would be nicer, but we'd need to exactly
match mips_parse_cpu in configure.ac and keep it all in sync.

	PR 23877
	* config/tc-mips.c (mips_after_parse_args): Don't assert that
	mips_parse_cpu returns non-NULL, call as_fatal with an informative
	message instead.
2024-02-29 08:55:51 +10:30
Matthieu Longo
d6a14e4138 aarch64: rename internals related to PAuth feature to use pauth in their naming for coherency
Hi,

Commits af1bd77 and 3f4ff08 introduced the Pointer Authentication feature with internal names that don't match the actual feature name pauth. The new feature PAuth_LR introduced in Armv9.5-A is an extension of the PAuth feature of Armv8.3-A. Using a different naming for it not based on the formerly "PAC" would create confusion.

Regression tested on aarch64-none-elf, and no regression found.

Ok for binutils-master? I don't have commit access so I need someone to commit on my behalf.

Regards,
Matthieu.
From 58b38358b2788939d81f2df7f5fb4c64a31ae06e Mon Sep 17 00:00:00 2001
From: Matthieu Longo <matthieu.longo@arm.com>
Date: Fri, 23 Feb 2024 11:30:40 +0000
Subject: [PATCH] aarch64: rename internals related to PAuth feature to use
 pauth in their naming for coherency

Commits af1bd77 and 3f4ff08 introduced the Pointer Authentication feature
with internal names that don't match the actual feature name pauth. The new
feature PAuth_LR introduced in Armv9.5-A is an extension of the PAuth feature
of Armv8.3-A. Using a different naming for it not based on the formerly "PAC"
would create confusion.
2024-02-27 12:46:15 +00:00
Alan Modra
086c8f406d PR25333, GAS is slow processing -fdebug-types-sections
gas needs to build lists of sections for each group.  This arranges to
build the lists earlier, so they can be used when looking for sections
that belong to a group.  Using the section hash table to find sections
by name, then by group isn't efficient when there are numerous groups
with the same section names.  Using a hash table to quickly find a
group, then searching by section name on a list for the group results
in a 100-fold speed improvement assembling the testcase in this PR.

To reduce the number of times we traverse the section list, the patch
also moves some processing done in elf_adjust_symtab for linked-to
section, to elf_frob_file.  This requires a testsuite change because
processing will stop before elf_frob_file if there is a parse error in
section21.s, ie. you'll only get the "junk at end of line" error, not
the "undefined linked-to symbol" errors.

	PR 25333
	* config/obj-elf.c (struct group_list, groups): Move earlier.
	(match_section): New function, extracted from..
	(get_section_by_match): ..here.
	(free_section_idx): Move earlier.
	(group_section_find, group_section_insert): New functions.
	(change_section): Use the above.
	(elf_set_group_name): New function.
	(obj_elf_attach_to_group): Use elf_set_group_name.
	(set_additional_section_info): Handle linked_to_symbol_name and
	stabs code, extracted from..
	(adjust_stab_sections): ..here,..
	(build_additional_section_info): ..and here.
	(elf_adjust_symtab): Don't call build_additional_section_info.
	(elf_frob_file): Adjust.
	* config/obj-elf.h (elf_set_group_name): Declare.
	* config/tc-xtensa.c (cache_literal_section): Use elf_set_group_name.
	(xtensa_make_property_section): Likewise.
	* testsuite/gas/elf/attach-1.d: Stricter group section matching,
	and changed group section ordering.
	* testsuite/gas/elf/attach-2.d: Stricter group section matching.
	* testsuite/gas/elf/attach-2.s: Provide section bar type.
	* testsuite/gas/elf/elf.exp: Run attach-2.
	* testsuite/gas/elf/section21.l: Update.
	* testsuite/gas/elf/section21.s: Don't check for a parse error.
2024-02-24 14:59:13 +10:30
Alan Modra
bc45bfd259 xtensa: move xtensa_make_property_section from bfd to gas
This function is only used by gas, so move it there.  Necessary for
gas to keep track of group sections as they are created.

	PR 25333
bfd/
	* elf32-xtensa.c (xtensa_make_property_section): Delete.
	(xtensa_property_section_name): Make public.
include/
	* elf/xtensa.h (xtensa_make_property_section): Delete.
	(xtensa_property_section_name): Declare
gas/
	* config/tc-xtensa.c (xtensa_make_property_section): New,
	moved from elf32-xtensa.c.
2024-02-24 14:58:55 +10:30
Jan Beulich
e346d50a89 x86: rename vec_encoding and vex_encoding_*
Even with just VEX these weren't limited to vector insns. With APX the
set of non-vector ones covered has greatly increased. Drop the vec_
prefix. Also drop the vex_ ones off of the enumerators, as they weren't
appropriate anyway: Should have been vec_ then, too.
2024-02-23 12:00:43 +01:00
Jan Beulich
db5aae3ccd x86: document -moperand-check=
PR gas/31388
Like other command line options this should be mentioned in
documentation as well, not just in "as --help" output.
2024-02-23 11:59:42 +01:00
Jan Beulich
a40a04601f x86: also permit YMM/ZMM use in CFI directives
Next to code using %ymm<N> or %zmm<N> it is more natural to have .cfi_*
directives also reference those, not the corresponding %xmm<N>. Accept
their names as kind of aliases, i.e. resolving to the same numbers.

While extending the respective 64-bit testcase, also add %bnd<N> there
(should have happened right with 633789901c ["x86-64: Dwarf2 register
numbers for %bnd<N>"], sorry), requiring binutils/dwarf.c to be adjusted
accordingly as well.
2024-02-23 11:59:09 +01:00
Jan Beulich
2f630f60b5 x86/APX: INV{EPT,PCID,VPID} are WIG
While various other entries in version 003 of the spec aren't quite as
explicit (due to simply leaving the respective field blank), all three
have a clear IGNORED there. IOW they ought to be emitted with EVEX.W=0
by default (and respect -mevexwig=).
2024-02-23 11:58:15 +01:00
mengqinggang
c429c44598 LoongArch: gas: Try to avoid R_LARCH_ALIGN associate with a symbol
The R_LARCH_ALIGN need to associated with a symbol if .align has the first
and third expressions. If R_LARCH_ALIGN associate with a symbol, the addend can
represent the first and third expression of .align.

For '.align 3', the addend of R_LARCH_ALIGN only need to represent the alignment
and R_LARCH_ALIGN not need to associate with a symbol.

For '.align x, , y', R_LARCH_ALIGN need to associate with a symbol if 0 < y <
2^x - 4.
2024-02-23 15:40:34 +08:00
Alan Modra
fddee222e5 Leak in i386_elf_section_change_hook
notes_alloc is perfect for assorted memory you can't free easily
and/or would rather leave freeing until just before exit.

	* config/tc-i386.c (i386_elf_section_change_hook): Use notes_alloc.
2024-02-22 07:57:15 +10:30
Matthieu Longo
44f85d2d79 aarch64: testsuite: move sysreg tests into sysreg sub-directory
This patch moves the existing sysreg tests for AArch64 into a subdirectory
(sysreg). The number of test files related to system registers grew
relatively big with time and makes the browsing of those files difficult.
Moreover, the difference of naming for the failure, working, and
feature-specific scenarios causes the tests not to appear next to one
another in the exploration tree when it is ordered alphabetically.
2024-02-21 13:01:51 +00:00
Nelson Chu
af514e5f6d RISC-V: Don't generate branch/jump relocation if symbol is local when no-relax.
Refer to commit, dff565fcca.  Theoretically,
assembler don't need to generate the pc-relative relocation and the refered
local .L symbol when relaxation is disabled.  The above commit improved the
pcrel_hi/pcrel_lo relocations, and this commit improves branch and jump
relocations.

Passed the gcc/binutils regressions of riscv-gnu-toolchain.

gas/
	* config/tc-riscv.c (md_apply_fix): Raise fixP->fx_done for all
	branch and jump relocations when -mno-relax.
2024-02-21 14:58:05 +08:00
Paul Iannetta
9012a09f4f kvx: gas: missing aliases for $r14r15 in assembler.
Most registers from a register-pair suffixed by .lo and .hi suffixes.
This was not the case of $r14 and $r15 since they are defined by the
ABI: $r14 is the frame pointer, and $r15 is used to return aggregates
from functions.  We do not add aliases for $r12 (the stack pointer) and
$r13 (the tls register).

opcodes/ChangeLog:

	* kvx-opc.c: Regenerate.

gas/ChangeLog:

	* config/kvx-parse.h: Regenerate.
2024-02-20 12:07:57 +01:00
Paul Iannetta
9798722ef6 kvx: enable magic immediates for integer multiply-accumulate and CMOVE*
Affected instructions:
 - alu unit:
    cmovewp cmovehq
 - mau unit:
     maddwdp madduwdp maddsuwdp mma msbfwdp msbfuwdp
     msbfsuwdp mms mulwdp muluwdp mulsuwdp mm

opcodes/ChangeLog:

	* kvx-opc.c (struct kvxopc): Regenerate.

gas/ChangeLog:

	* config/kvx-parse.h: Regenerate.
2024-02-20 12:07:57 +01:00
Paul Iannetta
0593f8d6f7 kvx: gas: rename: or -> ior, xor -> eor
TCA instructions start with an X, this introduces ambiguities when it
comes to XOR (Is it the OR on the TCA or the XOR of the core?).  For this
reason, we rename OR to IOR and XOR to EOR.

OR and XOR variants are still valid on KV3-1 and KV3-2.  However, they
have been completely removed from KV4-1.

opcodes/ChangeLog:

	* kvx-opc.c: Regenerate.

include/ChangeLog:

	* opcode/kvx.h: Regenerate.

gas/ChangeLog:

	* config/kvx-parse.h: Regenerate.
	* testsuite/gas/kvx/kv3-1-insns-32.d: Regenerate.
	* testsuite/gas/kvx/kv3-1-insns-32.s: Regenerate.
	* testsuite/gas/kvx/kv3-1-insns-64.d: Regenerate.
	* testsuite/gas/kvx/kv3-1-insns-64.s: Regenerate.
	* testsuite/gas/kvx/kv3-2-insns-32.d: Regenerate.
	* testsuite/gas/kvx/kv3-2-insns-32.s: Regenerate.
	* testsuite/gas/kvx/kv3-2-insns-64.d: Regenerate.
	* testsuite/gas/kvx/kv3-2-insns-64.s: Regenerate.
	* testsuite/gas/kvx/kv4-1-insns-32.d: Regenerate.
	* testsuite/gas/kvx/kv4-1-insns-32.s: Regenerate.
	* testsuite/gas/kvx/kv4-1-insns-64.d: Regenerate.
	* testsuite/gas/kvx/kv4-1-insns-64.s: Regenerate.
2024-02-20 12:07:57 +01:00
Paul Iannetta
3c85dd404f kvx: gas: move the splat modifier to the immediate
The position of the splat modifier is now after the operand it
modifies and not attached directly to the opcode.

opcodes/ChangeLog:

	* kvx-opc.c: Regenerate.

include/ChangeLog:

	* opcode/kvx.h: Regenerate.

gas/ChangeLog:

	* config/kvx-parse.h: Regenerate.
	* testsuite/gas/kvx/kv3-1-insns-32.d: Regenerate.
	* testsuite/gas/kvx/kv3-1-insns-32.s: Regenerate.
	* testsuite/gas/kvx/kv3-1-insns-64.d: Regenerate.
	* testsuite/gas/kvx/kv3-1-insns-64.s: Regenerate.
	* testsuite/gas/kvx/kv3-2-insns-32.d: Regenerate.
	* testsuite/gas/kvx/kv3-2-insns-32.s: Regenerate.
	* testsuite/gas/kvx/kv3-2-insns-64.d: Regenerate.
	* testsuite/gas/kvx/kv3-2-insns-64.s: Regenerate.
	* testsuite/gas/kvx/kv4-1-insns-32.d: Regenerate.
	* testsuite/gas/kvx/kv4-1-insns-32.s: Regenerate.
	* testsuite/gas/kvx/kv4-1-insns-64.d: Regenerate.
	* testsuite/gas/kvx/kv4-1-insns-64.s: Regenerate.
2024-02-20 12:07:57 +01:00
Paul Iannetta
3bf43af5f7 kvx: gas: fix leak
gas/ChangeLog:

	* config/tc-kvx.c (md_apply_fix): Free memory at this end.
2024-02-20 12:07:57 +01:00
Paul Iannetta
512707c2e2 kvx: Improve lexing & parsing
Up until now, we used ENV.PROMOTE_IMMEDIATE to get the next candidates,
however this candidate can be directly extracted from the array (in
kvx-parse.h) registering all the immediates.

During lexing, we ignored trailing characters after a number, this is
not good enough since now number can be followed by a modifier.  The
function READ_TOKEN and GET_TOKEN_CLASS have been update to take this
into account.

gas/ChangeLog:

	* config/kvx-parse.c (promote_token): Do not rely on
	  env.promote_immediate anymore.
	(get_token_class): Do not ignore trailing characters after a
	number.
	(read_token): Likewise.
	(print_token_list): THIS SHOULD NOT BE HERE.
2024-02-20 12:07:57 +01:00
Paul Iannetta
04e46d3bd9 kvx: gas: fix the detection of negative powers of 2
The detection of negative powers of 2 was wrong and could lead to
well-formed bundles ending up taking more syllables than necessary.

gas/ChangeLog:

	* config/kvx-parse.c (get_token_class): Use the signed value.
	* testsuite/gas/kvx/np2-detection.d: New test.
	* testsuite/gas/kvx/np2-detection.s: New test.
2024-02-20 12:07:57 +01:00
Jose E. Marchesi
f1efdade94 bpf: gas: add missing indcall-badoperand.* test files
This adds teh following files that were missing in the previous
commit ecd16ae4e4

  testsuite/gas/bpf/indcall-badoperand.d
  testsuite/gas/bpf/indcall-badoperand.l
  testsuite/gas/bpf/indcall-badoperand.s
2024-02-20 12:04:49 +01:00
Will Hawkins
ecd16ae4e4 bpf: fix bpf expression parsing regression in GAS
As a result of a switch instead of an if, as would issue non-specific
error messages when it encountered an operand it could not parse in bpf.
This patch fixes that regression and adds a test to prevent it from
reoccurring.

Tested for bpf-unknown-none on x86_64-redhat-linux.

gas/ChangeLog:

	* config/tc-bpf.c (parse_expression): Change switch to if so that error
	* condition is handled.
	* testsuite/gas/bpf/bpf.exp: Invoke new test.
	* testsuite/gas/bpf/indcall-badoperand.d: New test.
	* testsuite/gas/bpf/indcall-badoperand.l: New test.
	* testsuite/gas/bpf/indcall-badoperand.s: New test.
2024-02-19 20:48:17 +01:00
Jose E. Marchesi
b86b514aac bpf: gas: avoid UB in pointer subtraction
The PARSE_ERROR macro in md_assemble performs pointer subtraction.  If
parse_expression returns NULL then the later will be part of the
subtraction and therefore UB will be incurred.

This patch changes md_assemble to:
1. Accommodate all invocations to parse_expression to the fact it will
   return NULL when a parse error occurs.
2. Avoid UB in PARSE_ERROR.

Tested in bpf-unknown-none target / x86_64-linux-gnu host.

gas/ChangeLog:

	* config/tc-bpf.c (md_assemble): Fix to take into account that
	parse_expression can return NULL.
	(PARSE_ERROR): Avoid passing invalid length to parse_error.
2024-02-19 20:48:17 +01:00
Claudio Bantaloukas
b47cef7ca8 arm: Add support for Armv9.5-A 2024-02-19 15:26:59 +00:00
Yury Khrustalev
1bc24c0dab aarch64: Add support for the id_aa64isar3_el1 system register
Hi,

[PATCH][Binutils] aarch64: Add support for the id_aa64isar3_el1 system register

AArch64 defines a read-only system register called id_aa64isar3_el1.
This patch also adds relevant tests.

Regression tested on the aarch64-none-elf and aarch64-none-linux-gnu targets
and no regressions was found.

Is this Ok for trunk? I do not have commit rights, if OK, can someone commit on my behalf?

Thanks,
Yury Khrustalev

From e42c835e8f2ee81150f498675f2faf108bbe79f8 Mon Sep 17 00:00:00 2001
From: Yury Khrustalev <yury.khrustalev@arm.com>
Date: Tue, 6 Feb 2024 11:05:39 +0000
Subject: [PATCH] [PATCH][Binutils] aarch64: Add support for the
 id_aa64isar3_el1 system register

AArch64 defines a read-only system register called id_aa64isar3_el1.
This patch also adds relevant tests.

Regression tested on the aarch64-none-elf and aarch64-none-linux-gnu targets
and no regressions was found.
2024-02-19 14:08:36 +00:00
Zac Walker
f87eaf8ff3 aarch64: Add new relocations and limit COFF AArch64 relocation offsets
The patch adds support for the IMAGE_REL_ARM64_REL32 coff relocation
type. This is needed for 32-bit relative address.

It also adds a check for relocation offsets over 21 bits. Offsets
inside coff files are stored in instruction code. In the case of ADRP
the actual value is stored, not a downshifted page offset. This means
values over 21 bits would otherwise be truncated.

Finally it adds a mapping for BFD_RELOC_AARCH64_ADR_GOT_PAGE and
BFD_RELOC_AARCH64_LD64_GOT_LO12_NC that were previously skipped.

ChangeLog:

	* bfd/coff-aarch64.c (coff_aarch64_reloc_type_lookup): Add
	BFD_RELOC_AARCH64_ADR_GOT_PAGE,
	BFD_RELOC_AARCH64_LD64_GOT_LO12_NC and IMAGE_REL_ARM64_REL32
	relocations.
	(coff_pe_aarch64_relocate_section): Likewise.
	* gas/write.c (adjust_reloc_syms): COFF AArch64 relocation
	offsets need to be limited to 21bits
	(defined): Likewise.
2024-02-19 13:02:00 +00:00