Commit Graph

115393 Commits

Author SHA1 Message Date
Tom Tromey
2f01a2b9ea Report supportsBreakpointLocationsRequest
While looking at the DAP spec, I noticed that the breakpointLocations
request is gated behind a capability.  This patch changes gdb to
report this capability.

I've also added a comment to explain the fact that arguments to
breakpointLocations are not optional, even though the spec says they
are.
2023-07-27 10:35:00 -06:00
Alan Modra
2902e6682d /DISCARD/ in ld testsuite
The canonical form to discard all sections not mentioned earlier in
the script is
  /DISCARD/ : { *(*) }
not
  /DISCARD/ : { *(.*) }
".*" happens to work with the usual section names starting with a dot,
but let's not promote something not quite right.
2023-07-27 23:38:14 +09:30
Alan Modra
f1036ada3b sh: uninitialised sh_operand_info.type in get_specific
Seen when running gas/testsuite/gas/sh/err-at.s

	* config/tc-sh.c (get_operands): Always init operand type.
	* testsuite/gas/sh/err-at.s: Expect unnecessary extra errors.
2023-07-27 23:38:14 +09:30
Hu, Lin1
cd2908958a Support Intel PBNDKB
gas/ChangeLog:

	* NEWS: Support Intel PBNDKB.
	* config/tc-i386.c: Add pbndkb.
	* doc/c-i386.texi: Document .pbndkb.
	* testsuite/gas/i386/i386.exp: Add PBNDKB tests.
	* testsuite/gas/i386/x86-64.exp: Ditto.
	* testsuite/gas/i386/pbndkb-inval.l: New test.
	* testsuite/gas/i386/pbndkb-inval.s: Ditto.
	* testsuite/gas/i386/x86-64-pbndkb-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-pbndkb.d: Ditto.
	* testsuite/gas/i386/x86-64-pbndkb.s: Ditto.

opcodes/ChangeLog:

	* i386-dis.c (X86_64_0F01_REG_0_MOD_3_RM_7): New.
	(X86_64_0F01_REG_0_MOD_3_RM_7_P_0): Ditto.
	(prefix_table): Add PREFIX_0F01_REG_0_MOD_3_RM_7.
	(x86_64_table): Add X86_64_0F01_REG_0_MOD_3_RM_7_P_0.
	(rm_table): New entry for pbndkb.
	* i386-gen.c (cpu_flag): Add PBNDKB.
	* i386-init.h: Regenerated.
	* i386-mnem.h: Ditto.
	* i386-opc.h (CpuPBNDKB): New.
	(i386_cpu_flags): Add cpupbndkb.
	* i386-opc.tbl: Add PBNDKB instructions.
	* i386-tbl.h: Regenerated.
2023-07-27 20:52:52 +08:00
Haochen Jiang
2bced1684b Support Intel SM4
gas/ChangeLog:

	* NEWS: Support Intel SM4.
	* config/tc-i386.c: Add sm4.
	* doc/c-i386.texi: Document .sm4.
	* testsuite/gas/i386/i386.exp: Run SM4 tests.
	* testsuite/gas/i386/x86-64.exp: Ditto.
	* testsuite/gas/i386/sm4-intel.d: Add SM4 tests.
	* testsuite/gas/i386/sm4.d: Ditto.
	* testsuite/gas/i386/sm4.s: Ditto.
	* testsuite/gas/i386/x86-64-sm4-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-sm4.d: Ditto.
	* testsuite/gas/i386/x86-64-sm4.s: Ditto.

opcodes/ChangeLog:

	* i386-dis.c (prefix_table): Add SM4 instructions.
	* i386-gen.c (isa_dependencies): Add SM4.
	(cpu_flags): Ditto.
	* i386-init.h: Regenerated.
	* i386-mnem.h: Ditto.
	* i386-opc.h (CpuSM4): New.
	(i386_cpu_flags): Add cpusm4.
	* i386-opc.tbl: Add SM4 instructions.
	* i386-tbl.h: Regenerated.
2023-07-27 20:52:46 +08:00
Haochen Jiang
c55ba32b7a Support Intel SM3
gas/ChangeLog:

	* NEWS: Support Intel SM3.
	* config/tc-i386.c: Add sm3.
	* doc/c-i386.texi: Document .sm3.
	* testsuite/gas/i386/i386.exp: Run sm3 tests.
	* testsuite/gas/i386/x86-64.exp: Ditto.
	* testsuite/gas/i386/sm3-intel.d: New test.
	* testsuite/gas/i386/sm3.d: Ditto.
	* testsuite/gas/i386/sm3.s: Ditto.
	* testsuite/gas/i386/x86-64-sm3-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-sm3.d: Ditto.
	* testsuite/gas/i386/x86-64-sm3.s: Ditto.

opcodes/ChangeLog:

	* i386-dis.c (PREFIX_VEX_0F38DA_W_0): New.
	(VEX_LEN_0F38DA_W_0_P_0): Ditto.
	(VEX_LEN_0F38DA_W_0_P_2): Ditto.
	(VEX_LEN_0F3ADE_W_0): Ditto.
	(VEX_W_0F38DA): Ditto.
	(VEX_W_0F3ADE): Ditto.
	(prefix_table): Add PREFIX_VEX_0F38DA_W_0.
	(vex_len_table): Add VEX_LEN_0F38DA_W_0_P_0,
	VEX_LEN_0F38DA_W_0_P_2, VEX_LEN_0F3ADE_W_0.
	(vex_w_table): Add VEX_W_0F38DA, VEX_W_0F3ADE.
	* i386-gen.c (isa_dependencies): Add SM3.
	(cpu_flags): Ditto.
	* i386-init.h: Regenerated.
	* i386-mnem.h: Ditto.
	* i386-opc.h (CpuSM3): New.
	(i386_cpu_flags): Add cpusm3.
	* i386-opc.tbl: Add SM3 instructions.
	* i386-tbl.h: Regenerated.
2023-07-27 20:52:25 +08:00
Haochen Jiang
3ac2eb9481 Support Intel SHA512
gas/ChangeLog:

	* NEWS: Support Intel SHA512.
	* config/tc-i386.c: Add sha512.
	* doc/c-i386.texi: Document .sha512.
	* testsuite/gas/i386/disassem.d: Add SHA512 tests.
	* testsuite/gas/i386/disassem.s: Ditto.
	* testsuite/gas/i386/i386.exp: Run SHA512 tests.
	* testsuite/gas/i386/x86-64.exp: Ditto.
	* testsuite/gas/i386/sha512-intel.d: New test.
	* testsuite/gas/i386/sha512-inval.l: Ditto.
	* testsuite/gas/i386/sha512-inval.s: Ditto.
	* testsuite/gas/i386/sha512.d: Ditto.
	* testsuite/gas/i386/sha512.s: Ditto.
	* testsuite/gas/i386/x86-64-sha512-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-sha512-inval.l: Ditto.
	* testsuite/gas/i386/x86-64-sha512-inval.s: Ditto.
	* testsuite/gas/i386/x86-64-sha512.d: Ditto.
	* testsuite/gas/i386/x86-64-sha512.s: Ditto.

opcodes/ChangeLog:

	* i386-dis.c (Rxmmq): New.
	(Rymm): Ditto.
	(PREFIX_VEX_0F38CB): Ditto.
	(PREFIX_VEX_0F38CC): Ditto.
	(PREFIX_VEX_0F38CD): Ditto.
	(VEX_LEN_0F38CB_P_3_W_0): Ditto.
	(VEX_LEN_0F38CC_P_3_W_0): Ditto.
	(VEX_LEN_0F38CD_P_3_W_0): Ditto.
	(VEX_W_0F38CB_P_3): Ditto.
	(VEX_W_0F38CC_P_3): Ditto.
	(VEX_W_0F38CD_P_3): Ditto.
	(prefix_table): Add PREFIX_VEX_0F38CB, PREFIX_VEX_0F38CC,
	PREFIX_VEX_0F38CD.
	(vex_len_table): Add VEX_LEN_0F38CB_P_3_W_0,
	VEX_LEN_0F38CC_P_3_W_0, VEX_LEN_0F38CD_P_3_W_0.
	(vex_w_table): Add VEX_W_0F38CB_P_3, VEX_W_0F38CC_P_3, VEX_W_0F38CD_P_3.
	* i386-gen.c (isa_dependencies): Add SHA512.
	(cpu_flags): Ditto.
	* i386-init.h: Regenerated.
	* i386-mnem.h: Ditto.
	* i386-opc.h (CpuSHA512): New.
	(i386_cpu_flags): Add cpusha512.
	* i386-opc.tbl: Add SHA512 instructions.
	* i386-tbl.h: Regenerated.
2023-07-27 20:52:17 +08:00
konglin1
3fde5f6e7d Support Intel AVX-VNNI-INT16
gas/ChangeLog:

	* NEWS: Support Intel AVX-VNNI-INT16.
	* config/tc-i386.c: Add avx_vnni_int16.
	* doc/c-i386.texi: Document avx_vnni_int16.
	* testsuite/gas/i386/i386.exp: Run AVX VNNI INT16 tests.
	* testsuite/gas/i386/x86-64.exp: Ditto.
	* testsuite/gas/i386/avx-vnni-int16-intel.d: New test.
	* testsuite/gas/i386/avx-vnni-int16.d: New test.
	* testsuite/gas/i386/avx-vnni-int16.s: New test.
	* testsuite/gas/i386/x86-64-avx-vnni-int16-intel.d: New test.
	* testsuite/gas/i386/x86-64-avx-vnni-int16.d: New test.
	* testsuite/gas/i386/x86-64-avx-vnni-int16.s: New test.

opcodes/ChangeLog:

	* i386-dis.c (PREFIX_VEX_0F38D2_W_0): New.
	(PREFIX_VEX_0F38D3_W_0): Ditto.
	(VEX_W_0F38D2_P_0): Ditto.
	(VEX_W_0F38D2_P_1): Ditto.
	(VEX_W_0F38D2_P_2): Ditto.
	(VEX_W_0F38D3_P_0): Ditto.
	(VEX_W_0F38D3_P_1): Ditto.
	(VEX_W_0F38D3_P_2): Ditto.
	(prefix_table): Add PREFIX_VEX_0F38D2_W_0 and
	PREFIX_VEX_0F38D3_W_0.
	(vex_table): Add VEX_W_0F38D2 and VEX_W_0F38D3.
	(vex_w_table): Ditto.
	* i386-gen.c (isa_dependencies): Add AVX_VNNI_INT16.
	(cpu_flag): Ditto.
	* i386-init.h: Regenerated.
	* i386-mnem.h: Ditto.
	* i386-opc.h: (CpuAVX_VNNI_INT16): New.
	* i386-opc.tbl: Add Intel AVX_VNNI_INT16 instructions.
	* i386-tbl.h: Regenerated.
2023-07-27 20:51:20 +08:00
GDB Administrator
513c7e5f3e Automatic date update in version.in 2023-07-27 00:00:41 +00:00
Tom de Vries
afca9a9b45 [gdb/testsuite] Fix gdb.python/py-thread-exited.exp
Two fixes in gdb.python/py-thread-exited.exp:
- fix the copyright notice validity range (PR testsuite/30687):
  2022-202 -> 2022-2023, and
- add missing "require allow_python_tests".

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30687
2023-07-26 21:40:01 +02:00
David Faust
9d1e07bd19 bpf: accept # as an inline comment char
This little patch makes the BPF assembler accept '#' as an inline
comment character, which clang -S seems to use.

gas/
	* config/tc-bpf.c (comment_chars): Add '#'.
	* doc/c-bpf.texi (BPF Special Characters): Add note that '#' may
	be used for inline comments.
2023-07-26 08:22:31 -07:00
Tom de Vries
200546f1a3 [gdb/build] Fix Wstringop-truncation in coff_getfilename
When building gdb with -O2 -fsanitize-threads, I ran into
a Werror=stringop-truncation.

The problem is here in coff_getfilename in coffread.c:
...
      strncpy (buffer, aux_entry->x_file.x_n.x_fname, FILNMLEN);
      buffer[FILNMLEN] = '\0';
...

The constant FILNMLEN is expected to designate the size of
aux_entry->x_file.x_n.x_fname, but that's no longer the case since commit
60ebc25751 ("Fixes a buffer overflow when compiling assembler for the MinGW
targets.").

Fix this by using "sizeof (aux_entry->x_file.x_n.x_fname)" instead.

Likewise in xcoffread.c.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>

PR build/30669
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30669
2023-07-26 17:06:23 +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
Tom de Vries
bcf43b33cf [gdb/testsuite] Drop -nostdlib in gdb.dwarf2/typeddwarf.exp
As reported in PR testsuite/30633, when running test-case
gdb.dwarf2/typeddwarf.exp with target board native-gdbserver on Ubuntu
22.04.2, we run into:
...
(gdb) continue^M
Continuing.^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0x0000000000000001 in ?? ()^M
(gdb) FAIL: gdb.dwarf2/typeddwarf.exp: runto: run to main
...

We run into the FAIL as follows:
- due to using gdbserver, we attach at the point of the first instruction, in
  _start
- we then set a breakpoint at main
- the test-case is a .s file, that has main renamed to _start in the assembly,
  but not in the debuginfo
- setting a breakpoint at main sets the breakpoint at the same instruction
  we're currently stopped at
- continue doesn't hit the breakpoint, and we return out of _start, which
  causes a sigsegv

Note that this is for the amd64 case (using gdb.dwarf2/typeddwarf-amd64.S).
For the i386 case (using gdb.dwarf2/typeddwarf.S), setting a breakpoint in
main sets it one insn after function entry, and consequently the problem does
not occur.

The FAIL is a regression since commit 90cce6c055 ("[gdb/testsuite] Add nopie
in a few test-cases").

Without nopie the executable is PIE, with nopie it's static instead.

In the PIE case, we attach at the point of _start in the dynamic linker, and
consequently we do not skip the breakpoint in main, and also don't run into
the FAIL.

Fix this by:
- removing the -nostdlib setting, and
- renaming _start to main in both .S files.

The change to use -nostdlib and rename main to _start was originally added
in commit 6edba76fe8 (submitted here:
https://sourceware.org/pipermail/gdb-patches/2011-May/082657.html ) , I assume
to fix the problem now fixed by using nopie.

Tested on x86_64-linux.

Reported-By: Simon Marchi <simon.marchi@efficios.com>
Tested-By: Simon Marchi <simon.marchi@efficios.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30633
2023-07-26 13:42:32 +02:00
Tom de Vries
87c9b0289d [gdb/tui] Fix secondary prompt
With CLI, a session defining a command looks like:
...
(gdb) define foo
Type commands for definition of "foo".
End with a line saying just "end".
>bar
>end
(gdb)
...

With TUI however, we get the same secondary prompts, and type the same, but
are left with:
...
(gdb) define foo
Type commands for definition of "foo".
End with a line saying just "end".
(gdb)
...

Fix this by calling tui_inject_newline_into_command_window in
gdb_readline_wrapper_line, as is done in tui_command_line_handler.

Tested on x86_64-linux.

PR tui/30636
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30636
2023-07-26 13:31:53 +02:00
Tom de Vries
2b8bee8b34 [gdb/testsuite] Fix gdb.gdb/python-helper.exp with -O2 -flto=auto and gcc 7.5.0 some more
With a gdb build with -O2 -flto=auto and gcc 7.5.0 and test-case
gdb.gdb/python-helper.exp I run into:
...
(outer-gdb) continue^M
Continuing.^M
print 1^M
^M
Thread 1 "xgdb" hit Breakpoint 2, \
  _Z11value_printP5valueP7ui_filePK19value_print_options (val=0x22e2590, \
  stream=0x1f65480, options=0x7fffffffcdc0) at gdb/valprint.c:1193^M
1193    {^M
(outer-gdb) FAIL: gdb.gdb/python-helper.exp: hit breakpoint in outer gdb
...

This is the "value_print" variant of the problem with "c_print_type" I fixed
in commit 0d332f1112 ("[gdb/testsuite] Fix gdb.gdb/python-helper.exp with -O2
 -flto=auto and gcc 7.5.0").

Fix this likewise.

Tested on x86_64-linux.
2023-07-26 13:28:15 +02:00
Tom de Vries
c0afd99439 [gdb/tui] Fix assert in ~gdbpy_tui_window_maker
In gdb/tui/tui-layout.c, we have:
...
static window_types_map known_window_types;
...
and in gdb/python/py-tui.c:
...
  /* A global list of all gdbpy_tui_window_maker objects.  */
  static intrusive_list<gdbpy_tui_window_maker> m_window_maker_list;
};

/* See comment in class declaration above.  */

intrusive_list<gdbpy_tui_window_maker>
  gdbpy_tui_window_maker::m_window_maker_list;
...

With a gdb build with -O0 or -O2, the static destructor calling order seems to be:
- first gdb/tui/tui-layout.c,
- then gdb/python/py-tui.c.

So when running test-case gdb.python/tui-window-factory.exp, we see the
following order of events:
- the destructor for known_window_types is called, which triggers calling the
  destructor for the only element E of m_window_maker_list.  The destructor
  destroys E, and also removes E from m_window_maker_list, leaving it empty.
- the destructor for m_window_maker_list is called.  It's empty, so it's a nop.

However, when building gdb with -O2 -flto=auto, the static destructor calling
order seems to be reversed.

Instead, we have these events:
- the destructor for m_window_maker_list is called.  This doesn't destroy it's
  only element E, but it does make m_window_maker_list empty.
- the destructor for known_window_types is called, which triggers calling the
  destructor for E.  An attempt is done to remove E from m_window_maker_list,
  but we run into an assertion failure, because the list is empty.

Fix this by checking is_linked () before attempting to remove from
m_window_maker_list, similar to how things were addressed in commit 995a34b177
("Guard against frame.c destructors running before frame-info.c's").

Tested on x86_64-linux.

PR tui/30646
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30646
2023-07-26 12:29:28 +02:00
Tom de Vries
906c2c6564 [gdb/testsuite] Fix regexps in gdb.base/step-over-syscall.exp
When running test-case gdb.base/step-over-syscall.exp without glibc debuginfo
installed, I get:
...
(gdb) continue^M
Continuing.^M
^M
Breakpoint 2, 0x00007ffff7d4405e in vfork () from /lib64/libc.so.6^M
(gdb) PASS: gdb.base/step-over-syscall.exp: vfork: displaced=off: \
  continue to vfork (1st time)
...
but with glibc debuginfo installed I get instead:
...
(gdb) continue^M
Continuing.^M
^M
Breakpoint 2, 0x00007ffff7d4405e in __libc_vfork () at \
  ../sysdeps/unix/sysv/linux/x86_64/vfork.S:44^M
44      ENTRY (__vfork)^M
(gdb) FAIL: gdb.base/step-over-syscall.exp: vfork: displaced=off: \
  continue to vfork (1st time)
...

The FAIL is due to a mismatch with regexp:
...
  "Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*"
...
because it cannot match both ".* in " and the __libc_ prefix.

Fix this by using instead the regexp:
...
  "Breakpoint \[0-9\]+, (.* in )?(__libc_)?$syscall \\(\\).*"
...

Tested on x86_64-linux.
2023-07-26 11:53:31 +02:00
Jose E. Marchesi
4200337219 bpf: fix neg and neg32 BPF instructions in simulator
This patch fixes the semantics of the neg and neg32 BPF instructions
in the simulator, and also updates the corresponding tests
accordingly.

Tested in target bpf-unknown-none.
2023-07-26 11:44:20 +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
Alan Modra
477c9f2ba2 PR30657, gprof heap buffer overflow
PR 30657
	* cg_arcs.c (cg_assemble): Sanity check find_call addresses.
	* i386.c (i386_find_call): Don't access past end of core_text_space.
	* aarch64.c (aarch64_find_call): Round up lowpc, round down highpc.
	* alpha.c (alpha_find_call): Likewise.
	* mips.c (mips_find_call): Likewise.
	* sparc.c (sparc_find_call): Likewise.
	* vax.c (vax_find_call): Sanity check core_text_space accesses.
2023-07-26 10:23:27 +09:30
Alan Modra
eb14a8b4bf [GOLD] reporting local symbol names
get_symbol_name currently returns "" for the usual STT_SECTION symbols
generated by gas.  That's not very helpful, return the section name.
Demangle local symbols too, fixing an inconsistency in
issue_discarded_error where global symbols are demangled.

	* object.cc (Sized_relobj_file::get_symbol_name): Return a
	std::string.  Return section name for STT_SECTION symbols with
	zero st_name.  Sanity check st_name, and don't run off the end
	of an improperly terminated .strtab.  Demangle sym names.
	* object.h (Sized_relobj_file::get_symbol_name): Update decl.
	* target-reloc.h (issue_discarded_error): Adjust.
	* powerpc.cc (Target_powerpc::Relocate::relocate): Report reloc
	type and symbol for relocation overflows.
2023-07-26 10:23:27 +09:30
Alan Modra
0d8e39f5ce Don't warn on .attach_to_group to same group
* config/obj-elf.c (obj_elf_attach_to_group): Don't warn if
	group name matches current group for section.
2023-07-26 10:04:31 +09:30
Alan Modra
fafcbd14a7 bpf: format not a string literal
* config/tc-bpf.c (md_assemble): Correct as_bad call.
2023-07-26 10:04:31 +09:30
Alan Modra
af67f1d01d Regen bpf opcodes POTFILE 2023-07-26 10:04:31 +09:30
GDB Administrator
6296109afc Automatic date update in version.in 2023-07-26 00:00:23 +00:00
David Faust
02f68ef297 bpf: Add atomic compare-and-exchange instructions
This patch adds the two remaining BPF v3 atomic instructions:
- BPF_INSN_ACMP{,32}: atomic compare-and-swap
- BPF_INSN_AXCHG{,32}: atomic (non-conditional) exchange

Tests and documentation are also updated.

gas/
	* doc/c-bpf.texi (BPF Instructions): Document atomic exchange and
	atomic compare-and-swap instructions.
	* testsuite/gas/bpf/atomic.s: Test ACMP, ACMP32, AXCHG, AXCGH32
	instructions.
	* testsuite/gas/bpf/atomic.d: Likewise.
	* testsuite/gas/bpf/atomic-be.d: Likewise.
	* testsuite/gas/bpf/atomic-pseudoc.s: Likewise.
	* testsuite/gas/bpf/atomic-pseudoc.d: Likewise.
	* testsuite/gas/bpf/atomic-be-pseudoc.d: Likewise.

include/
	* opcode/bpf.h (BPF_IMM32_ACMP): Fix typo.
	(enum bpf_insn_id): New entries for BPF_INSN_ACMP{,32} and
	BPF_INSN_AXCHG{,32}.

opcodes/
	* bpf-opc.c (bpf_opcodes): Add entries for ACMP{,32} and
	AXCHG{,32} instructions.
2023-07-25 13:40:06 -07:00
David Faust
055a4c8e0f bpf: Update atomic instruction pseudo-C syntax
This patch updates the pseudo-C dialect templates for the BPF v3 atomic
instructions.  The templates match the strings emitted by clang -S for
these instructions.

The tests and documentation are updated accordingly.

gas/
	* doc/c-bpf.texi (BPF Instructions): Update entries for atomic
	and 32-bit atomic instructions.
	* testsuite/gas/bpf/atomic.s: Test AAND, AAND32, AOR, AOR32,
	AXOR, AXOR32, AFADD, AFADD32, AFAND, AFAND32, AFOR, AFOR32,
	AFXOR and AFXOR32 instructions.
	* testsuite/gas/bpf/atomic.d: Likewise.
	* testsuite/gas/bpf/atomic-be.d: Likewise.
	* testsuite/gas/bpf/atomic-pseudoc.s: Likewise.
	* testsuite/gas/bpf/atomic-pseudoc.d: Likewise.
	* testsuite/gas/bpf/atomic-be-pseudoc.d: Likewise.
	* testsuite/gas/bpf/atomic-v1.s: New test.
	* testsuite/gas/bpf/atomic-v1.d: Likewise.
	* testuiste/gas/bpf/atomic-v1-be.d: Likewise.
	* testuiste/gas/bpf/bpf.exp: Run new tests.

opcodes/
	* bpf-opc.c (bpf_opcodes): Update pseudo-C dialect templates for:
	BPF_INSN_AADD, BPF_INSN_AOR, BPF_INSN_AAND, BPF_INSN_AXOR,
	BPF_INSN_AFADD, BPF_INSN_AFOR, BPF_INSN_AFAND, BPF_INSN_AFXOR,
	BPF_INSN_AADD32, BPF_INSN_AOR32, BPF_INSN_AAND32,
	BPF_INSN_AXOR32, BPF_INSN_AFADD32, BPF_INSN_AFOR32,
	BPF_INSN_AFAND32, and BPF_INSN_AFXOR32 instructions.
2023-07-25 13:10:15 -07:00
Tsukasa OI
695776dc2f RISC-V: Enable RVC on ".option arch, +zca" etc.
Since the 'Zca' extension is the new base of the compressed instructions,
this commit enables RVC *also* when the 'Zca' extension is enabled
via ".option arch" directive.

gas/ChangeLog:

	* config/tc-riscv.c (s_riscv_option): Enable RVC also when the
	'Zca' extension is enabled after an ".option arch" directive.
2023-07-25 01:42:44 +00:00
GDB Administrator
3dfee72010 Automatic date update in version.in 2023-07-25 00:00:25 +00:00
Tsukasa OI
6e30678feb RISC-V: Implications from 'Zc[fd]' extensions
The version 1.0.4-1 of the code size reduction specification clarifies
that 'Zcf' implies 'F' and 'Zcd' implies 'D'.

cf:
<https://github.com/riscv/riscv-code-size-reduction/releases/tag/v1.0.4-1>

This commit adds those implications.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_implicit_subsets): Add two implications,
	'Zcf' -> 'F' and 'Zcd' -> 'D'.

gas/ChangeLog:

	* testsuite/gas/riscv/march-imply-zcd.d: New test.
	* testsuite/gas/riscv/march-imply-zcf.d: New test.
2023-07-24 23:42:35 +00:00
Tsukasa OI
766f6d170c RISC-V: Prohibit the 'Zcf' extension on RV64
As per:
<https://github.com/riscv/riscv-code-size-reduction/issues/221>,
the 'Zcf' extension does not exist on RV64.  This is reflected on the
version 1.0.4-1 of the code size reduction specification:
<https://github.com/riscv/riscv-code-size-reduction/releases/tag/v1.0.4-1>.

This commit prohibits the combination: RV64 (or any ISA with XLEN > 32)
and the 'Zcf' extension.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_parse_check_conflicts): Prohibit
	combination of RV64 and 'Zcf'.

gas/ChangeLog:

	* testsuite/gas/riscv/march-fail-rv64i_zcf.d: New test.
	* testsuite/gas/riscv/march-fail-rv64i_zcf.l: Likewise.
2023-07-24 23:42:35 +00:00
Johannes Schauer Marin Rodrigues
6badd1020f objcopy embeds the current time and ignores SOURCE_DATE_EPOCH making the output unreproducible.
bfd
  * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): If inserting a timestamp, use the value held in the SOURCE_DATE_EPOCH environment variable, if it is defined.
binutils
  * doc/binutils.texi (objcopy): Document change in behaviour of objcopy's --preserve-dates command line option.
ld
  * pe-dll.c (fill_edata): If inserting a timestamp, use the value held in the SOURCE_DATE_EPOCH environment variable, if it is defined.
  * ld.texi (--insert-timestamp): Document change in behaviour.
2023-07-24 16:59:19 +01:00
Nick Clifton
4701770c57 Updated translations for bfd, gold and opcodes 2023-07-24 09:13:29 +01:00
mengqinggang
3fa45fb168 LoongArch: ld: Simplify inserting IRELATIVE relocations to .rela.dyn
In LoongArch, the R_LARCH_IRELATIVE relocations for local ifunc symbols are
in .rela.dyn. Before, this is done by loongarch_elf_finish_dynamic_sections.
But this function is called after elf_link_sort_relocs, it need to find a
null slot to insert IRELATIVE relocation.

Now, it is processed by elf_loongarch_output_arch_local_syms before
elf_link_sort_relocs, just need to call loongarch_elf_append_rela to
insert IRELATIVE relocation.

bfd/ChangeLog:

	* elfnn-loongarch.c (elfNN_allocate_local_ifunc_dynrelocs): Return
	type change to int.
	(loongarch_elf_size_dynamic_sections): Delete (void *).
	(loongarch_elf_finish_dynamic_symbol): Use loongarch_elf_append_rela
	insert IRELATIVE relocation to .rela.dyn.
	(elfNN_loongarch_finish_local_dynamic_symbol): Return type change to
	int.
	(loongarch_elf_finish_dynamic_sections): Delete process of local
	ifunc symbols.
	(elf_backend_output_arch_local_syms): New.

ld/ChangeLog:

	* testsuite/ld-loongarch-elf/local-ifunc-reloc.d: Regenerated.
2023-07-24 11:22:42 +08:00
mengqinggang
a38b0c05b6 LoongArch: Fix immediate overflow check bug
For B16/B21/B26/PCREL20_S2 relocations, if immediate overflow check after
rightshift, and the mask need to include sign bit.

Now, the immediate overflow check before rightshift for easier understand.

bfd/ChangeLog:

	* elfxx-loongarch.c (reloc_bits_pcrel20_s2): Delete.
	(reloc_bits_b16): Delete.
	(reloc_bits_b21): Delete.
	(reloc_bits_b26): Delete.
	(reloc_sign_bits): New.
2023-07-24 11:22:42 +08:00
mengqinggang
378535f277 LoongArch: Fix instruction immediate bug caused by sign-extend
For extreme code mode, the instruction sequences is
    pcalau12i $t0, hi20
    addi.d $t1, $zero, lo12
    lu32i.d $t1, lo20
    lu52i.d $t1, hi12
    add.d $t1, $t0, $t1

If lo12 > 0x7ff, hi20 need to add 0x1, lo20 need to sub 0x1.
If hi20 > 0x7ffff, lo20 need to add 0x1.

bfd/ChangeLog:

	* elfnn-loongarch.c (RELOCATE_CALC_PC32_HI20): Redefined.
	(RELOCATE_CALC_PC64_HI32): Redefined.
2023-07-24 11:22:42 +08: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
GDB Administrator
167991e60e Automatic date update in version.in 2023-07-24 00:00:23 +00: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
Tom Tromey
338b21b088 Use 'name' in DAP start_thread function
The DAP start_thread helper function has a 'name' parameter that is
unused.  Apparently I forgot to hook it up to the thread constructor.
This patch fixes the oversight.
2023-07-23 15:08:40 -06:00
Tom Tromey
560c121c20 Export gdb.block_signals and create gdb.Thread
While working on an experiment, I realized that I needed the DAP
block_signals function.  I figured other developers may need it as
well, so this patch moves it from DAP to the gdb module and exports
it.

I also added a new subclass of threading.Thread that ensures that
signals are blocked in the new thread.

Finally, this patch slightly rearranges the documentation so that
gdb-side threading issues and functions are all discussed in a single
node.
2023-07-23 14:33:44 -06:00
Andrew Burgess
8a9da63e40 gdb: two changes to linux_nat_debug_printf calls in linux-nat.c
This commit adjusts some of the debug output in linux-nat.c, but makes
no other functional changes to GDB.

In resume_lwp I've added the word "sibling" to one of the debug
messages.  All the other debug messages in this function talk about
operating on the sibling thread, so I think it makes sense, for
consistency, if the message I've updated also talks about the sibling
thread.

In resume_stopped_resumed_lwps I've reordered the condition checks so
that the vfork-parent check now happens after the checks for whether
the thread is already resumed or not.  This makes no functional
difference to GDB, but does, I think, mean we see more helpful debug
messages first.

Consider the situation where a vfork-parent thread is already resumed,
and resume_stopped_resumed_lwps is called.  Previously the message
saying that the thread was not being resumed due to being a
vfork-parent, was printed.  This might give the impression that the
thread is left in a not resumed state, which is misleading.

After this change we now get a message saying that the thread is not
being resumed due to it not being stopped (i.e. is already resumed).
With this message the already resumed nature of the thread is much
clearer.

I found this change helpful when debugging some vfork related issues.
2023-07-23 09:28:33 +01:00
Andrew Burgess
dd82bbc1b3 gdb/testsuite: replace $testfile with $binfile in one case
For *reasons* I was hacking on gdb.base/foll-vfork.exp and wanted to
change the name of the binary that was created.  Should be easy, I
adjusted the global $binfile variable .... but that didn't work.

In one place the script uses $testfile instead of $binfile.

Fixed this to use $binfile, now I can easily change the name of the
generated binary, and the test still works.

There's no change in what is tested after this commit.
2023-07-23 09:25:48 +01:00
GDB Administrator
7f9e225fde Automatic date update in version.in 2023-07-23 00:00:19 +00:00
Tom de Vries
b40b1e4f9a [gdb/testsuite] Improve gdb.arch/arm-pthread_cond_timedwait-bt.exp
I noticed in test-case gdb.arch/arm-pthread_cond_timedwait-bt.exp that
prepare_for_testing is used, followed by a clean_restart.

This calls clean_restart twice in a row.

Fix this by using build_executable instead.

Also, I noticed that the test-case requires an SVC instruction, so add a
require to limit the test-case to supported architectures.

While we're at it, run M-x indent-region in emacs to fix indentation.

Tested on x86_64-linux.
2023-07-22 11:00:25 +02:00
Tom de Vries
09075d5d4a [gdb/testsuite] Use proc readnow in two test-cases
Use "require !readnow" in two test-cases, instead of the written-out variant.

Tested on x86_64-linux, with target boards unix and readnow.
2023-07-22 11:00:25 +02:00
GDB Administrator
6fbe38ce11 Automatic date update in version.in 2023-07-22 00:00:19 +00:00