Commit Graph

8269 Commits

Author SHA1 Message Date
Jose E. Marchesi
5be1b78727 bpf: gas: consolidate handling of immediate overflows
This commit changes the BPF GAS port in order to handle immediate
overflows the same way than the clang BPF assembler:

- For an immediate field of N bits, any written number (positive or
  negative) whose two's complement encoding fit in N its is accepted.
  This means that -2 is the same than 0xffffffe.  It is up to the
  instructions to decide how to interpret the encoded value.

- Immediate fields in jump instructions are no longer relaxed.
  Relaxing to jump instructions with wider range is only performed
  when expressions are involved.

- The manual is updated to document this, and testsuite adapted
  accordingly.

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

gas/ChangeLog:

2023-08-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* config/tc-bpf.c (check_immediate_overflow): New function.
	(encode_insn): Use check_immediate_overflow.
	(md_assemble): Do not relax instructions with
	constant disp16 fields.
	* doc/c-bpf.texi (BPF Instructions): Add note about how numerical
	literal values are interpreted for instruction immediate operands.
	* testsuite/gas/bpf/disp16-overflow.s: Adapt accordingly.
	* testsuite/gas/bpf/jump-relax-jump.s: Likewise.
	* testsuite/gas/bpf/jump-relax-jump.d: Likewise.
	* testsuite/gas/bpf/jump-relax-jump-be.d: Likewise.
	* testsuite/gas/bpf/jump-relax-ja.s: Likewise.
	* testsuite/gas/bpf/jump-relax-ja.d: Likewise.
	* testsuite/gas/bpf/jump-relax-ja-be.d: Likewise.
	* testsuite/gas/bpf/disp16-overflow-relax.l: Likewise.
	* testsuite/gas/bpf/imm32-overflow.s: Likewise.
	* testsuite/gas/bpf/disp32-overflow.s: Likewise.
	* testsuite/gas/bpf/disp16-overflow.l: Likewise.
	* testsuite/gas/bpf/disp32-overflow.l: Likewise.
	* testsuite/gas/bpf/imm32-overflow.l: Likewise.
	* testsuite/gas/bpf/offset16-overflow.l: Likewise.
2023-08-17 09:41:43 +02:00
Sam James
b5c37946cc Revert "2.41 Release sources"
This reverts commit 675b9d612c.

See https://sourceware.org/pipermail/binutils/2023-August/128761.html.
2023-08-02 12:06:23 +01:00
Nick Clifton
675b9d612c 2.41 Release sources 2023-08-02 09:23:36 +01:00
Jose E. Marchesi
1e18ffc991 bpf: include, bfd, opcodes: add EF_BPF_CPUVER ELF header flags
This patch adds support for EF_BPF_CPUVER bits in the ELF
machine-dependent header flags.  These bits encode the BPF CPU
version for which the object file has been compiled for.

The BPF assembler is updated so it annotates the object files it
generates with these bits.

The BPF disassembler is updated so it honors EF_BPF_CPUVER to use the
appropriate ISA version if the user didn't specify an explicit ISA
version in the command line.  Note that a value of zero in
EF_BPF_CPUVER is interpreted by the disassembler as "use the later
supported version" (the BPF CPU versions start with v1.)

The readelf utility is updated to pretty print EF_BPF_CPUVER when it
prints out the ELF header:

   $ readelf -h a.out
   ELF Header:
     ...
     Flags:                             0x4, CPU Version: 4

Tested in bpf-unknown-none.

include/ChangeLog:

2023-07-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* elf/bpf.h (EF_BPF_CPUVER): Define.
	* opcode/bpf.h (BPF_XBPF): Change from 0xf to 0xff so it fits in
	EF_BPF_CPUVER.

binutils/ChangeLog:

2023-07-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* readelf.c (get_machine_flags): Recognize and pretty print BPF
	machine flags.

opcodes/ChangeLog:

2023-07-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* bpf-dis.c: Initialize asm_bpf_version to -1.
	(print_insn_bpf): Set BPF ISA version from the cpu version ELF
	header flags if no explicit version set in the command line.
	* disassemble.c (disassemble_init_for_target): Remove unused code.

gas/ChangeLog:

2023-07-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* config/tc-bpf.h (elf_tc_final_processing): Define.
	* config/tc-bpf.c (bpf_elf_final_processing): New function.
2023-07-30 22:39:30 +02:00
Jose E. Marchesi
0346042938 bpf: gas: add field overflow checking to the BPF assembler
This patch makes the BPF assembler to throughfully check for overflow
in immediates.  This includes relaxed instructions.

Tested in bpf-unknown-none.

gas/ChangeLog:

2023-07-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* config/tc-bpf.c (signed_overflow): Copy function from
	tc-aarch64.c.
	(encode_insn): Check for overflow in constant immediates.
	(add_relaxed_insn): Pass relax argument to encode_insn.
	(add_fixed_insn): Likewise.
	* testsuite/gas/bpf/disp16-overflow.d: New file.
	* testsuite/gas/bpf/disp16-overflow.s: Likewise.
	* testsuite/gas/bpf/disp16-overflow.l: Likewise.
	* testsuite/gas/bpf/disp32-overflow.d: Likewise.
	* testsuite/gas/bpf/disp32-overflow.s: Likewise.
	* testsuite/gas/bpf/disp32-overflow.l: Likewise.
	* testsuite/gas/bpf/imm32-overflow.d: Likewise.
	* testsuite/gas/bpf/imm32-overflow.s: Likewise.
	* testsuite/gas/bpf/imm32-overflow.l: Likewise.
	* testsuite/gas/bpf/offset16-overflow.d: Likewise.
	* testsuite/gas/bpf/offset16-overflow.s: Likewise.
	* testsuite/gas/bpf/offset16-overflow.l: Likewise.
	* testsuite/gas/bpf/disp16-overflow-relax.d: Likewise.
	* testsuite/gas/bpf/disp16-overflow-relax.l: Likewise.
	* testsuite/gas/bpf/disp16-overflow-relax.s: Likewise.
	* testsuite/gas/bpf/jump-relax-jump-be.d: New file.
	* testsuite/gas/bpf/bpf.exp: Run new tests.
2023-07-30 21:08:14 +02:00
Jose E. Marchesi
249d4715e4 bpf: gas: support relaxation of V4 jump instructions
The BPF jump-always instruction (JA), like all other jump instructions
in the ISA, get a signed 16-bit displacement target argument denoted
in number of 64-bit words minus one.  This can sometimes be overflown.

The BPF V4 ISA thus introduced support for a jump-always
instruction (JAL) that gets a signed 32-bit displacement instead.

This patch makes the BPF assembler to perform the following
relaxations when the disp16 field gets overflown, unless the option
-mno-relax is specified:

  JA disp16  -> JAL disp32
  Jxx disp16 -> Jxx +1; JA +1; JAL disp32

Documentation and tests added.
Tested in bpf-unknown-none.

gas/ChangeLog:

2023-07-28  Jose E. Marchesi  <jose.marchesi@oracle.com>

	PR gas/30690
	* config/tc-bpf.c (struct bpf_insn): Add fields is_relaxable and
	relaxed_exp.
	(enum options): Add OPTION_NO_RELAX.
	(md_longopts): Likewise for -mno-relax.
	(do_relax): New global.
	(md_parse_option): Handle OPTION_NO_RELAX.
	(RELAX_BRANCH_ENCODE): Define.
	(RELAX_BRANCH_P): Likewise.
	(RELAX_BRANCH_LENGTH): Likewise.
	(RELAX_BRANCH_CONST): Likewise.
	(RELAX_BRANCH_UNCOND): Likewise.
	(relaxed_branch_length): New function.
	(md_estimate_size_before_relax): Likewise.
	(read_insn_word): Likewise.
	(encode_int16): Likewise.
	(encode_int32): Likewise.
	(write_insn_bytes): Likewise.
	(md_convert_frag): Likewise.
	(encode_insn): Likewise.
	(install_insn_fixups): Likewise.
	(add_fixed_insn): Likewise.
	(add_relaxed_insn): Likewise.
	(md_assemble): Move instruction encoding logic to the above
	new functions.
	* testsuite/gas/bpf/jump-relax-ja.d: New test.
	* testsuite/gas/bpf/jump-relax-ja-be.d: Likewise.
	* testsuite/gas/bpf/jump-relax-ja.s: And corresponding source.
	* testsuite/gas/bpf/jump-relax-jump.d: New test.
	* testsuite/gas/bpf/jump-relax-jump-be.d: Likewise.
	* testsuite/gas/bpf/jump-relax-jump.s: And corresponding source.
	* testsuite/gas/bpf/bpf.exp: Run new tests.
	* doc/c-bpf.texi (BPF Options): Document -mno-relax.
2023-07-28 18:19:44 +02:00
Jose E. Marchesi
ac284430be bpf: gas: add negi and neg32i tests
gas/ChangeLog:

2023-07-26  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* testsuite/gas/bpf/alu.s: Add test for NEGI and NEG32I.
	* testsuite/gas/bpf/alu32.s: Likewise.
	* testsuite/gas/bpf/alu-pseudoc.s: Likewise.
	* testsuite/gas/bpf/alu32-pseudoc.s: Likewise.
	* testsuite/gas/bpf/alu.d: Add expected results.
	* testsuite/gas/bpf/alu-be.d: Likewise.
	* testsuite/gas/bpf/alu-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu32.d: Likewise.
	* testsuite/gas/bpf/alu32-be.d: Likewise.
	* testsuite/gas/bpf/alu32-be-pseudoc.d: Likewise.
2023-07-26 15:03:04 +02:00
Jose E. Marchesi
04896832b2 bpf: fix register NEG[32] instructions
This patch fixes the BPF_INSN_NEGR and BPF_INSN_NEG32R BPF
instructions to not use their source registers.

Tested in bpf-unknown-none.

opcodes/ChangeLog:

2023-07-26  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* bpf-opc.c (bpf_opcodes): Fix BPF_INSN_NEGR to not use a src
	register.

gas/ChangeLog:

2023-07-26  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* testsuite/gas/bpf/alu.s: The register neg instruction gets only
	one argument.
	* testsuite/gas/bpf/alu32-be-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu32-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu32-pseudoc.s: Likewise.
	* testsuite/gas/bpf/alu-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu-pseudoc.s: Likewise.
	* testsuite/gas/bpf/alu-be.d: Likewise.
	* testsuite/gas/bpf/alu.d: Likewise.
	* testsuite/gas/bpf/alu32-be.d: Likewise.
	* testsuite/gas/bpf/alu32.d: Likewise.
	* testsuite/gas/bpf/alu32.s: Likewise.
	* doc/c-bpf.texi (BPF Instructions): Update accordingly.
2023-07-26 11:38:04 +02:00
Jose E. Marchesi
5cbe549257 bpf: gas,include,opcode: add suppor for instructions BSWAP{16,32,64}
This patch adds support for the BPF V4 ISA byte swap instructions to
opcodes, assembler and disassembler.

Tested in bpf-unknown-none.

include/ChangeLog:

2023-07-24  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* opcode/bpf.h (BPF_IMM32_BSWAP16): Define.
	(BPF_IMM32_BSWAP32): Likewise.
	(BPF_IMM32_BSWAP64): Likewise.
	(enum bpf_insn_id): New entries BPF_INSN_BSWAP{16,32,64}.

opcodes/ChangeLog:

2023-07-24  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* bpf-opc.c (bpf_opcodes): Add entries for the BSWAP*
	instructions.

gas/ChangeLog:

2023-07-24  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* doc/c-bpf.texi (BPF Instructions): Document BSWAP* instructions.
	* testsuite/gas/bpf/alu.s: Test BSWAP{16,32,64} instructions.
	* testsuite/gas/bpf/alu.d: Likewise.
	* testsuite/gas/bpf/alu-be.d: Likewise.
	* testsuite/gas/bpf/alu-pseudoc.s: Likewise.
	* testsuite/gas/bpf/alu-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
2023-07-24 02:54:06 +02:00
Jose E. Marchesi
a50ead7822 bpf: gas: fix in manual that MOVS* pseudoc syntax uses = instead of s=
gas/ChangeLog:

2023-07-24  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* doc/c-bpf.texi (BPF Instructions): The pseudoc syntax for MOVS*
	doesn't use `s=' but `='.
2023-07-24 02:20:55 +02:00
Jose E. Marchesi
3ccfc0b46c bpf: gas,opcodes: fix pseudoc syntax for MOVS* and LDXS* insns
This patch fixes the pseudoc syntax of the V4 instructions MOVS* and
LDXS* in order to reflect https://reviews.llvm.org/D144829.

opcodes/ChangeLog:

2023-07-24  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* bpf-opc.c (bpf_opcodes): Fix pseudo-c syntax for MOVS* and LDXS*
	instructions.

gas/ChangeLog:

2023-07-24  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* doc/c-bpf.texi (BPF Instructions): Fix pseudoc syntax for MOVS*
	and LDXS* instructions.
	* testsuite/gas/bpf/mem-pseudoc.d: Likewise.
	* testsuite/gas/bpf/mem-be-pseudoc.d: Likewise.
	* testsuite/gas/bpf/mem-pseudoc.s: Likewise.
	* testsuite/gas/bpf/alu-pseudoc.s: Likewise.
	* testsuite/gas/bpf/alu-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu32-pseudoc.s: Likewise.
	* testsuite/gas/bpf/alu32-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu32-be-pseudoc.d: Likewise.
2023-07-24 02:13:17 +02:00
Jose E. Marchesi
c2ca88d74b bpf: add support for jal/gotol jump instruction with 32-bit target
This patch adds support for the V4 BPF instruction jal/gotol, which is
like ja/goto but it supports a signed 32-bit PC-relative (in number of
64-bit words minus one) target operand instead of the 16-bit signed
operand of the other instruction.  This greatly increases the jump
range in BPF programs.

Tested in bpf-unkown-none.

bfd/ChangeLog:

2023-07-24  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* reloc.c: New reloc BFD_RELOC_BPF_DISPCALL32.
	* elf64-bpf.c (bpf_reloc_type_lookup): Handle the new reloc.
	* libbfd.h (bfd_reloc_code_real_names): Regenerate.

gas/ChangeLog:

2023-07-24  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* config/tc-bpf.c (struct bpf_insn): New field `id'.
	(md_assemble): Save the ids of successfully parsed instructions
	and use the new BFD_RELOC_BPF_DISPCALL32 whenever appropriate.
	(md_apply_fix): Adapt to the new BFD reloc.
	* testsuite/gas/bpf/jump.s: Test JAL.
	* testsuite/gas/bpf/jump.d: Likewise.
	* testsuite/gas/bpf/jump-pseudoc.d: Likewise.
	* testsuite/gas/bpf/jump-be.d: Likewise.
	* testsuite/gas/bpf/jump-be-pseudoc.d: Likewise.
	* doc/c-bpf.texi (BPF Instructions): Document new instruction
	jal/gotol.
	Document new operand type disp32.

include/ChangeLog:

2023-07-24  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* opcode/bpf.h (enum bpf_insn_id): Add entry BPF_INSN_JAL.
	(enum bpf_insn_id): Remove spurious entry BPF_INSN_CALLI.

opcodes/ChangeLog:

2023-07-23  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* bpf-opc.c (bpf_opcodes): Add entry for jal.
2023-07-24 01:20:03 +02:00
Jose E. Marchesi
c24fd9547f bpf: opcodes, gas: support for signed load V4 instructions
This commit adds the signed load to register (ldxs*) instructions
introduced in the BPF ISA version 4, including opcodes and assembler
tests.

Tested in bpf-unknown-none.

include/ChangeLog:

2023-07-21  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* opcode/bpf.h (enum bpf_insn_id): Add entries for signed load
	instructions.
	(BPF_MODE_SMEM): Define.

opcodes/ChangeLog:

2023-07-21  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* bpf-opc.c (bpf_opcodes): Add entries for LDXS{B,W,H,DW}
	instructions.

gas/ChangeLog:

2023-07-21  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* testsuite/gas/bpf/mem.s: Add signed load instructions.
	* testsuite/gas/bpf/mem-pseudoc.s: Likewise.
	* testsuite/gas/bpf/mem.d: Likewise.
	* testsuite/gas/bpf/mem-pseudoc.d: Likewise.
	* testsuite/gas/bpf/mem-be.d: Likewise.
	* doc/c-bpf.texi (BPF Instructions): Document the signed load
	instructions.
2023-07-21 20:00:30 +02:00
Jose E. Marchesi
2f3dbc5fb5 bpf: opcodes, gas: support for signed register move V4 instructions
This commit adds the signed register move (movs) instructions
introduced in the BPF ISA version 4, including opcodes and assembler
tests.

Tested in bpf-unknown-none.

include/ChangeLog:

2023-07-21  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* opcode/bpf.h (BPF_OFFSET16_MOVS8): Define.
	(BPF_OFFSET16_MOVS16): Likewise.
	(BPF_OFFSET16_MOVS32): Likewise.
	(enum bpf_insn_id): Add entries for MOVS{8,16,32}R and
	MOVS32{8,16,32}R.

opcodes/ChangeLog:

2023-07-21  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* bpf-opc.c (bpf_opcodes): Add entries for MOVS{8,16,32}R and
	MOVS32{8,16,32}R instructions.  and MOVS32I instructions.

gas/ChangeLog:

2023-07-21  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* testsuite/gas/bpf/alu.s: Test movs instructions.
	* testsuite/gas/bpf/alu-pseudoc.s: Likewise.
	* testsuite/gas/bpf/alu32.s: Likewise for movs32 instruction.
	* testsuite/gas/bpf/alu32-pseudoc.s: Likewise.
	* testsuite/gas/bpf/alu.d: Add expected results.
	* testsuite/gas/bpf/alu32.d: Likewise.
	* testsuite/gas/bpf/alu-be.d: Likewise.
	* testsuite/gas/bpf/alu32-be.d: Likewise.
	* testsuite/gas/bpf/alu-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu32-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu32-be-pseudoc.d: Likewise.
2023-07-21 20:00:30 +02:00
Nick Clifton
87485f5349 Change version number to 2.41.50 and regenerate files 2023-07-03 11:54:06 +01:00
Nick Clifton
d501d38488 Add markers for the 2.41 branch 2023-07-03 11:12:15 +01:00
Nick Clifton
cddbf406ea Fix gas tests for aarch64-pe 2023-06-26 17:37:19 +01:00
Jose E. Marchesi
2b8c7766ea gas: bpf: fix tests for pseudo-c syntax
This patch fixes the GAS BPF testsuite so the tests for pseudo-c
syntax are actually executed.

2023-04-27  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* testsuite/gas/bpf/mem.dump: New file.
	* testsuite/gas/bpf/mem-pseudoc.d: Likewise.
	* testsuite/gas/bpf/mem.d: #dump mem.dump.
	* testsuite/gas/bpf/lddw.dump: New file.
	* testsuite/gas/bpf/lddw-pseudoc.d: Likewise.
	* testsuite/gas/bpf/lddw.d: #dump lddw.dump.
	* testsuite/gas/bpf/jump.dump: New file.
	* testsuite/gas/bpf/jump-pseudoc.d: Likewise
	* testsuite/gas/bpf/jump.d: #dump jump.dump.
	* testsuite/gas/bpf/jump32.dump: New file.
	* testsuite/gas/bpf/jump32-pseudoc.d: Likewise.
	* testsuite/gas/bpf/jump32.d: #dump jump32.dump.
	* testsuite/gas/bpf/lddw-be.dump: New file.
	* testsuite/gas/bpf/lddw-be-pseudoc.d: Likewise.
	* testsuite/gas/bpf/lddw-be.d: #dump lddw-be.dump.
	* testsuite/gas/bpf/indcall-1.dump: New file.
	* testsuite/gas/bpf/indcall-1-pseudoc.d: Likewise.
	* testsuite/gas/bpf/indcall-1.d: #dump indcall-1.dump.
	* testsuite/gas/bpf/indcall-1-pseudoc.s (main): Fix lddw
	instruction.
	* testsuite/gas/bpf/atomic.dump: New file.
	* testsuite/gas/bpf/atomic-pseudoc.d: Likewise.
	* testsuite/gas/bpf/atomic.d: #dump atomic.dump.
	* testsuite/gas/bpf/alu32.dump: New file.
	* testsuite/gas/bpf/alu32-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu32.d: #dump alu32.dump.
	* testsuite/gas/bpf/alu.dump: New file.
	* testsuite/gas/bpf/alu-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu.d: #dump alu.dump.

	* testsuite/gas/bpf/alu-be.dump: New file.
	* testsuite/gas/bpf/alu-be-pseudoc.d: Likewise.
	* testsuite/gas/bpf/alu-be.d: #dump alu-be.dump.
	* testsuite/gas/bpf/alu32-be-pseudoc.d: New file.
	* testsuite/gas/bpf/alu32-be-dump: Likewise.
	* testsuite/gas/bpf/alu32-be.d: #dump alu32-be-dump.
	* testsuite/gas/bpf/bpf.exp: Run *-pseudoc tests.
2023-04-27 20:06:30 +02:00
Jose E. Marchesi
dcdec68b0b gas: documentation for the BPF pseudo-c asm syntax
This patch expands the GAS manual in order to specify the alternate
pseudo-C assembly syntax used in BPF, and now supported by the
assembler.

gas/ChangeLog:

2023-04-19  Jose E. Marchesi  <jose.marchesi@oracle.com>

	PR gas/29757
	* doc/c-bpf.texi (BPF Pseudo-C Syntax): New section.
2023-04-26 19:29:09 +02:00
Guillermo E. Martinez
bba4624d03 gas: BPF pseudo-c syntax tests
This patch expands the GAS BPF testsuite in order to also test the
alternative pseudo-C syntax used in BPF assembly.

This includes three main changes:

- Some general GAS tests involving assignment and equality operands in
  expressions (such as = and ==) are disabled in bpf-* targets,
  because the syntax collides with the pseudo-C BPF assembly syntax.

- New tests are added to the BPF GAS testsuite that test the pseudo-c
syntax.  Tests for all BPF instructions are included.

- New tests are added to the BPF GAS testsuite that test the support
  for both syntaxes in the same source.

gas/ChangeLog:

2023-04-20  Guillermo E. Martinez  <guillermo.e.martinez@oracle.com>

	PR gas/29728
	* testsuite/gas/all/assign-bad-recursive.d: Skip test in bpf-*
	targets.
	* testsuite/gas/all/eqv-dot.d: Likewise.
	* testsuite/gas/all/gas.exp: Skip other assignment tests in bpf-*.
	* testsuite/gas/bpf/alu-pseudoc.s: New file.
	* testsuite/gas/bpf/pseudoc-normal.s: Likewise.
	* testsuite/gas/bpf/pseudoc-normal.d: Likewise.
	* testsuite/gas/bpf/pseudoc-normal-be.d: Likewise.
	* testsuite/gas/bpf/mem-pseudoc.s: Likewise.
	* testsuite/gas/bpf/lddw-pseudoc.s: Likewise.
	* testsuite/gas/bpf/jump32-pseudoc.s: Likewise.
	* testsuite/gas/bpf/jump-pseudoc.s: Likewise.
	* testsuite/gas/bpf/indcall-1-pseudoc.s: Likewise.
	* testsuite/gas/bpf/atomic-pseudoc.s: Likewise.
	* testsuite/gas/bpf/alu32-pseudoc.s: Likewise.
	* testsuite/gas/bpf/*.d: Add -pseudoc variants of the tests.
2023-04-26 19:28:06 +02:00
Guillermo E. Martinez
ff5a51b377 gas: support for the BPF pseudo-c assembly syntax
This patch adds support to the GNU assembler for an alternative
assembly syntax used in BPF.  This syntax is C-like and very
unconventional for an assembly language, but it is generated by
clang/llvm and is also used in inline asm templates in kernel code, so
we ought to support it.

After this patch, the assembler is able to parse instructions in both
supported syntax: the normal assembly-like syntax and the pseudo-C
syntax.  Instruction formats can be mixed in the source program: the
assembler recognizes the right syntax to use.

gas/ChangeLog:

2023-04-20  Guillermo E. Martinez  <guillermo.e.martinez@oracle.com>

	PR gas/29728
	* config/tc-bpf.h (TC_EQUAL_IN_INSN): Define.
	* config/tc-bpf.c (LEX_IS_SYMBOL_COMPONENT): Define.
	(LEX_IS_WHITESPACE): Likewise.
	(LEX_IS_NEWLINE): Likewise.
	(LEX_IS_ARITHM_OP): Likewise.
	(LEX_IS_STAR): Likewise.
	(LEX_IS_CLSE_BR): Likewise.
	(LEX_IS_OPEN_BR): Likewise.
	(LEX_IS_EQUAL): Likewise.
	(LEX_IS_EXCLA): Likewise.
	(ST_EOI): Likewise.
	(MAX_TOKEN_SZ): Likewise.
	(init_pseudoc_lex): New function.
	(md_begin): Call init_pseudoc_lex.
	(valid_expr): New function.
	(build_bpf_non_generic_load): Likewise.
	(build_bpf_atomic_insn): Likewise.
	(build_bpf_jmp_insn): Likewise.
	(build_bpf_arithm_insn): Likewise.
	(build_bpf_endianness): Likewise.
	(build_bpf_load_store_insn): Likewise.
	(look_for_reserved_word): Likewise.
	(is_register): Likewise.
	(is_cast): Likewise.
	(get_token): Likewise.
	(bpf_pseudoc_to_normal_syntax): Likewise.
	(md_assemble): Try pseudo-C syntax if an instruction cannot be
	parsed.
2023-04-26 19:27:41 +02:00
mengqinggang
a02676b77d Symbols with GOT relocatios do not fix adjustbale
gas
    * config/tc-loongarch.c (loongarch_fix_adjustable): Symbols with GOT relocatios do not fix adjustbale.
    * testsuite/gas/loongarch/macro_op_large_abs.d: Regenerated.
    * testsuite/gas/loongarch/macro_op_large_pc.d: Regenerated.
  ld
     * testsuite/ld-loongarch-elf/macro_op.d: Regenerated. -
2023-04-18 11:49:21 +01:00
Thomas Koenig
01996a7a49 Assembler Internal Docs: Describe handling of opcodes for relaxation a bit better. 2023-04-18 11:21:58 +01:00
Claudiu Zissulescu
bd6750f0c4 arc: Update ARC's CFI tests.
The double store/loads instructions (e.g. STD/LDD) are not baseline
ARC ISA.  The same holds for some short instructions.  Update the
tests to use base ARC ISA.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-04-13 10:31:06 +03:00
Claudiu Zissulescu
3b637883d4 arc: Update GAS test
Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2023-04-13 10:05:00 +03:00
Nick Clifton
2dd1c6e88a Fix assembler documentation regarding data directives.
PR 30206
 * doc/as.texi (Pseudo Ops): Document that data directives such as .byte and .int are not intended for encoding instructions.
2023-03-14 11:19:45 +00:00
Richard Ball
31f2faf5cf [Aarch64] Add Binutils support for MEC
This change supports MEC which is part of RME (Realm Management Extension).
2023-02-28 10:55:25 +00:00
Benson Muite
8034b0baea Do not change the timestamp when updating the gas asconfig file.
PR 28909 * doc/local.mk (asconfig.texi): Use "cp -p" to preserve timestamps. * Makefile.in: Regenerate.
2023-02-27 13:35:49 +00:00
Nick Clifton
4788abdec7 Fix compilation of the assembler with sanitization enabled.
* dwarf2dbg.c (emit_inc_line_addr): Use unsigned constants when checking addr_delta.
2023-02-01 09:49:07 +00:00
Frederic Cambus
2e175383bf Add OpenBSD ARM GAS support. 2023-01-20 10:46:37 +00:00
Nick Clifton
69373ba164 Updated translations for the gas and binutils sub-directories 2023-01-16 10:45:38 +00:00
Nick Clifton
e8b4b7b258 Fix a translation problem in the x86 assembler.
PR 29952
	* config/tc-i386.c (md_assemble): Avoid constructing translatable
	strings.
2023-01-03 12:03:02 +00:00
Nick Clifton
11982f9f8b Updated translations for various languages and sub-directories 2023-01-03 11:32:42 +00:00
Alan Modra
d87bef3a7b Update year range in copyright notice of binutils files
The newer update-copyright.py fixes file encoding too, removing cr/lf
on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and
embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2023-01-01 21:50:11 +10:30
Nick Clifton
a72b07181d Add markers for 2.40 branch 2022-12-31 12:05:28 +00:00
Nick Clifton
1a7e622b82 Fix ARM and AArch64 assembler tests to work in a multi-arch environment.
PR 29764
gas	* testsuite/gas/arm/cpu-cortex-a76ae.d: Add arm prefix to the -m
	option passed to objdump.
	* testsuite/gas/arm/cpu-cortex-a77.d: Likewise.
	* testsuite/gas/aarch64/cpu-cortex-a76ae.d: Add aarch64 prefix to
	the -m option passed to objdump.
	* testsuite/gas/aarch64/cpu-cortex-a77.d: Likewise.

bfd	* cpu-arm.c (scan): Accept machine names prefixed with "arm:".
	* cpu-aarch64.c (scan): Accept machine names prefixed with "aarch64:".

bin	* doc/binutils.texi (objdump): Note that the -m option supports
	the <architecture>:<machine> syntax.
2022-11-21 16:44:02 +00:00
Yoshinori Sato
de1fbe7889 RX assembler: switch arguments of thw MVTACGU insn. 2022-10-31 10:46:37 +00:00
Nick Clifton
12509439a1 Re: Error: attempt to get value of unresolved symbol `L0'
* symbols.c (S_GET_VALUE): If the unresolved symbol is the fake
	label provide a more helpful error message to the user.
	(S_GET_VALUE_WHERE): Like S_GET_VALUE, but includes a file/line
	number for error reporting purposes.
	* symbols.h (S_GET_VALUE_WHERE): Prototype.
	* write.c (fixup_segment): Use S_GET_VALUE_WHERE.
2022-10-11 15:29:03 +01:00
Nick Clifton
029b1ee8d8 Error: attempt to get value of unresolved symbol `L0'
* symbols.c (S_GET_VALUE): If the unresolved symbol is the fake
	label provide a more helpful error message to the user.
2022-10-11 11:52:38 +01:00
Nick Clifton
7ebd68d142 The help document of as misses some many options
PR 29623
	* as.c (show_usage): Document the --dump-config,
	--gdwarf-cie-version, --hash-size, --multibyte-handling,
	and --reduce-memory-overheads options.
	* config/tc-i386.c (md_show_usage): Document the -O option.
	* doc/as.texi: Document the --dump-config, --emulation,
	--hash-size, and --reduce-memory-overheads options.
2022-09-28 12:56:04 +01:00
Nick Clifton
0ee31dffb8 Gas generated incorrect debug info (top-level DW_TAG_unspecified_type DIE)
PR 29559
	* dwarf2dbg.c (out_debug_info): Place DW_TAG_unspecified_type at
	the end of the list of children, not at the start of the CU
	information.
	* testsuite/gas/elf/dwarf-3-func.d: Update expected output.
	* testsuite/gas/elf/dwarf-5-func-global.d: Likewise.
	* testsuite/gas/elf/dwarf-5-func-local.d: Likewise.
	* testsuite/gas/elf/dwarf-5-func.d: Likewise.
2022-09-08 12:43:33 +01:00
Frederic Cambus
6472b2302d Add OpenBSD AArch64 GAS support.
* configure.tgt (aarch64*-*-openbsd*): Add target.
2022-08-31 15:50:04 +01:00
Nick Clifton
6f4eb56ec7 Add a testcase for PR 29494.
PR 29494
	* testsuite/gas/arm/pr29494.s: New test source file.
	* testsuite/gas/arm/pr29494.d: New test driver.
2022-08-30 13:46:11 +01:00
Nick Clifton
5578fbf672 GAS: Add a return type tag to DWARF DIEs generated for function symbols.
PR 29517
	* dwarf2dbg.c (GAS_ABBREV_COMP_UNIT): New defined constant.
	(GAS_ABBREV_SUBPROG): New defined constant.
	(GAS_ABBREV_NO_TYPE): New defined constant.
	(out_debug_abbrev): Use the new defined constants when emitting
	abbreviation numbers.  Generate an abbreviation for an unspecified
	type.
	(out_debug_info): Use the new defined constants when referring to
	abbreviations.  Generate a use of the no_type abbreviation.
	Reference the use when generating DIEs for functions.
	* testsuite/gas/elf/dwarf-3-func.d: Update to allow for newly
	extended output from the assembler.
	* testsuite/gas/elf/dwarf-5-func-global.d: Likewise.
	* testsuite/gas/elf/dwarf-5-func-local.d: Likewise.
	* testsuite/gas/elf/dwarf-5-func.d: Likewise.
2022-08-25 11:48:00 +01:00
Nick Clifton
e8f2052623 GAS: Allow AArch64 pseudo-ops to accept the command line separator character.
PR 29519
	* config/tc-aarch64.c (s_unreq): Use find_end_of_line().
	(s_aarch64_cpu): Likewise.
	(s_aarch64_arch): Likewise.
	(s_aarch64_arch_extension): Likewise.
	* testsuite/gas/aarch64/pr29519.d: New test driver file.
	* testsuite/gas/aarch64/pr29519.s: New test source file.
2022-08-25 11:39:50 +01:00
Tsukasa OI
d7872ebb65 Mach-O: i18n enablement on some error messages.
* config/obj-macho.c (obj_mach_o_get_section_names): Wrap two
	string literals within with gettext macro.
2022-08-08 12:41:30 +01:00
Nick Clifton
5858ac626e When gas/read.c calls mbstowcs with a NULL destination, it should set size to 0
PR 29447
	* read.c (read_symbol_name): Pass 0 as the length parameter when
	invoking mbstowc in order to check the validity of a wide string.
2022-08-05 10:29:48 +01:00
Claudiu Zissulescu
5154216259 arc: Update missing cipher.
The ciphers 5,7, and 9 are missing when parsing an assembly
instruction leading to errors when those ciphers are
used.

gas/config
	* tc-arc.c (md_assembly): Update strspn string with the
          missing ciphers.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2022-07-18 14:25:31 +03:00
Nick Clifton
0bd0932314 Add markers for 2.39 branch 2022-07-08 10:41:07 +01:00
Victor Do Nascimento
320f42099a oops - forgot changelog entry for the previous delta. 2022-05-18 16:26:21 +01:00