Commit Graph

120301 Commits

Author SHA1 Message Date
Tom de Vries
e031f02db3 [gdbsupport] Handle EINTR in event-pipe.cc
Use gdb syscall wrappers to handle EINTR in event-pipe.cc.

Tested on aarch64-linux.
2024-11-22 17:44:29 +01:00
Tom de Vries
2af94d6c92 [gdb] Handle EINTR in ser-event.c
Use gdb syscall wrappers to handle EINTR in ser-event.c.

Tested on aarch64-linux.
2024-11-22 17:44:29 +01:00
Tom de Vries
4e4dfc4728 [gdb] Add gdb::wait
Add gdb::wait, and use it in gdb/procfs.c, making sure that EINTR is handled.

Tested on x86_64-linux.
2024-11-22 17:44:29 +01:00
Tom de Vries
a9791f1438 [gdb] Use gdb::waitpid more often
Use gdb::waitpid instead of plain waitpid, making sure that EINTR is handled.

Tested on x86_64-linux.
2024-11-22 17:44:29 +01:00
Tom de Vries
658a03e9e8 [gdbsupport] Add gdb::{waitpid,read,write,close}
We have gdb::handle_eintr, which allows us to rewrite:
...
  ssize_t ret;
    do
      {
        errno = 0;
        ret = ::write (pipe[1], "+", 1);
      }
    while (ret == -1 && errno == EINTR);
...
into:
...
  ssize_t ret = gdb::handle_eintr (-1, ::write, pipe[1], "+", 1);
...

However, the call to write got a bit mangled, requiring effort to decode it
back to its original form.

Instead, add a new function gdb::write that allows us to write:
...
  ssize_t ret = gdb::write (pipe[1], "+", 1);
...

Likewise for waitpid, read and close.

Tested on x86_64-linux.
2024-11-22 17:44:29 +01:00
Andrew Burgess
26522e3480 gdb/disasm: fix demangling when disassembling the current function
When disassembling function symbols in C++ code, if GDB is asked to
disassemble a function by name then the function name in the header
line can be demangled by turning on `set print asm-demangle on`, e.g.:

  (gdb) disassemble foo_type::some_function
  Dump of assembler code for function _ZN8foo_type13some_functionE7my_type:
     0x0000000000401142 <+0>:	push   %rbp
     ... etc ...
  End of assembler dump.
  (gdb) set print asm-demangle on
  (gdb) disassemble foo_type::some_function
  Dump of assembler code for function foo_type::some_function(my_type):
     0x0000000000401142 <+0>:	push   %rbp
     ... etc ...                                                        │
  End of assembler dump.                                                │

However, if GDB is disassembling the current function, then this
demangling doesn't work, e.g.:

  (gdb) break foo_type::some_function
  Breakpoint 1 at 0x401152: file mangle.cc, line 16.
  (gdb) run
  Starting program: /tmp/mangle

  Breakpoint 1, foo_type::some_function (this=0x7fffffffa597, obj=...) at mangle.cc:16
  16	    obj.update ();
  (gdb) disassemble
  Dump of assembler code for function _ZN8foo_type13some_functionE7my_type:
     0x0000000000401142 <+0>:	push   %rbp
     ... etc ...
  End of assembler dump.
  (gdb) set print asm-demangle on
  (gdb) disassemble
  Dump of assembler code for function _ZN8foo_type13some_functionE7my_type:
     0x0000000000401142 <+0>:	push   %rbp
     ... etc ...
  End of assembler dump.

This commit fixes this issue, and extends gdb.cp/disasm-func-name.exp,
which was already testing the first case (disassemble by name) to also
cover disassembling the current function.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-22 16:36:07 +00:00
Tom de Vries
8a7f13063a [gdb/python] Ensure locale is restored in do_start_initialization
I noticed in do_start_initialization:
...
  std::string oldloc = setlocale (LC_ALL, NULL);
  setlocale (LC_ALL, "");
  ...
  if (count == (size_t) -1)
    {
      fprintf (stderr, "Could not convert python path to string\n");
      return false;
    }
  setlocale (LC_ALL, oldloc.c_str ());
...
that the old locale is not restored if the "return false" is triggered.

Fix this by using SCOPE_EXIT.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-22 17:34:50 +01:00
Sam James
461248c143
libiberty: sync with gcc again
This imports the following single commit from GCC as of r15-5586-g77f4b1097e6aec:
	961c50410926 Add LTO support

That change slipped in while I was preparing the previous just-pushed sync.
2024-11-22 15:49:50 +00:00
Sam James
dad783716c
libiberty: sync with gcc
This imports the following commits from GCC as of r15-5375-gbeec291225be9b:
	94bea5dd6c9a libiberity: ANSIfy test-demangle.c
	aa84020b2edb libiberty: Fix comment typos
	c1b2100e736c libiberty: Restore build with CP_DEMANGLE_DEBUG defined
	bb8dd0980b39 libiberty: Fix up > 64K section handling in simple_object_elf_copy_lto_debug_section [PR116614]

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-22 15:47:05 +00:00
Tom de Vries
00386b4c68 [gdb/tdep] Simplify amd64_windows_store_arg_in_reg
Simplify amd64_windows_store_arg_in_reg by:
- replacing memset with value initialization,
- making valbuf a gdb::array_view, allowing us to:
  - replace memcpy with std::copy, and
  - use valbuf.size () instead of arg->type->size (), and
- dropping the std::min in std::min (type->length (), (ULONGEST) 8), since
  we're already asserting that type->length () <= 8.

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

Tested by rebuilding on x86_64-linux.
2024-11-22 13:43:03 +01:00
Tom de Vries
2e61ad32ab [gdb/testsuite] Require local host in gdb.base/bg-exec-sigint-bp-cond.exp
I noticed that gdb.base/bg-exec-sigint-bp-cond.exp fails for remote host
(concretely, host board local-remote-host and target board
remote-gdbserver-on-localhost):
...
(gdb) c&^M
Continuing.^M
(gdb) bash: line 0: kill: (23834) - Operation not permitted^M
^M
Breakpoint 2, foo () at bg-exec-sigint-bp-cond.c:23^M
23        return 0;^M
...
due to getting gdb's pid like this:
...
    set gdb_pid [exp_pid -i [board_info host fileid]]
...

For remote host using ssh, this returns the pid of the ssh session on build.

Fix this by requiring local host.

Tested on x86_64-linux.
2024-11-22 13:37:24 +01:00
Tom de Vries
b200576fa0 [gdb/testsuite] Fix gdb.base/bg-exec-sigint-bp-cond.exp for signal merging
The test-case gdb.base/bg-exec-sigint-bp-cond.exp sends 10 SIGINTS to gdb, and
counts whether 10 have arrived.

Occasionally, less than 10 arrive due to signal merging [1].

This is more likely to happen when building gdb with -fsanitize=thread.

Fix this by instead, sending one SIGINT at a time, and waiting for it to
arrive.

This still makes the test-case fail if the fix fixing the PR that the
test-case was introduced for is reverted.

Tested on aarch64-linux and x86_64-linux.

PR testsuite/32329
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32329

[1] https://www.gnu.org/software/libc/manual/html_node/Merged-Signals.html
2024-11-22 13:37:24 +01:00
Tom de Vries
c4df8ad79c [gdb/build] Workaround tsan select bug
When building gdb with -O0 and -fsanitize-thread, I run into a large number of
timeouts caused by gdb hanging, for instance:
...
(gdb) continue^M
Continuing.^M
[Inferior 1 (process 378) exited normally]^M
FAIL: gdb.multi/stop-all-on-exit.exp: continue until exit (timeout)
...

What happens is the following:
- two inferiors are added, stopped at main
- inferior 1 is setup to exit after 1 second
- inferior 2 is setup to exit after 10 seconds
- the continue command is issued
- because of set schedule-multiple on, both inferiors continue
- the first inferior exits
- gdb sends a SIGSTOP to the second inferior
- the second inferior receives the SIGSTOP, and raises a SIGCHILD
- gdb calls select, and blocks
- the signal arrives, and interrupts select
- ThreadSanitizers signal handler is called, which marks the signal pending
  internally
- select returns -1 with errno == EINTR
- gdb calls select again, and blocks
- gdb hangs, waiting for gdb's sigchild_handler to be called

This is a bug [1] in ThreadSanitizer.  When select is called with
timeout == nullptr, it is blocking but ThreadSanitizer doesn't consider it so,
and consequently doesn't see the need to call sigchild_handler.

Work around this by:
- instead of using the blocking select variant, forcing a small timeout and
- upon timeout calling a function that ThreadSanitizer does consider
  blocking: usleep, forcing sigchild_handler to be called.

Tested on x86_64-linux.

PR build/32295
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32295

[1] https://github.com/google/sanitizers/issues/1813
2024-11-22 12:54:57 +01:00
Tom de Vries
dcc4d67866 [gdb] Add gdb_select variant for looping
In interruptible_select we run gdb_select in a loop:
...
  do
    {
      res = gdb_select (n, readfds, writefds, exceptfds, timeout);
    }
  while (res == -1 && errno == EINTR);
...
but man select tells us that:
- if using select() within a loop, the sets (readfds, writefds and
  exceptfds) must be reinitialized before each call, and
- timeout should be considered to be undefined after select() returns.

Add a gdb_select variant:
...
static int
gdb_select (int n,
	    const fd_set *req_readfds, fd_set *ret_readfds,
	    const fd_set *req_writefds, fd_set *ret_writefds,
	    const fd_set *req_exceptfds, fd_set *ret_exceptfds,
	    const struct timeval *req_timeout, struct timeval *ret_timeout)
...
that keeps requested and returned values separate, ensuring that the requested
values stay constant.

Tested on x86_64-linux.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
2024-11-22 12:54:57 +01:00
Martin Storsjö
3c557e1ae9 ld/PE: Handle MS style import libraries for files named *.exe too
When handling MS style import libraries (also called short import
libraries, or ILF), we need to detect the kind of library.

So far, this has been done by looking at the member file names
in the import library - in an MS style import library, all the
member files for a specific library have the same member file
name - the name of the runtime module to link against. Usually
this is a DLL - thus we do a case insensitive comparison and
check if the suffix is .dll.

However, an .exe can also export symbols which can be linked
against in the same way. In particular, if linking against
WDK (Windows Driver Kit) import libraries, e.g. wdmsec.lib, the
import libraries can provide imports for ntoskrnl.exe.

Instead of specifically checking for *.dll (and *.exe, etc),
invert the condition and skip archive members named *.o and *.obj.
For any remaining archive members, that do contain .idata
sections, apply the renaming. (The renaming is also mostly
harmless if applied where it isn't needed; if archive members
already have unique file names, their relative ordering should
remain intact except for very contrieved cases.)

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-11-22 12:39:42 +02:00
Nelson Chu
595e49a4b7 RISC-V: Support SiFive extensions: xsfvqmaccdod, xsfvqmaccqoq and xsfvfnrclipxfqf
Those SiFive extensions have been published on the web for a while, and we plan
to implement intrinsics in GCC for those instructions soon.

NOTE: The original patch was written by Nelson when he was still working at
SiFive, and Kito rebased it to the trunk. Therefore, I kept the author as Nelson
with his SiFive email.

Document links:
xsfvqmaccdod: https://www.sifive.com/document-file/sifive-int8-matrix-multiplication-extensions-specification
xsfvqmaccqoq: https://www.sifive.com/document-file/sifive-int8-matrix-multiplication-extensions-specification
xsfvfnrclipxfqf: https://www.sifive.com/document-file/fp32-to-int8-ranged-clip-instructions

Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
2024-11-22 09:56:54 +08:00
GDB Administrator
87480dcfb6 Automatic date update in version.in 2024-11-22 00:00:17 +00:00
Tom Tromey
29e316d8b1 Don't put JIT_READER_DIR into help text
The 80-column-help-string self-test can fail if gdb's install
directory is too long, because the help for "jit-reader-load" includes
JIT_READER_DIR.

This help text is actually somewhat misleading, though.
JIT_READER_DIR is not actually used directly -- instead the relocated
variant is used.

This patch adds a new "show jit-reader-directory" command and changes
the help text to refer to this instead.  I considered adding a "set"
command as well, but since absolute paths are acceptable here, and
since this is a very niche command anyway, I figured there was no need
to bother.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32357
Reviewed-By: Kévin Le Gouguec <legouguec@adacore.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-11-21 14:08:18 -07:00
Andrew Burgess
9783247189 gdb/build-id: protect against weirdly short build-ids
While looking at build_id_to_bfd_suffix (in gdb/build-id.c) I realised
that GDB would likely not do what we wanted if a build-id was ever a
single byte.

Right now, build-ids generated by the GNU linker are 32 bytes, but
there's nothing that forces this to be the case, it's pretty easy to
create a fake, single byte, build-id.  Given that the build-id is an
external input (read from the objfile), GDB should protect itself
against these edge cases.

The problem with build_id_to_bfd_suffix is that this function creates
the path used to lookup either the debug information, or an
executable, based on its build-id.  So a 3-byte build-id 0xaabbcc will
look in the path: `$DEBUG_FILE_DIRECTORY/.build-id/aa/bbcc.debug`.
However, a single byte build-id 0xaa, will look in the file:
`$DEBUG_FILE_DIRECTORY/.build-id/aa/.debug` which doesn't seem right.

Worse, when looking for an objfile given a build-id GDB will look for
a file called `$DEBUG_FILE_DIRECTORY/.build-id/aa/` with a trailing
'/' character.

I propose that, in build_id_to_bfd_suffix we just return early if the
build-id is 1 byte (or less) with a return value that indicates no
separate file was found.

For testing I made use of the DWARF assembler.  I needed to update the
build-id creation proc, the existing code assumes that the build-id is
a multiple of 4 bytes, so I added some additional padding to ensure
that the generated note was a multiple of 4 bytes, even if the
build-id was not.

I added a test with a 1 byte build-id, and also for the case where the
build-id has zero length.  The zero length case already does what
you'd expect (no debug is loaded) as the bfd library rejects the
build-id when loading it from the objfile, but adding this additional
test is pretty cheap.

Approved-By: Kevin Buettner <kevinb@redhat.com>
2024-11-21 19:38:39 +00:00
Rohr, Stephan
be740e7cc6 testsuite: skip confirmation in 'gdb_reinitialize_dir'
Some shells automatically confirm the 'dir' command:

  (gdb) dir
  Reinitialize source path to empty? (y or n)
    [answered Y; input not from terminal]
  Source directories searched: $cdir;$cwd
  (gdb) y
  dir <...>/gdb/testsuite/gdb.base
  Undefined command: "y".  Try "help".

For example, this reprdocues in a MinGW32 environment with
'TERM=dumb'.  Skip sending 'y' if the command is already confirmed.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-21 00:49:39 -08:00
GDB Administrator
25f0170973 Automatic date update in version.in 2024-11-21 00:00:23 +00:00
Peter Bergner
e7bc2c935c PowerPC: Add support for RFC02677 - VSX Vector Rotate Left Word
opcodes/
	* ppc-opc.c (powerpc_opcodes): Add xvrlw.

gas/
	* testsuite/gas/ppc/future.s: Add test for xvrlw.
	* testsuite/gas/ppc/future.d: Likewise.
2024-11-20 18:33:07 -05:00
Tom Tromey
b6f3ac06ee Improve choice sorting in ada-lang.c
ada-lang.c has a "sort_choices" function that claims to sort the
symbol choices, but which does not really implement sorting.  This
patch changes this code to really sort the result vector, sorting
first by filename, then line number, and finally by the symbol name.

The filename sorting is done first by comparing basenames.  It turns
out that gnatmake and gprbuild invoke the compiler a bit differently,
so depending on which one you use, the results of a naive sort might
be different (due to the use of absolute or relative paths).
2024-11-20 13:18:40 -07:00
Andre Vieira
1fb5ccd6bf arm: Support pac_key_* register operand for MRS/MSR in Armv8.1-M Mainline
Add support for pac_key_[pu]_[0-3](_ns)? register operands for the MRS and MSR
instructions when assembling for Armv8.1-M Mainline, as well as adding the
corresponding support for disassembling instructions that use it.
2024-11-20 17:15:28 +00:00
Mohamed Bouhaouel
a5419b6f00 gdb: add Mohamed Bouhaouel to gdb/MAINTAINERS 2024-11-20 15:17:01 +01:00
Nick Clifton
4d1636909d
Remove Debian from SECURITY.txt 2024-11-20 12:59:35 +00:00
Andrew Burgess
661611b9d7 gdb/python: fix reference leak in gdb.BreakpointLocation.thread_groups
While reviewing another patch which uses PyList_Append I took a look
at our other uses of PyList_Append in GDB.  I spotted something odd
about the use in bplocpy_get_thread_groups.

We do:

    gdbpy_ref<> num = gdb_py_object_from_ulongest (inf->num);

At which point `num` will own a reference to the `int` object.  But
when we add the object to the result list we do:

    if (PyList_Append (list.get (), num.release ()) != 0)
      return nullptr;

By calling `release` we pass ownership of the reference to
PyList_Append, however, PyList_Append acquires its own reference, it
doesn't take ownership of an existing reference.

The consequence of this is that we leak the reference held in `num`.

This mostly isn't a problem though.  For small (< 257) integers Python
keeps a single instance of each and just hands out new references.  By
leaking the references, these small integers will not be cleaned up as
the Python interpreter shuts down, but that is only done when GDB
exits, so hardly a disaster.  As we're dealing with GDB's internal
inferior number here, unless the user has 257+ inferiors, we'll not
actually be leaking memory.

Still, lets do things right.  Switch to using `num.get ()`.  Now when
`num` goes out of scope it will decrement the reference count as
needed.

Approved-By: Tom Tromey <tom@tromey.com>
2024-11-20 09:33:17 +00:00
Jiawei
00ef37e860 RISC-V: Add Zcmt instructions and csr.
This patch supports Zcmt[1] instruction 'cm.jt' and 'cm.jalt'.
Add new CSR jvt for tablejump using. Since 'cm.jt' and 'cm.jalt'
have the same instructiong encoding, use 'match_cm_jt' and 'match_cm_jalt'
check the 'zcmt_index' field to distinguish them.

[1] https://github.com/riscvarchive/riscv-code-size-reduction/releases

Co-Authored by: Charlie Keaney <charlie.keaney@embecosm.com>
Co-Authored by: Mary Bennett <mary.bennett@embecosm.com>
Co-Authored by: Nandni Jamnadas <nandni.jamnadas@embecosm.com>
Co-Authored by: Sinan Lin <sinan.lin@linux.alibaba.com>
Co-Authored by: Simon Cook <simon.cook@embecosm.com>
Co-Authored by: Shihua Liao <shihua@iscas.ac.cn>
Co-Authored by: Yulong Shi <yulong@iscas.ac.cn>

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_multi_subset_supports): New extension.
	(riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

	* config/tc-riscv.c (enum riscv_csr_class): New CSR.
	(riscv_csr_address): Ditto.
	(validate_riscv_insn): New operand.
	(riscv_ip): Ditto.
	* testsuite/gas/riscv/csr-version-1p10.d: New CSR.
	* testsuite/gas/riscv/csr-version-1p10.l: Ditto.
	* testsuite/gas/riscv/csr-version-1p11.d: Ditto.
	* testsuite/gas/riscv/csr-version-1p11.l: Ditto.
	* testsuite/gas/riscv/csr-version-1p12.d: Ditto.
	* testsuite/gas/riscv/csr-version-1p12.l: Ditto.
	* testsuite/gas/riscv/csr.s: Ditto.
	* testsuite/gas/riscv/march-help.l: New extension.
	* testsuite/gas/riscv/zcmt-fail.d: New test.
	* testsuite/gas/riscv/zcmt-fail.l: New test.
	* testsuite/gas/riscv/zcmt-fail.s: New test.
	* testsuite/gas/riscv/zcmt.d: New test.
	* testsuite/gas/riscv/zcmt.s: New test.

include/ChangeLog:

	* opcode/riscv-opc.h (MATCH_CM_JT): New opcode.
	(MASK_CM_JT): New mask.
	(MATCH_CM_JALT): New opcode.
	(MASK_CM_JALT): New mask.
	(CSR_JVT): New CSR.
	(DECLARE_INSN): New declaration.
	(DECLARE_CSR): Ditto.
	* opcode/riscv.h (EXTRACT_ZCMT_INDEX): New marco.
	(ENCODE_ZCMT_INDEX): Ditto.
	(enum riscv_insn_class): New class.

opcodes/ChangeLog:

	* riscv-dis.c (print_insn_args): New operand.
	* riscv-opc.c (match_cm_jt): New function.
	(match_cm_jalt): Ditto.
2024-11-20 08:26:39 +08:00
GDB Administrator
46e64f7387 Automatic date update in version.in 2024-11-20 00:00:15 +00:00
Charles Baylis
9fc57f35eb gdb: Remove inappropriate comments
Remove some inappropriate comments in darwin_nat_target::attach,
gnu_nat_target::attach and inf_ptrace_target::attach.

Tested by rebuilding on x86_64-linux.

Copyright-paperwork-exempt: yes
Approved-By: Tom Tromey <tom@tromey.com>
2024-11-19 22:27:37 +01:00
Tom de Vries
f5e259f32f [gdb/contrib] Fix shellcheck warnings in spellcheck.sh
Fix shellcheck warnings in spellcheck.sh, found using shellcheck v0.10.0.

Ran shellcheck v0.10.0 (on a system with shellcheck version 0.8.0) using this
command from an RFC patch [1]:
...
$ ./gdb/contrib/pre-commit-shellcheck.sh ./gdb/contrib/spellcheck.sh
...

Tested on x86_64-linux

[1] https://sourceware.org/pipermail/gdb-patches/2024-November/213400.html
2024-11-19 12:32:40 +01:00
Nelson Chu
cb45bd5948 RISC-V: Don't report warnings when linking different privileged spec objects.
Since only the abandoned privileged spec v1.9.1 will have conflict csrs, to
keep the compatible we still report warnings when linking privileged spec
v1.9.1 objects with others.  But don't report warnings for other compatible
cases because it is actually a bit noisy and useless...

bfd/
	* elfnn-riscv.c (riscv_merge_attributes): Only report warnings when
	linking the abandoned privileged spec v1.9.1 object with others.
ld/
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Removed.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Removed.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Removed.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Removed.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Removed.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Removed.
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
2024-11-19 13:44:49 +08:00
Hu, Lin1
d7d71afa6a Support x86 Intel MSR_IMM
gas/ChangeLog:

	* NEWS: Support x86 Intel MSR_IMM.
	* config/tc-i386.c (cpu_arch): Add MSR_IMM.
	(cpu_flags_match): Add MSR_IMM to APX_F related processing.
	(i386_assemble): WRMSRNS's first operand is imm32, so add
	MN_wrmsrns like MN_uwrmsr.
	* doc/c-i386.texi: Document .msr_imm.
	* testsuite/gas/i386/i386.exp: Run MSR_IMM tests.
	* testsuite/gas/i386/x86-64.exp: Ditto.
	* testsuite/gas/i386/msr_imm-inval.l: New test.
	* testsuite/gas/i386/msr_imm-inval.s: Ditto.
	* testsuite/gas/i386/x86-64-msr_imm-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-msr_imm.d: Ditto.
	* testsuite/gas/i386/x86-64-msr_imm.s: Ditto.

opcodes/ChangeLog:

	* i386-dis.c: Add REG_VEX_MAP7_F6_L_0_W_0,
	PREFIX_VEX_MAP7_F6_L_0_W_0_R_0_X86_64,
	X86_64_VEX_MAP7_F6_L_0_W_0_R_0,
	VEX_LEN_MAP7_F6,
	VEX_W_MAP7_F6_L_0.
	(reg_table): New entry for MSR_IMM.
	(prefix_table): Ditto.
	(x86_64_table): Ditto.
	(vex_len_table): Ditto.
	(vex_w_table): Ditto.
	(map7_f6_opcode): New variable for MAP7.
	(get_valid_dis386): Support MAP7.
	* i386-gen.c (cpu_flags): Add MSR_IMM.
	* i386-init.h: Regenerated.
	* i386-mnem.h: Ditto.
	* i386-opc.h (i386_cpu_flags): Add cpumsr_imm.
	* i386-opc.tbl: Add MSR_IMM instructions.
	* i386-tbl.h: Regenerated.
2024-11-19 10:45:56 +08:00
Lulu Cai
77bcfb741c LoongArch: Do not relax pcalau12i+ld.d when there is overflow
There is no overflow check for the relaxation of pcalau12i+ld.d =>
pcalau12i+addi.d. For instruction sequences that can be relaxed,
they are directly relaxed to pcalau12i+addi.d. However, when the
relative distance between the symbol and the pc exceeds the 32-bit
range, the symbol value cannot be obtained correctly.

Adds an overflow check for the relaxation of pcalau12i+ld.d.
If it is found that the relaxation will overflow, it will not
be relaxed.
2024-11-19 09:42:23 +08:00
GDB Administrator
0073bda210 Automatic date update in version.in 2024-11-19 00:00:29 +00:00
Matthieu Longo
1b3b96ba32 aarch64: renaming of arm to AArch64 2024-11-18 18:03:56 +00:00
Matthieu Longo
493993718e aarch64: remove annoying white spaces in bfd/elfnn-aarch64.c 2024-11-18 18:03:56 +00:00
Christina Schimpe
27e82ad68b LAM: Enable tagged pointer support for watchpoints.
The Intel (R) linear address masking (LAM) feature modifies the checking
applied to 64-bit linear addresses.  With this so-called "modified
canonicality check" the processor masks the metadata bits in a pointer
before using it as a linear address.  LAM supports two different modes that
differ regarding which pointer bits are masked and can be used for
metadata: LAM 48 resulting in a LAM width of 15 and LAM 57 resulting in a
LAM width of 6.

This patch adjusts watchpoint addresses based on the currently enabled
LAM mode using the untag mask provided in the /proc/<pid>/status file.
As LAM can be enabled at runtime or as the configuration may change
when entering an enclave, GDB checks enablement state each time a watchpoint
is updated.

In contrast to the patch implemented for ARM's Top Byte Ignore "Clear
non-significant bits of address on memory access", it is not necessary to
adjust addresses before they are passed to the target layer cache, as
for LAM tagged pointers are supported by the system call to read memory.
Additionally, LAM applies only to addresses used for data accesses.
Thus, it is sufficient to mask addresses used for watchpoints.

The following examples are based on a LAM57 enabled program.
Before this patch tagged pointers were not supported for watchpoints:
~~~
(gdb) print pi_tagged
$2 = (int *) 0x10007ffffffffe004
(gdb) watch *pi_tagged
Hardware watchpoint 2: *pi_tagged
(gdb) c
Continuing.
Couldn't write debug register: Invalid argument.
~~~~

Once LAM 48 or LAM 57 is enabled for the current program, GDB can now
specify watchpoints for tagged addresses with LAM width 15 or 6,
respectively.

Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
2024-11-18 13:36:16 +00:00
Christina Schimpe
86bb38cee9 gdb: Make tagged pointer support configurable.
The gdbarch function gdbarch_remove_non_address_bits adjusts addresses to
enable debugging of programs with tagged pointers on Linux, for instance for
ARM's feature top byte ignore (TBI).
Once the function is implemented for an architecture, it adjusts addresses for
memory access, breakpoints and watchpoints.

Linear address masking (LAM) is Intel's (R) implementation of tagged
pointer support.  It requires certain adaptions to GDB's tagged pointer
support due to the following:
- LAM supports address tagging for data accesses only.  Thus, specifying
  breakpoints on tagged addresses is not a valid use case.
- In contrast to the implementation for ARM's TBI, the Linux kernel supports
  tagged pointers for memory access.

This patch makes GDB's tagged pointer support configurable such that it is
possible to enable the address adjustment for a specific feature only (e.g
memory access, breakpoints or watchpoints).  This way, one can make sure
that addresses are only adjusted when necessary.  In case of LAM, this
avoids unnecessary parsing of the /proc/<pid>/status file to get the
untag mask.

Reviewed-By: Felix Willgerodt <felix.willgerodt@intel.com>
(AArch64) Tested-By: Luis Machado <luis.machado@arm.com>
Approved-By: Luis Machado <luis.machado@arm.com>
2024-11-18 13:35:52 +00:00
Jan Beulich
335cb88259 x86: rename SPACE_{,E}VEX_MAP<N>
Map7 already has dual purpose for USER-MSR (and is to gain more for
MSR-IMM), while Map5 is about to gain VEX uses for AMX extensions. Drop
the not really meaningful infixes and (in the opcode table) prefixes,
retaining merely EVexMap4 for encoding EVex128 at the same time.
2024-11-18 11:46:28 +01:00
Jan Beulich
497ee27a74 x86: VP2INTERSECT{D,Q} have mask register destination group
Much like AVX512-{4FMAPS,4VNNIW} have a constraint on their register
source, there's a constraint (need to be even) on the destination
register here.

Adjust "good" test cases accordingly, and add a new test case to check
the warning.
2024-11-18 11:45:50 +01:00
Jan Beulich
3c17b69fa1 x86: generalize "implicit quad group" handling
We'll want to re-use it for VP2INTERSECT{D,Q}.

While there add a testcase for the similarly affected AVX512-4VNNIW
insns.
2024-11-18 11:45:34 +01:00
Tom de Vries
c6f2bd9d10 [gdb/contrib] Fix spellcheck.sh for bash < 5.1
Since commit 5cb0406bb6 ("[gdb/contrib] Handle capitalized words in
spellcheck.sh"), spellcheck.sh uses '${pat@u}' which is available starting
bash 5.1, and consequently the script breaks with bash 4.4.

Fix this by checking for the bash version, and using an alternative
implementation for bash < 5.1.

Tested on x86_64-linux.
2024-11-18 11:42:44 +01:00
Benjamin Drung
b0cc81e870 ld: Support percent-encoded JSON in --package-metadata
Specifying the compiler flag `-Wl,--package-metadata=<JSON>` will not
work in case the JSON contains a comma, because compiler drivers eat
commas. Example:

```
$ echo "void main() { }" > test.c
$ gcc '-Wl,--package-metadata={"type":"deb","os":"ubuntu"}' test.c
/usr/bin/ld: cannot find "os":"ubuntu"}: No such file or directory
collect2: error: ld returned 1 exit status
```

The quotation marks in the JSON value do not work well with shell nor
make. Specifying the `--package-metadata` linker flag in a `LDFLAGS`
environment variable might loose its quotation marks when it hits the
final compiler call.

So support percent-encoded and %[string] encoded JSON data in the
`--package-metadata` linker flag. Percent-encoding is used because it is
a standard, simple to implement, and does take too many additional
characters. %[string] encoding is supported for having a more readable
encoding.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32003
Bug-Ubutru: https://bugs.launchpad.net/bugs/2071468
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
2024-11-18 11:38:25 +01:00
Jan Beulich
20d9fb448c gas: move had_errors() invocation in finishing of subsegs
Invoking this repeatedly in an inner loop is not only inefficient, but
may lead to inconsistencies in e.g. the listings that the original
comment author cared about. (Accept potential inconsistencies across
distinct sections though, to cover all invocations of the function.)
2024-11-18 11:37:31 +01:00
Jan Beulich
af3394d97a ELF: SHF_STRINGS isn't really tied to SHF_MERGE
It's not overly useful without it, but the spec doesn't name any
dependency between the two. People may want to use it for purely
informational purposes, for example. Adjust, in particular, entity size
processing to be engaged if either flag is set, as mandated by the spec.
2024-11-18 11:36:57 +01:00
Jan Beulich
70ab7e0acf ELF: SHF_MERGE vs SHT_NOBITS
bfd/merge.c puts in quite some effort to track mergable sections. That's
all wasted for sections which don't have contents, as for them
_bfd_write_merged_section() will never be called.

With the combination not having any useful effect, also warn about this
in gas.
2024-11-18 11:36:30 +01:00
Jan Beulich
d5cbf916be gas/ELF: also reject merge entity size being zero
This won't have any useful effect, so is at best marginally less bogus
than a negative value.

The change actually points out a flawed (for Arm) testcase: @ is a
comment character there.
2024-11-18 11:35:57 +01:00
Jens Remus
76445f36a2 s390: Add arch15 Concurrent-Functions Facility insns
opcodes/
	* s390-opc.txt: Add arch15 Concurrent-Functions Facility
	instructions.
	* s390-opc.c (INSTR_SSF_RRDRD2, MASK_SSF_RRDRD2): New SSF
	instruction format variant.

gas/testsuite/
	* gas/s390/zarch-arch15.d: Tests for arch15 Concurrent-Functions
	Facility instructions.
	* gas/s390/zarch-arch15.s: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-11-18 10:42:21 +01:00
Jens Remus
b0588b2173 s390: Add arch15 instruction names
opcodes/
	* s390-opc.txt: Add arch15 instruction names.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-11-18 10:42:21 +01:00