binutils-gdb.git
20 months agoRX assembler: switch arguments of thw MVTACGU insn.
Yoshinori Sato [Mon, 31 Oct 2022 10:46:37 +0000 (10:46 +0000)]
RX assembler: switch arguments of thw MVTACGU insn.

20 months agoobjdump: Add configure time option to enable colored disassembly output by default.
Nick Clifton [Mon, 31 Oct 2022 09:35:16 +0000 (09:35 +0000)]
objdump: Add configure time option to enable colored disassembly output by default.

PR 29457
* configure.ac: Add --enable-colored-disassembly.
* objdump.c: Add --disassembler-color=terminal.
* doc/binutils.texi (objdump): Document the new option.
* NEWS: Mention new feature.
* config.in: Regenerate in.
* configure: Regenerate.

20 months agold: Add publics stream to PDB files
Mark Harmstone [Mon, 31 Oct 2022 00:15:54 +0000 (00:15 +0000)]
ld: Add publics stream to PDB files

20 months agold: Add section header stream to PDB files
Mark Harmstone [Mon, 31 Oct 2022 00:15:53 +0000 (00:15 +0000)]
ld: Add section header stream to PDB files

20 months agold: Use %E in einfo in pdb.c
Mark Harmstone [Mon, 31 Oct 2022 00:15:52 +0000 (00:15 +0000)]
ld: Use %E in einfo in pdb.c

Resubmission, taking into account
https://sourceware.org/pipermail/binutils/2022-October/123948.html.

20 months agoAutomatic date update in version.in
GDB Administrator [Mon, 31 Oct 2022 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agoPool section entries for DWP version 1
Alan Modra [Sun, 30 Oct 2022 08:38:51 +0000 (19:08 +1030)]
Pool section entries for DWP version 1

Ref: https://gcc.gnu.org/wiki/DebugFissionDWP?action=recall&rev=3

Fuzzers have found a weakness in the code stashing pool section
entries.  With random nonsensical values in the index entries (rather
than each index pointing to its own set distinct from other sets),
it's possible to overflow the space allocated, losing the NULL
terminator.  Without a terminator, find_section_in_set can run off the
end of the shndx_pool buffer.  Fix this by scanning the pool directly.

binutils/
* dwarf.c (add_shndx_to_cu_tu_entry): Delete range check.
(end_cu_tu_entry): Likewise.
(process_cu_tu_index): Fill shndx_pool by directly scanning
pool, rather than indirectly from index entries.

20 months agoAutomatic date update in version.in
GDB Administrator [Sun, 30 Oct 2022 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agogdb/testsuite: Wrap `param_integer_error' in gdb.guile/scm-parameter.exp
Maciej W. Rozycki [Sat, 29 Oct 2022 13:54:13 +0000 (14:54 +0100)]
gdb/testsuite: Wrap `param_integer_error' in gdb.guile/scm-parameter.exp

Wrap an overlong line in the definition of `param_integer_error' in
gdb.guile/scm-parameter.exp.  No functional change.

20 months agosim/sh: Remove redundant function declaration
Tsukasa OI [Sat, 24 Sep 2022 09:11:52 +0000 (09:11 +0000)]
sim/sh: Remove redundant function declaration

Clang generates a warning if there is a function declaration/definition
with zero arguments.  Such declarations/definitions without a prototype (an
argument list) are deprecated forms of indefinite arguments
("-Wdeprecated-non-prototype").  On the default configuration, it causes a
build failure (unless "--disable-werror" is specified).

But there is another issue.  This function declaration in sim/sh/interp.c
is completely redundant.  This commit just removes that declaration.

20 months agosim/m32r: Initialize "list" variable
Tsukasa OI [Mon, 26 Sep 2022 07:03:00 +0000 (07:03 +0000)]
sim/m32r: Initialize "list" variable

The variable "list" is only initialized when arg1 > 0 and when arg1 == 0,
an uninitialized value is passed to translate_endian_h2t function.

Although this behavior is harmless, this commit adds initialization to avoid
a GCC warning ("-Wmaybe-uninitialized").

20 months agosim/erc32: Use int32_t as IRQ callback argument
Tsukasa OI [Sat, 24 Sep 2022 09:54:32 +0000 (09:54 +0000)]
sim/erc32: Use int32_t as IRQ callback argument

Clang generates a warning if an argument is passed to a function without
prototype (zero arguments, even without (void)).  Such calls are deprecated
forms of indefinite arguments passing ("-Wdeprecated-non-prototype").
On the default configuration, it (somehow) doesn't cause a build failure but
a warning is generated.

But because the cause is the same as the issue the author fixed in
"sim/erc32: Use int32_t as event callback argument", it would be better to
fix it now to prevent problems in the future.

To fix the issue, this commit makes struct irqcall to use int32_t as a
callback (callback) argument of an IRQ.

20 months agosim/erc32: Use int32_t as event callback argument
Tsukasa OI [Sat, 24 Sep 2022 09:49:42 +0000 (09:49 +0000)]
sim/erc32: Use int32_t as event callback argument

Clang generates a warning if an argument is passed to a function without
prototype (zero arguments, even without (void)).  Such calls are deprecated
forms of indefinite arguments passing ("-Wdeprecated-non-prototype").
On the default configuration, it causes a build failure (unless
"--disable-werror" is specified).

To fix that, this commit makes struct evcell to use int32_t as a callback
(cfunc) argument of an event.  int32_t is chosen because "event" function
accepts "int32_t arg".

20 months agosim/erc32: Insert void parameter
Tsukasa OI [Sat, 24 Sep 2022 09:16:57 +0000 (09:16 +0000)]
sim/erc32: Insert void parameter

Clang generates a warning if there is a function declaration/definition
with zero arguments.  Such declarations/definitions without a prototype (an
argument list) are deprecated forms of indefinite arguments
("-Wdeprecated-non-prototype").  On the default configuration, it causes a
build failure (unless "--disable-werror" is specified).

This commit replaces () with (void) to avoid this warning.

20 months ago[gdb/testsuite] Use ssh -t in remote-*.exp
Tom de Vries [Sat, 29 Oct 2022 07:43:32 +0000 (09:43 +0200)]
[gdb/testsuite] Use ssh -t in remote-*.exp

When running test-case gdb.server/multi-ui-errors.exp on target board
remote-gdbserver-on-localhost.exp, I run into:
...
(gdb) PASS: gdb.server/multi-ui-errors.exp: connect to gdbserver
continue^M
Continuing.^M
PASS: gdb.server/multi-ui-errors.exp: continue - extra UI
Remote debugging from host ::1, port 35466^M
FAIL: gdb.server/multi-ui-errors.exp: ensure inferior is running
...

The problem is that the target board uses ssh -T, which fails to guarantee
that output from the inferior will be available.

Fix this by copying proc ${board}_spawn from local-remote-host.exp, which
ensures using ssh -t.  [ It would be nice to define an ssh base board to
get rid of the copies, but I'm not addressing that in this commit. ]

Likewise for target board remote-stdio-gdbserver.exp.

Tested on x86_64-linux.

20 months ago[gdb/testsuite] Fix gdb.server/multi-ui-errors.exp with local-remote-host-notty
Tom de Vries [Sat, 29 Oct 2022 07:43:32 +0000 (09:43 +0200)]
[gdb/testsuite] Fix gdb.server/multi-ui-errors.exp with local-remote-host-notty

With test-case gdb.server/multi-ui-errors.exp and host board
local-remote-host-notty, I run into:
...
(gdb) PASS: gdb.server/multi-ui-errors.exp: interact with GDB's main UI
Executing on target: kill -9 29666    (timeout = 300)
builtin_spawn -ignore SIGHUP kill -9 29666^M
echo^M
Remote connection closed^M
(gdb) (gdb) FAIL: gdb.server/multi-ui-errors.exp: \
  main UI, prompt after gdbserver dies (timeout)
...

In contrast, with local-remote-host (so, everything the same but editing off):
...
(gdb) PASS: gdb.server/multi-ui-errors.exp: interact with GDB's main UI
Executing on target: kill -9 31245    (timeout = 300)
builtin_spawn -ignore SIGHUP kill -9 31245^M
Remote connection closed^M
(gdb) echo^M
(gdb) PASS: gdb.server/multi-ui-errors.exp: main UI, prompt after gdbserver dies
...

The test-case issues a kill, which results in a "Remote connection closed"
message and a prompt.

The problem is that the prompt is not consumed, so the subsequent echo may be
issued before that prompt, which causes a mismatch when matching the result
of the echo.

Fix this by consuming the "Remote connection closed" message and prompt.

Tested on x86_64-linux.

20 months ago[gdb/testsuite] Consume output asap in gdb.server/multi-ui-errors.exp
Tom de Vries [Sat, 29 Oct 2022 07:43:32 +0000 (09:43 +0200)]
[gdb/testsuite] Consume output asap in gdb.server/multi-ui-errors.exp

With test-case gdb.server/multi-ui-errors.exp we see:
...
(gdb) PASS: multi-ui-errors.exp: main UI, prompt after gdbserver dies
continue^M
Continuing.^M
echo^M
(gdb) PASS: multi-ui-errors.exp: extra UI, prompt after gdbserver dies
...

The continue is issued earlier in the test-case, but the output has not been
consumed, which makes it show up much later.

Consume the continue output asap, to make it clear when the continue is issued:
...
(gdb) PASS: gdb.server/multi-ui-errors.exp: connect to gdbserver
continue^M
Continuing.^M
PASS: gdb.server/multi-ui-errors.exp: continue - extra UI
...

Tested on x86_64-linux.

20 months ago[gdb/testsuite] Remove REMOTE_PORTNUM in remote-stdio-gdbserver.exp
Tom de Vries [Sat, 29 Oct 2022 07:20:36 +0000 (09:20 +0200)]
[gdb/testsuite] Remove REMOTE_PORTNUM in remote-stdio-gdbserver.exp

The usage for board remote-stdio-gdbserver.exp is advertised as:
...
 # bash$ make check RUNTESTFLAGS="--target_board=remote-stdio-gdbserver \
 #    REMOTE_USERNAME=... REMOTE_HOSTNAME=... REMOTE_PORTNUM=... \
 #    [REMOTE_TMPDIR=${remote_dir}] [GDBSERVER=${remote_gdbserver}]"
...
but when adding REMOTE_PORTNUM=22, I run into:
...
Running stop-reply-no-thread-multi.exp ...
ERROR: tcl error sourcing stop-reply-no-thread-multi.exp.
ERROR: couldn't execute "/usr/bin/ssh -p22": no such file or directory
    while executing
"builtin_spawn {/usr/bin/ssh -p22} -l vries localhost {/usr/bin/gdbserver \
  --once localhost:2346 \
  /home/vries/gdb_versions/devel/build/gdb/testsuite/outp..."
...

Fix this by simply removing REMOTE_PORTNUM.

Tested on x86_64-linux.

20 months agosim, sim/{m32c,ppc,rl78}: Use getopt_long
Tsukasa OI [Mon, 17 Oct 2022 15:47:23 +0000 (15:47 +0000)]
sim, sim/{m32c,ppc,rl78}: Use getopt_long

Because of a Libiberty hack, getopt on GNU libc (2.25 or earlier) is
currently unusable on sim, causing a regression on CentOS 7.

This is caused as follows:

1.  If HAVE_DECL_GETOPT is defined (getopt declaration with known prototype
    is detected while configuration), a declaration of getopt in
    "include/getopt.h" is suppressed.
    The author started to define HAVE_DECL_GETOPT in sim with the commit
    340aa4f6872c ("sim: Check known getopt definition existence").
2.  GNU libc (2.25 or earlier)'s <unistd.h> includes <getopt.h> with a
    special purpose macro defined to declare only getopt function but due
    to include path (not tested while configuration), it causes <unistd.h>
    to include Libiberty's "include/getopt.h".
3.  If both 1. and 2. are satisfied, despite that <unistd.h> tries to
    declare getopt by including <getopt.h>, "include/getopt.h" does not do
    so, causing getopt function undeclared.

Getting rid of "include/getopt.h" (e.g. renaming this header file) is the
best solution to avoid hacking but as a short-term solution, this commit
replaces getopt with getopt_long under sim/.

20 months agopef: sanity check before malloc
Alan Modra [Sat, 29 Oct 2022 03:46:29 +0000 (14:16 +1030)]
pef: sanity check before malloc

And do the sanity check in a way that can't overflow.

* pef.c (bfd_pef_parse_function_stubs): Sanity check header
imported_library_count and total_imported_symbol_count before
allocating memory.

20 months agoFix small objcopy memory leak
Alan Modra [Sat, 29 Oct 2022 00:12:50 +0000 (10:42 +1030)]
Fix small objcopy memory leak

* objcopy.c (copy_archive): Free l->name.

20 months agoNULL dereference read in som_write_object_contents
Alan Modra [Sat, 29 Oct 2022 00:01:01 +0000 (10:31 +1030)]
NULL dereference read in som_write_object_contents

objcopy copy_object may omit the call to bfd_copy_private_bfd_data for
various conditions deemed non-fatal, in which case obj_som_exec_data
will be NULL for the output file.

* som.c (som_finish_writing): Don't dereference NULL
obj_som_exec_data.

20 months agoRISC-V: Always generate mapping symbols at the start of the sections.
Nelson Chu [Sat, 29 Oct 2022 03:34:10 +0000 (11:34 +0800)]
RISC-V: Always generate mapping symbols at the start of the sections.

Before figuring out the suppress rule of mapping symbol with architecture
(changed back to $x), always generate them at the start of the sections.

gas/
    * config/tc-riscv.c (need_arch_map_symbol): Removed.
    (riscv_mapping_state): Updated.
    (riscv_check_mapping_symbols): Updated.
    * testsuite/gas/riscv/mapping-non-arch.d: Removed.
    * testsuite/gas/riscv/mapping-non-arch.s: Likewise.

20 months agoAutomatic date update in version.in
GDB Administrator [Sat, 29 Oct 2022 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agogas: NEWS: Note support for RISC-V Zawrs
Palmer Dabbelt [Thu, 27 Oct 2022 20:20:44 +0000 (13:20 -0700)]
gas: NEWS: Note support for RISC-V Zawrs

This has been supported since eb668e50036 ("RISC-V: Add Zawrs ISA
extension support").

20 months agogas: NEWS: Add a missing newline
Palmer Dabbelt [Thu, 27 Oct 2022 20:20:02 +0000 (13:20 -0700)]
gas: NEWS: Add a missing newline

20 months agoConvert compunit_language to a method
Tom Tromey [Thu, 27 Oct 2022 00:26:38 +0000 (18:26 -0600)]
Convert compunit_language to a method

This changes compunit_language to be a method on compunit_symtab.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
20 months agoRISC-V: Improve "bits undefined" diagnostics
Tsukasa OI [Tue, 28 Jun 2022 10:07:52 +0000 (19:07 +0900)]
RISC-V: Improve "bits undefined" diagnostics

This commit improves internal error message
"internal: bad RISC-V opcode (bits 0x%lx undefined): %s %s"
to display actual unused bits (excluding non-instruction bits).

gas/ChangeLog:

* config/tc-riscv.c (validate_riscv_insn): Exclude non-
instruction bits from displaying internal diagnostics.
Change error message slightly.

20 months agoRISC-V: Fallback for instructions longer than 64b
Tsukasa OI [Thu, 6 Oct 2022 04:18:52 +0000 (04:18 +0000)]
RISC-V: Fallback for instructions longer than 64b

We don't support instructions longer than 64-bits yet.  Still, we can
modify validate_riscv_insn function to prevent unexpected behavior by
limiting the "length" of an instruction to 64-bit (or less).

gas/ChangeLog:

* config/tc-riscv.c (validate_riscv_insn): Fix function
description comment based on current spec.  Limit instruction
length up to 64-bit for now.  Make sure that required_bits does
not corrupt even if unsigned long long is longer than 64-bit.

20 months agoRISC-V/gas: fix build with certain gcc versions
Jan Beulich [Fri, 28 Oct 2022 13:47:03 +0000 (15:47 +0200)]
RISC-V/gas: fix build with certain gcc versions

Some versions of gcc warn by default about shadowed outer-scope
declarations. This affects frag_align_code, which is declared in
frags.h. Rename the offending function parameter. While there also
switch to using true/false at the function call sites.

20 months agoRISC-V: Fix build failure for -Werror=maybe-uninitialized
Tsukasa OI [Fri, 28 Oct 2022 06:46:13 +0000 (06:46 +0000)]
RISC-V: Fix build failure for -Werror=maybe-uninitialized

Commit 40f1a1a4564b ("RISC-V: Output mapping symbols with ISA string.")
caused a build failure on GCC 12 as follows:

make[3]: Entering directory '$(builddir)/gas'
  CC       config/tc-riscv.o
In file included from $(srcdir)/gas/config/tc-riscv.c:23:
$(srcdir)/gas/as.h: In function ‘make_mapping_symbol’:
$(srcdir)/gas/as.h:123:15: error: ‘buff’ may be used uninitialized [-Werror=maybe-uninitialized]
  123 | #define xfree free
      |               ^~~~
$(srcdir)/gas/config/tc-riscv.c:487:9: note: ‘buff’ was declared here
  487 |   char *buff;
      |         ^~~~
cc1: all warnings being treated as errors
make[3]: *** [Makefile:1425: config/tc-riscv.o] Error 1

This is caused by a false positive of "maybe uninitialized" variable
detection (-Wmaybe-uninitialized).  To avoid this error, this commit
initializes the local variable buff to NULL first in all cases.

gas/ChangeLog:

* config/tc-riscv.c (make_mapping_symbol): Initialize variable
buff with NULL to avoid build failure caused by a GCC's false
positive of maybe uninitialized variable detection.

20 months agogdb, btrace: fix family and model computation
Markus Metzger [Thu, 20 Oct 2022 14:27:34 +0000 (16:27 +0200)]
gdb, btrace: fix family and model computation

In gdb/nat/linux-btrace.c:btrace_this_cpu() we initialize the cpu
structure given to the libipt btrace decoder.

We only consider the extended model field for family 0x6 and forget about
family 0xf and we don't consider the extended family field.  Fix it.

20 months agoinclude: Define macro to ignore -Wdeprecated-declarations on GCC
Tsukasa OI [Thu, 27 Oct 2022 04:33:37 +0000 (04:33 +0000)]
include: Define macro to ignore -Wdeprecated-declarations on GCC

"-Wdeprecated-declarations" warning option can be helpful to track
deprecated function delarations but sometimes we need to disable this
warning for a good reason.

DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS is an existing macro but only
defined on Clang.  Since "-Wdeprecated-declarations" is also available on
GCC (>= 3.4.0), this commit adds equivalent definition as Clang.

__GNUC__ and __GNUC_MINOR__ are not checked because this header file seems
to assume GCC >= 4.6 (with "GCC diagnostic push/pop").

include/ChangeLog:

* diagnostics.h (DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS):
Define also on GCC.

20 months agoRISC-V: Output mapping symbols with ISA string.
Nelson Chu [Thu, 29 Sep 2022 11:07:46 +0000 (19:07 +0800)]
RISC-V: Output mapping symbols with ISA string.

RISC-V Psabi pr196,
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/196

bfd/
    * elfxx-riscv.c (riscv_release_subset_list): Free arch_str if needed.
    (riscv_copy_subset_list): Copy arch_str as well.
    * elfxx-riscv.h (riscv_subset_list_t): Store arch_str for each subset list.
gas/
    * config/tc-riscv.c (riscv_reset_subsets_list_arch_str): Update the
    architecture string in the subset_list.
    (riscv_set_arch): Call riscv_reset_subsets_list_arch_str after parsing new
    architecture string.
    (s_riscv_option): Likewise.
    (need_arch_map_symbol): New boolean, used to indicate if .option
    directives do affect instructions.
    (make_mapping_symbol): New boolean parameter reset_seg_arch_str.  Need to
    generate $x+arch for MAP_INSN, and then store it into tc_segment_info_data
    if reset_seg_arch_str is true.
    (riscv_mapping_state): Decide if we need to add $x+arch for MAP_INSN.  For
    now, only add $x+arch if the architecture strings in subset list and segment
    are different.  Besides, always add $x+arch at the start of section, and do
    not add $x+arch for code alignment, since rvc for alignment can be judged
    from addend of R_RISCV_ALIGN.
    (riscv_remove_mapping_symbol): If current and previous mapping symbol have
    same value, then remove the current $x only if the previous is $x+arch;
    Otherwise, always remove previous.
    (riscv_add_odd_padding_symbol): Updated.
    (riscv_check_mapping_symbols): Don't need to add any $x+arch if
    need_arch_map_symbol is false, so changed them to $x.
    (riscv_frag_align_code): Updated since riscv_mapping_state is changed.
    (riscv_init_frag): Likewise.
    (s_riscv_insn): Likewise.
    (riscv_elf_final_processing): Call riscv_release_subset_list to release
    subset_list of riscv_rps_as, rather than only release arch_str in the
    riscv_write_out_attrs.
    (riscv_write_out_attrs): No need to call riscv_arch_str, just get arch_str
    from subset_list of riscv_rps_as.
    * config/tc-riscv.h (riscv_segment_info_type): Record current $x+arch mapping
    symbol of each segment.
    * testsuite/gas/riscv/mapping-0*: Merged and replaced by mapping.s.
    * testsuite/gas/riscv/mapping.s: New testcase, to test most of the cases in
    one file.
    * testsuite/gas/riscv/mapping-symbols.d: Likewise.
    * testsuite/gas/riscv/mapping-dis.d: Likewise.
    * testsuite/gas/riscv/mapping-non-arch.s: New testcase for the case that
    does need any $x+arch.
    * testsuite/gas/riscv/mapping-non-arch.d: Likewise.
    * testsuite/gas/riscv/option-arch-01a.d: Updated.
opcodes/
    * riscv-dis.c (riscv_disassemble_insn): Set riscv_fpr_names back to
    riscv_fpr_names_abi or riscv_fpr_names_numeric when zfinx is disabled
    for some specfic code region.
    (riscv_get_map_state): Recognized mapping symbols $x+arch, and then reset
    the architecture string once the ISA is different.

20 months agobinutils: Update my e-mail and Yunhai's e-mail
Lifang Xia [Fri, 28 Oct 2022 02:13:56 +0000 (10:13 +0800)]
binutils: Update my e-mail and Yunhai's e-mail

binutils/
* MAINTAINERS(C-SKY): update e-mails of Lifang & Yunhai.

20 months agoPowerPC: Add support for RFC02658 - MMA+ Outer-Product Instructions
Peter Bergner [Sat, 8 Oct 2022 21:19:51 +0000 (16:19 -0500)]
PowerPC: Add support for RFC02658 - MMA+ Outer-Product Instructions

gas/
* config/tc-ppc.c (md_assemble): Only check for prefix opcodes.
* testsuite/gas/ppc/rfc02658.s: New test.
* testsuite/gas/ppc/rfc02658.d: Likewise.
* testsuite/gas/ppc/ppc.exp: Run it.

opcodes/
* ppc-opc.c (XMSK8, P_GERX4_MASK, P_GERX2_MASK, XX3GERX_MASK): New.
(powerpc_opcodes): Add dmxvi8gerx4pp, dmxvi8gerx4, dmxvf16gerx2pp,
dmxvf16gerx2, dmxvbf16gerx2pp, dmxvf16gerx2np, dmxvbf16gerx2,
dmxvi8gerx4spp, dmxvbf16gerx2np, dmxvf16gerx2pn, dmxvbf16gerx2pn,
dmxvf16gerx2nn, dmxvbf16gerx2nn, pmdmxvi8gerx4pp, pmdmxvi8gerx4,
pmdmxvf16gerx2pp, pmdmxvf16gerx2, pmdmxvbf16gerx2pp, pmdmxvf16gerx2np,
pmdmxvbf16gerx2, pmdmxvi8gerx4spp, pmdmxvbf16gerx2np, pmdmxvf16gerx2pn,
pmdmxvbf16gerx2pn, pmdmxvf16gerx2nn, pmdmxvbf16gerx2nn.

20 months agoPowerPC: Add support for RFC02653 - Dense Math Facility
Peter Bergner [Thu, 6 Oct 2022 22:08:53 +0000 (17:08 -0500)]
PowerPC: Add support for RFC02653 - Dense Math Facility

gas/
* config/tc-ppc.c (pre_defined_registers): Add dense math registers.
(md_assemble): Check dmr specified in correct operand.
* testsuite/gas/ppc/outerprod.s <dmsetaccz, dmxvbf16ger2,
dmxvbf16ger2nn, dmxvbf16ger2np, dmxvbf16ger2pn, dmxvbf16ger2pp,
dmxvf16ger2, dmxvf16ger2nn, dmxvf16ger2np, dmxvf16ger2pn, dmxvf16ger2pp,
dmxvf32ger, dmxvf32gernn, dmxvf32gernp, dmxvf32gerpn, dmxvf32gerpp,
dmxvf64ger, dmxvf64gernn, dmxvf64gernp, dmxvf64gerpn, dmxvf64gerpp,
dmxvi16ger2, dmxvi16ger2pp, dmxvi16ger2s, dmxvi16ger2spp, dmxvi4ger8,
dmxvi4ger8pp, dmxvi8ger4, dmxvi8ger4pp, dmxvi8ger4spp, dmxxmfacc,
dmxxmtacc, pmdmxvbf16ger2, pmdmxvbf16ger2nn, pmdmxvbf16ger2np,
pmdmxvbf16ger2pn, pmdmxvbf16ger2pp, pmdmxvf16ger2, pmdmxvf16ger2nn,
pmdmxvf16ger2np, pmdmxvf16ger2pn, pmdmxvf16ger2pp, pmdmxvf32ger,
pmdmxvf32gernn, pmdmxvf32gernp, pmdmxvf32gerpn, pmdmxvf32gerpp,
pmdmxvf64ger, pmdmxvf64gernn, pmdmxvf64gernp, pmdmxvf64gerpn,
pmdmxvf64gerpp, pmdmxvi16ger2, pmdmxvi16ger2pp, pmdmxvi16ger2s,
pmdmxvi16ger2spp, pmdmxvi4ger8, pmdmxvi4ger8pp, pmdmxvi8ger4,
pmdmxvi8ger4pp, pmdmxvi8ger4spp>: Add new tests.
* testsuite/gas/ppc/outerprod.d: Likewise.
* testsuite/gas/ppc/rfc02653.s: New test.
* testsuite/gas/ppc/rfc02653.d: Likewise.
* testsuite/gas/ppc/ppc.exp: Run it.

include/
* opcode/ppc.h (PPC_OPERAND_DMR): Define.  Renumber following
PPC_OPERAND defines.

opcodes/
* ppc-dis.c (print_insn_powerpc): Prepend 'dm' when printing DMR regs.
* ppc-opc.c (insert_p2, (extract_p2, (insert_xa5, (extract_xa5,
insert_xb5, (extract_xb5): New functions.
(insert_xa6a, extract_xa6a, insert_xb6a, extract_xb6a): Disallow
operand overlap only on Power10.
(DMR, DMRAB, P1, P2, XA5p, XB5p, XDMR_MASK, XDMRDMR_MASK, XX2ACC_MASK,
XX2DMR_MASK, XX3DMR_MASK): New defines.
(powerpc_opcodes): Add dmmr, dmsetaccz, dmsetdmrz, dmxor, dmxvbf16ger2,
dmxvbf16ger2nn, dmxvbf16ger2np, dmxvbf16ger2pn, dmxvbf16ger2pp,
dmxvf16ger2, dmxvf16ger2nn, dmxvf16ger2np, dmxvf16ger2pn, dmxvf16ger2pp,
dmxvf32ger, dmxvf32gernn, dmxvf32gernp, dmxvf32gerpn, dmxvf32gerpp,
dmxvf64ger, dmxvf64gernn, dmxvf64gernp, dmxvf64gerpn, dmxvf64gerpp,
dmxvi16ger2, dmxvi16ger2pp, dmxvi16ger2s, dmxvi16ger2spp, dmxvi4ger8,
dmxvi4ger8pp, dmxvi8ger4, dmxvi8ger4pp, dmxvi8ger4spp, dmxxextfdmr256,
dmxxextfdmr512, dmxxinstdmr256, dmxxinstdmr512, dmxxmfacc, dmxxmtacc,
pmdmxvbf16ger2, pmdmxvbf16ger2nn, pmdmxvbf16ger2np, pmdmxvbf16ger2pn,
pmdmxvbf16ger2pp, pmdmxvf16ger2, pmdmxvf16ger2nn, pmdmxvf16ger2np,
pmdmxvf16ger2pn, pmdmxvf16ger2pp, pmdmxvf32ger, pmdmxvf32gernn,
pmdmxvf32gernp, pmdmxvf32gerpn, pmdmxvf32gerpp, pmdmxvf64ger,
pmdmxvf64gernn, pmdmxvf64gernp, pmdmxvf64gerpn, pmdmxvf64gerpp,
pmdmxvi16ger2, pmdmxvi16ger2pp, pmdmxvi16ger2s, pmdmxvi16ger2spp,
pmdmxvi4ger8, pmdmxvi4ger8pp, pmdmxvi8ger4, pmdmxvi8ger4pp,
pmdmxvi8ger4spp.

20 months agoAutomatic date update in version.in
GDB Administrator [Fri, 28 Oct 2022 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agosim/cgen: initialize variable at creation in engine_run_n
Andrew Burgess [Mon, 24 Oct 2022 15:55:07 +0000 (16:55 +0100)]
sim/cgen: initialize variable at creation in engine_run_n

Zero initialize engine_fns entirely at creation, then override those
fields we intend to use, rather than zero just initializing the unused
fields later on.

There should be no user visible changes after this commit.

20 months ago[gdb/testsuite] Remove address from test names
Tom de Vries [Thu, 27 Oct 2022 15:14:33 +0000 (17:14 +0200)]
[gdb/testsuite] Remove address from test names

I noticed an address in a test name:
...
PASS: gdb.base/eh_return.exp: gdb_breakpoint: \
  set breakpoint at *0x000000000040071b
...

Stabilize the test name by using "set breakpoint on address" instead.

Likewise in two other test-cases.

Tested on x86_64-linux.

20 months ago[gdb/testsuite] Disable styling in host board local-remote-host-native.exp
Tom de Vries [Thu, 27 Oct 2022 14:53:12 +0000 (16:53 +0200)]
[gdb/testsuite] Disable styling in host board local-remote-host-native.exp

Propagate fix from commit 17c68d98f74 ("[gdb/testsuite] Disable styling in host
board local-remote-host.exp") to local-remote-host-native.exp.

Tested on x86_64-linux.

20 months ago[gdb/testsuite] Fix silent timeouts in gdb.mi/mi-exec-run.exp with remote host
Tom de Vries [Thu, 27 Oct 2022 14:53:12 +0000 (16:53 +0200)]
[gdb/testsuite] Fix silent timeouts in gdb.mi/mi-exec-run.exp with remote host

I noticed that running test-case gdb.mi/mi-exec-run.exp with host board
local-remote-host.exp takes about 44 seconds.

I found two silent timeouts responsible for this.

The first is in mi_gdb_exit, where we have:
...
    if { [is_remote host] && [board_info host exists fileid] } {
        send_gdb "999-gdb-exit\n"
        gdb_expect 10 {
            -re "y or n" {
                send_gdb "y\n"
                exp_continue
            }
            -re "Undefined command.*$gdb_prompt $" {
                send_gdb "quit\n"
                exp_continue
            }
            -re "DOSEXIT code" { }
        }
    }
...
so in gdb.log we see:
...
999-gdb-exit^M
999^exit^M
=thread-exited,id="1",group-id="i1"^M
=thread-group-exited,id="i1"^M
...
after which expect just waits for the timeout.

Fix this by adding a gdb_expect clause to parse the exit:
...
            -re "\r\n999\\^exit\r\n" { }
...

Note that we're not parsing the thread-exited/thread-group-exited messages, because
they may not be present:
...
$ gdb -i=mi
=thread-group-added,id="i1"
(gdb)
999-gdb-exit
999^exit
$
...

After fixing that, we have:
...
(gdb) ^M
saw mi error
PASS: gdb.mi/mi-exec-run.exp: inferior-tty=separate: mi=separate: \
  force-fail=1: run failure detected
quit^M
&"quit\n"^M
...

What seems to be happening is that default_gdb_exit sends a cli interpreter
quit command to an mi interpreter, after which again expect just waits for the
timeout.

Fix this by adding mi_gdb_exit to the end of the test-case, as in many other
gdb.mi/*.exp test-cases.

After these two fixes, the test-case takes about 4 seconds.

Tested on x86_64-linux.

20 months ago[gdb/testsuite] Use remote_exec chmod instead of remote_spawn
Tom de Vries [Thu, 27 Oct 2022 14:53:12 +0000 (16:53 +0200)]
[gdb/testsuite] Use remote_exec chmod instead of remote_spawn

I build gdb using -O2, and ran the testsuite using taskset -c 0, and ran into:
...
(gdb) PASS: gdb.server/connect-with-no-symbol-file.exp: sysroot=: \
  action=delete: setup: adjust sysroot
builtin_spawn gdbserver --once localhost:2385 /connect-with-no-symbol-file^M
/bin/bash: connect-with-no-symbol-file: Permission denied^M
/bin/bash: line 0: exec: connect-with-no-symbol-file: cannot execute: \
  Permission denied^M
During startup program exited with code 126.^M
Exiting^M
target remote localhost:2385^M
`connect-with-no-symbol-file' has disappeared; keeping its symbols.^M
localhost:2385: Connection timed out.^M
(gdb) FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: \
  action=delete: connection to GDBserver succeeded
...

The expected series of events is (skipping disconnect and detach as I don't
think they're relevant to the problem):
- enter scenario "permission"
- cp $exec.bak $exec
- gdbserver start with $exec
- chmod 000 $exec
- connect to gdbserver
- enter scenario "delete"
- cp $exec.bak $exec
- gdbserver start with $exec
- delete $exec
- connect to gdbserver

The problem is that the chmod is executed using remote_spawn:
...
       } elseif { $action == "permission" } {
         remote_spawn target "chmod 000 $target_exec"
       }
...
without waiting on the resulting spawn id, so we're not sure when the
chmod will have effect.

The FAIL we're seeing above is explained by the chmod having effect during the
delete scenario, after the "cp $exec.bak $exec" and before the "gdbserver
start with $exec".

Fix this by using remote_exec instead.

Likewise, fix a similar case in gdb.mi/mi-exec-run.exp.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29726

20 months agoRISC-V: Fix build failures for -Werror=sign-compare.
Nelson Chu [Thu, 27 Oct 2022 01:39:13 +0000 (09:39 +0800)]
RISC-V: Fix build failures for -Werror=sign-compare.

elfnn-riscv.c: In function ‘riscv_relax_resolve_delete_relocs’:
elfnn-riscv.c:4256:30: error: operand of ‘?:’ changes signedness from ‘int’ to ‘unsigned int’ due to unsignedness of other operand [-Werror=sign-compare]

So make the operands unsigned could resolve problem.

bfd/
    * elfnn-riscv.c (riscv_relax_resolve_delete_relocs): Fixed build
    failures for -Werror=sign-compare.

20 months agoFuzzed files in archives
Alan Modra [Thu, 27 Oct 2022 05:31:17 +0000 (16:01 +1030)]
Fuzzed files in archives

Given a fuzzed object file in an archive with section size exceeding
file size, objcopy will report an error like "section size (0xfeffffff
bytes) is larger than file size (0x17a bytes)" but will create a copy
of the object laid out for the large section.  That means a large
temporary file on disk that is read back and written to the output
archive, which can take a while.  The output archive is then deleted
due to the error.  Avoid some of this silliness.

* objcopy.c (copy_section): If section contents cannot be read
set output section size to zero.

20 months agotests: use canonical option name
Martin Liska [Wed, 26 Oct 2022 08:44:50 +0000 (10:44 +0200)]
tests: use canonical option name

ld/ChangeLog:

* testsuite/ld-size/size.exp: Use canonical option name.

20 months agore: Support Intel AMX-FP16
Alan Modra [Thu, 27 Oct 2022 00:52:13 +0000 (11:22 +1030)]
re: Support Intel AMX-FP16

Fix these fails due to the target padding out sections with nops.
x86_64-w64-mingw32  +FAIL: x86_64 AMX-FP16 insns
x86_64-w64-mingw32  +FAIL: x86_64 AMX-FP16 insns (Intel disassembly)

* testsuite/gas/i386/x86-64-amx-fp16-intel.d: Accept trailing nops.
* testsuite/gas/i386/x86-64-amx-fp16.d: Likewise.

20 months agoRe: ld/testsuite: adjust ld-arm to run shared tests only when supported
Alan Modra [Thu, 27 Oct 2022 00:15:18 +0000 (10:45 +1030)]
Re: ld/testsuite: adjust ld-arm to run shared tests only when supported

commit 67527cffcd enabled previously disabled tests unresolved-1-dyn,
thumb-plt and thumb-plt-got for nacl.  The first fails due to trying
to link against mixed-lib.so which isn't compiled for nacl.  The last
two fail with
objdump: tmpdir/dump(.rel.plt): relocation 0 has invalid symbol index 14885104
and
readelf: Error:  bad symbol index: 00e320f0 in reloc

Relocation section '.rel.plt' at offset 0x128 contains 1 entry:
 Offset     Info    Type                Sym. Value  Symbol's Name
e320f000  e320f000 R_ARM_NONE

* testsuite/ld-arm/arm-elf.exp: Disable unresolved-1-dyn,
thumb-plt and thumb-plt-got for nacl.

20 months agoAutomatic date update in version.in
GDB Administrator [Thu, 27 Oct 2022 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agogdb/testsuite: fix gdb.guile/scm-parameter.exp "wrong type argument" test pattern...
Simon Marchi [Mon, 24 Oct 2022 16:43:38 +0000 (12:43 -0400)]
gdb/testsuite: fix gdb.guile/scm-parameter.exp "wrong type argument" test pattern for Guile >= 2.2

Since commit 90319cefe3 ("GDB/Guile: Don't assert that an integer value
is boolean"), I see:

    FAIL: gdb.guile/scm-parameter.exp: kind=PARAM_ZINTEGER: test-PARAM_ZINTEGER-param: guile (set-parameter-value! test-PARAM_ZINTEGER-param #:unlimited)
    FAIL: gdb.guile/scm-parameter.exp: kind=PARAM_ZUINTEGER: test-PARAM_ZUINTEGER-param: guile (set-parameter-value! test-PARAM_ZUINTEGER-param #:unlimited)

This comes from the fact that GDB outputs this:

    ERROR: In procedure set-parameter-value!:
    In procedure gdbscm_set_parameter_value_x: Wrong type argument in position 2 (expecting integer): #:unlimited
    Error while executing Scheme code.

while the test expects an additional "ERROR:" on the second line,
something like this:

    ERROR: In procedure set-parameter-value!:
    ERROR: In procedure gdbscm_set_parameter_value_x: Wrong type argument in position 2 (expecting integer): #:unlimited
    Error while executing Scheme code.

Guile 2.0 outputs the `ERROR:` on the second line, while later versions
do not.  Change the pattern to accept both outputs.  This is similar to
commit 6bbe1a929c6 ("[gdb/testsuite] Fix gdb.guile/scm-breakpoint.exp
with guile 3.0").

Change-Id: I9dc45e7492a4f08340cad974610242ed689de959

20 months agogdb/arm: Fix M-profile EXC_RETURN
Luis Machado [Wed, 26 Oct 2022 12:00:50 +0000 (13:00 +0100)]
gdb/arm: Fix M-profile EXC_RETURN

Arm v8-M Architecture Reference Manual,
D1.2.95 EXC_RETURN, Exception Return Payload
describes ES bit:

"ES, bit [0]
     Exception Secure. The security domain the exception was taken to.
     The possible values of this bit are:
       0 Non-secure.
       1 Secure"

arm-tdep.c:3443, arm_m_exception_cache () function tests this bit:

  exception_domain_is_secure = (bit (lr, 0) == 0);

The test is negated!

Later on line 3553, the condition evaluates if an additional state
context is stacked:

  /* With the Security extension, the hardware saves R4..R11 too.  */
  if (tdep->have_sec_ext && secure_stack_used
      && (!default_callee_register_stacking || exception_domain_is_secure))

RM, B3.19 Exception entry, context stacking
reads:
RPLHM "In a PE with the Security Extension, on taking an exception,
the PE hardware:
  ...
  2. If exception entry requires a transition from Secure state to
     Non-secure state, the PE hardware extends the stack frame and also
     saves additional state context."

So we should test for !exception_domain_is_secure instead of non-negated
value!
These two bugs compensate each other so unstacking works correctly.

But another test of exception_domain_is_secure (negated due to the
first bug) prevents arm_unwind_secure_frames to work as expected:

  /* Unwinding from non-secure to secure can trip security
     measures.  In order to avoid the debugger being
     intrusive, rely on the user to configure the requested
     mode.  */
  if (secure_stack_used && !exception_domain_is_secure
      && !arm_unwind_secure_frames)

Test with GNU gdb (GDB) 13.0.50.20221016-git.
Stopped in a non-secure handler:

 (gdb) set arm unwind-secure-frames 0
 (gdb) bt
 #0  HAL_SYSTICK_Callback () at C:/dvl/stm32l5trustzone/GPIO_IOToggle_TrustZone/NonSecure/Src/nsmain.c:490
 #1  0x0804081c in SysTick_Handler ()
     at C:/dvl/stm32l5trustzone/GPIO_IOToggle_TrustZone/NonSecure/Src/nsstm32l5xx_it.c:134
 #2  <signal handler called>
 #3  HAL_GPIO_ReadPin (GPIOx=0x52020800, GPIO_Pin=8192)
     at C:/dvl/stm32l5trustzone/GPIO_IOToggle_TrustZone/Drivers/STM32L5xx_HAL_Driver/Src/stm32l5xx_hal_gpio.c:386
 #4  0x0c000338 in SECURE_Mode () at C:/dvl/stm32l5trustzone/GPIO_IOToggle_TrustZone/Secure/Src/main.c:86
 #5  0x080403f2 in main () at C:/dvl/stm32l5trustzone/GPIO_IOToggle_TrustZone/NonSecure/Src/nsmain.c:278
 Backtrace stopped: previous frame inner to this frame (corrupt stack?)

The frames #3 and #4 are secure. backtrace should stop before #3.

Stopped in a secure handler:

 (gdb) bt
 #0  HAL_SYSTICK_Callback () at C:/dvl/stm32l5trustzone/GPIO_IOToggle_TrustZone/Secure/Src/main.c:425
 #1  0x0c000b6a in SysTick_Handler ()
     at C:/dvl/stm32l5trustzone/GPIO_IOToggle_TrustZone/Secure/Src/stm32l5xx_it.c:234
 warning: Non-secure to secure stack unwinding disabled.
 #2  <signal handler called>

The exception from secure to secure erroneously stops unwinding. It should
continue as far as the security unlimited backtrace:

 (gdb) set arm unwind-secure-frames 1
 (gdb) si <-- used to rebuild frame cache after change of unwind-secure-frames
 0x0c0008e6      425       if (SecureTimingDelay != 0U)
 (gdb) bt
 #0  0x0c0008e6 in HAL_SYSTICK_Callback () at C:/dvl/stm32l5trustzone/GPIO_IOToggle_TrustZone/Secure/Src/main.c:425
 #1  0x0c000b6a in SysTick_Handler ()
     at C:/dvl/stm32l5trustzone/GPIO_IOToggle_TrustZone/Secure/Src/stm32l5xx_it.c:234
 #2  <signal handler called>
 #3  0x0c000328 in SECURE_Mode () at C:/dvl/stm32l5trustzone/GPIO_IOToggle_TrustZone/Secure/Src/main.c:88
 #4  0x080403f2 in main () at C:/dvl/stm32l5trustzone/GPIO_IOToggle_TrustZone/NonSecure/Src/nsmain.c:278

 Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Set exception_domain_is_secure to the value expected by its name.
Fix exception_domain_is_secure usage in the additional state context
stacking condition.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
20 months agogdb/arm: fix IPSR field test in arm_m_exception_cache ()
Luis Machado [Wed, 26 Oct 2022 12:00:17 +0000 (13:00 +0100)]
gdb/arm: fix IPSR field test in arm_m_exception_cache ()

Arm v8-M Architecture Reference Manual,
D1.2.141 IPSR, Interrupt Program Status Register reads
"Exception, bits [8:0]"

9 bits, not 8! It is uncommon but true!

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
20 months agogdb/arm: Terminate frame unwinding in M-profile lockup
Luis Machado [Wed, 26 Oct 2022 11:59:13 +0000 (12:59 +0100)]
gdb/arm: Terminate frame unwinding in M-profile lockup

In the lockup state the PC value of the the outer frame is irreversibly
lost. The other registers are intact so LR likely contains
PC of some frame next to the outer one, but we cannot analyze
the nearest outer frame without knowing its PC
therefore we do not know SP fixup for this frame.

The frame unwinder possibly gets mad due to the wrong SP value.
To prevent problems terminate unwinding if PC contains the magic
value of the lockup state.

Example session wihtout this change,
Cortex-M33 CPU in lockup, gdb 13.0.50.20221016-git:
----------------
  (gdb) c
  Continuing.

  Program received signal SIGINT, Interrupt.
  0xeffffffe in ?? ()
  (gdb) bt
  #0  0xeffffffe in ?? ()
  #1  0x0c000a9c in HardFault_Handler ()
      at C:/dvl/stm32l5trustzone/GPIO_IOToggle_TrustZone/Secure/Src/stm32l5xx_it.c:99
  #2  0x2002ffd8 in ?? ()
  Backtrace stopped: previous frame identical to this frame (corrupt stack?)
  (gdb)
----------------
The frame #1 is at correct PC taken from LR, #2 is a total nonsense.

With the change:
----------------
  (gdb) c
  Continuing.

  Program received signal SIGINT, Interrupt.
  warning: ARM M in lockup state, stack unwinding terminated.
  <signal handler called>
  (gdb) bt
  #0  <signal handler called>
  (gdb)
----------------

There is a visible drawback of emitting a warning in a cache buildnig routine
as introduced in Torbjörn SVENSSON's
[PATCH v4] gdb/arm: Stop unwinding on error, but do not assert
The warning is printed just once and not repeated on each backtrace command.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
20 months agogdb: copyright: make file header scan a bit more pythonic
Mike Frysinger [Sat, 1 Jan 2022 18:08:20 +0000 (13:08 -0500)]
gdb: copyright: make file header scan a bit more pythonic

Should be functionally the same, but uses more pythonic idioms to get
fewer lines of code, and to make sure to not leak open file handles.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
20 months agogdb: make copyright.py interface a bit nicer
Mike Frysinger [Sat, 1 Jan 2022 18:02:02 +0000 (13:02 -0500)]
gdb: make copyright.py interface a bit nicer

This way people can run `./copyright.py --help` and get some info as
to what this does without it going and modifying the tree.

20 months agosim: testsuite: improve parallel test processing
Mike Frysinger [Sun, 23 Oct 2022 19:45:18 +0000 (01:30 +0545)]
sim: testsuite: improve parallel test processing

The current logic limits itself to a maxdepth of 4 when looking for
results.  This wouldn't be a problem if cris didn't have a testsuite
at a depth of 5 which we end up ignoring when summarizing.  Rather
than bump the number from 4 to 5, rework the code so that we gather
the exact set of tests that we tried to run.

20 months agobuffer overflow in _bfd_XX_print_ce_compressed_pdata
Alan Modra [Wed, 26 Oct 2022 07:20:29 +0000 (17:50 +1030)]
buffer overflow in _bfd_XX_print_ce_compressed_pdata

More fuzzed fun.

* peXXigen.c (_bfd_XX_print_ce_compressed_pdata): Use smaller of
virt_size and bfd section size as limit of function table.

20 months agoCorrect ELF reloc size sanity check
Alan Modra [Wed, 26 Oct 2022 06:43:12 +0000 (17:13 +1030)]
Correct ELF reloc size sanity check

The external reloc size check was wrong.  Here asect is the code/data
section, not the reloc section.  So using this_hdr gave the size of
the code/data section.

* elf.c (_bfd_elf_get_reloc_upper_bound): Properly get
external size from reloc headers.

20 months agosegfault in objdump.c reloc_at
Alan Modra [Wed, 26 Oct 2022 06:04:19 +0000 (16:34 +1030)]
segfault in objdump.c reloc_at

bfd_canonicalize_reloc returns -1L on errors.

* objdump.c (load_specific_debug_section): Properly handle
error return from bfd_canonicalize_reloc.

20 months agosom.c reloc sanity checking
Alan Modra [Wed, 26 Oct 2022 00:58:08 +0000 (11:28 +1030)]
som.c reloc sanity checking

This patch checks that relocations emitted in som_write_fixups have
offsets that are monotonic and within a section.  To do that properly
using bfd_reloc_offset_in_range it is necessary to set the reloc howto
size field, which isn't used otherwise by the som backend.  Note that
the sizes used are not exactly those in the old sizing switch
statement deleted from som_write_fixups, but all relocs handled by the
main switch statement there get the same size.  Most unhandled relocs
get a zero size (exceptions being R_RELOCATION, R_SPACE_REF,
R_MILLI_REL, R_BREAKPOINT which all involve writing one word according
to my SOM reference).  I figure it doesn't matter since any unhandled
reloc is converted to 0xff R_RESERVED, and a default of zero is better
for a "don't know" reloc.

Besides tidying the code, stringizing name from type in SOM_HOWTO
fixes R_REPEATED_INIT name.

* som.c (SOM_HOWTO): Add SIZE arg, delete NAME.  Stringize type
to name.
(som_hppa_howto_table): Update with sizes.
(som_write_fixups): Delete sizing switch statement.  Sanity check
bfd_reloc address against subsection size.

20 months agosom.c buffer overflow
Alan Modra [Wed, 26 Oct 2022 00:56:34 +0000 (11:26 +1030)]
som.c buffer overflow

Fuzzed object files can put random values in bfd_reloc->address,
leading to large som_reloc_skip output.

* som.c (som_write_fixups): Allow for maximal som_reloc_skip.

20 months agoPR29720, objdump -S crashes if build-id is missing
Alan Modra [Tue, 25 Oct 2022 23:11:55 +0000 (09:41 +1030)]
PR29720, objdump -S crashes if build-id is missing

PR 29720
* objdump.c (slurp_file): Don't call debuginfod_find_source
when build_id is NULL.

20 months agoAutomatic date update in version.in
GDB Administrator [Wed, 26 Oct 2022 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agogdb: remove spurious spaces after frame_info_ptr
Simon Marchi [Tue, 25 Oct 2022 02:05:15 +0000 (22:05 -0400)]
gdb: remove spurious spaces after frame_info_ptr

Fix some whitespace issues introduced with the frame_info_ptr patch.

Change-Id: I158d30d8108c97564276c647fc98283ff7b12163

20 months agox86-64: Use only one default max-page-size
Michael Matz [Thu, 20 Oct 2022 14:06:57 +0000 (16:06 +0200)]
x86-64: Use only one default max-page-size

On x86-64 the default ELF_MAXPAGESIZE depends on a configure
option (--disable-separate-code).  Since 9833b775
("PR28824, relro security issues") we use max-page-size for relro
alignment (with a short interval, from 31b4d3a ("PR28824, relro
security issues, x86 keep COMMONPAGESIZE relro") to its revert
a1faa5ea, where x86-64 only used COMMONPAGESIZE as relro alignment
target).

But that means that a linker configured with --disable-separate-code
behaves different from one configured with --enable-separate-code
(the default), _even if using "-z {no,}separate-code" option to use
the non-configured behaviour_ .  In particular it means that when
configuring with --disable-separate-code the linker will produce
binaries aligned to 2MB pages on disk, and hence generate 2MB
executables for a hello world (and even 6MB when linked with
"-z separate-code").

Generally we can't have constants that ultimately land in static
variables be depending on configure options if those only influence
behaviour that is overridable by command line options.

So, do away with that, make the default MAXPAGESIZE be 4k (as is default
for most x86-64 configs anyway, as most people won't configure with
--disable-separate-code).  If people need more they can use the
"-z max-page-size" (with would have been required right now for a
default configure binutils).

bfd/
* elf64-x86-64.c (ELF_MAXPAGESIZE): Don't depend on
DEFAULT_LD_Z_SEPARATE_CODE.

20 months agogdb/testsuite: make sure to consume the prompt in gdb.base/unwind-on-each-insn.exp
Simon Marchi [Tue, 25 Oct 2022 13:50:56 +0000 (09:50 -0400)]
gdb/testsuite: make sure to consume the prompt in gdb.base/unwind-on-each-insn.exp

This test fails quite reliably for me when ran as:

    $ taskset -c 1 make check TESTS="gdb.base/unwind-on-each-insn.exp" RUNTESTFLAGS="--target_board=native-gdbserver"

or more simply:

    $ make check-read1 TESTS="gdb.base/unwind-on-each-insn.exp"

The problem is that the gdb_test_multiple call that grabs the frame id
from "maint print frame-id" does not consume the prompt.  Well, it does
sometimes due to the trailing .*, but not always.  If the prompt is not
consumed, the tests that follow get confused:

    FAIL: gdb.base/unwind-on-each-insn.exp: gdb_breakpoint: set breakpoint at *foo
    FAIL: gdb.base/unwind-on-each-insn.exp: disassemble foo
    FAIL: gdb.base/unwind-on-each-insn.exp: get $sp and frame base in foo: get hexadecimal valueof "$sp"
    ... many more ...

Use -wrap to make gdb_test_multiple consume the prompt.

While at it, remove the bit that consumes the command name and do
exp_continue, it's not really necessary.  And for consistency, do the
same changes to the gdb_test_multiple that consumes the stack address,
although that one was fine, it did consume the prompt explicitly.

Change-Id: I2b7328c8844c7e98921ea494c4c05107162619fc
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
20 months ago[gdb/testsuite] Handle missing .note.GNU-stack
Tom de Vries [Tue, 25 Oct 2022 12:14:34 +0000 (14:14 +0200)]
[gdb/testsuite] Handle missing .note.GNU-stack

On openSUSE Tumbleweed I run into this for the dwarf assembly test-cases, and
some hardcoded assembly test-cases:
...
 Running gdb.dwarf2/fission-absolute-dwo.exp ...
 gdb compile failed, ld: warning: fission-absolute-dwo.o: \
   missing .note.GNU-stack section implies executable stack
 ld: NOTE: This behaviour is deprecated and will be removed in a future \
   version of the linker

                 === gdb Summary ===

 # of untested testcases         1
...

Fix the dwarf assembly test-cases by adding the missing .note.GNU-stack in
proc Dwarf::assemble.

Fix the hard-coded test-cases using this command:
...
$ for f in $(find gdb/testsuite/gdb.* -name *.S); do
    if ! grep -q note.GNU-stack $f; then
      echo -e "\t.section\t.note.GNU-stack,\"\",@progbits" >> $f;
    fi;
  done
...

Likewise for .s files, and gdb/testsuite/lib/my-syscalls.S.

The idiom for arm seems to be to use %progbits instead, see commit 9a5911c08be
("gdb/testsuite/gdb.dwarf2: Replace @ with % for ARM compatability"), so
hand-edit gdb/testsuite/gdb.arch/arm-disp-step.S to use %progbits instead.

Note that dwarf assembly testcases use %progbits as decided by proc _section.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29674

20 months ago[gdb/testsuite] Add missing skip_gdbserver_tests in gdb.multi/attach-no-multi-process.exp
Tom de Vries [Tue, 25 Oct 2022 12:09:32 +0000 (14:09 +0200)]
[gdb/testsuite] Add missing skip_gdbserver_tests in gdb.multi/attach-no-multi-process.exp

I build gdb without gdbserver, and ran into:
...
(gdb) PASS: gdb.multi/attach-no-multi-process.exp: target_non_stop=off: \
  switch to inferior 2
spawn of  --once --multi localhost:2346 failed
ERROR: tcl error sourcing attach-no-multi-process.exp.
ERROR: tcl error code NONE
ERROR: Timeout waiting for gdbserver response.
...

Add the missing skip_gdbserver_tests.

Tested on x86_64-linux.

20 months ago[gdb] Rewrite RETHROW_ON_TARGET_CLOSE_ERROR into function
Tom de Vries [Tue, 25 Oct 2022 09:32:41 +0000 (11:32 +0200)]
[gdb] Rewrite RETHROW_ON_TARGET_CLOSE_ERROR into function

Recent commit b2829fcf9b5 ("[gdb] Fix rethrow exception slicing in
insert_bp_location") introduced macro RETHROW_ON_TARGET_CLOSE_ERROR.

I wrote this as a macro in order to have the rethrowing throw be part of the
same function as the catch, but as it turns out that's not necessary.

Rewrite into a function.

Tested on x86_64-linux.

20 months agogdb: internal_error -> internal_error_loc in gdb-gdb.gdb.in
Simon Marchi [Tue, 25 Oct 2022 04:11:29 +0000 (00:11 -0400)]
gdb: internal_error -> internal_error_loc in gdb-gdb.gdb.in

Commit f34652de0b ("internal_error: remove need to pass
__FILE__/__LINE__") renamed the internal_error function to
internal_error_loc.  Change gdb-gdb.gdb.in accordingly.

Change-Id: I876e1623607b6becf74ade53d102ead53a74ed86

20 months agoRISC-V: Should reset `again' flag for _bfd_riscv_relax_pc.
Nelson Chu [Mon, 24 Oct 2022 10:26:36 +0000 (18:26 +0800)]
RISC-V: Should reset `again' flag for _bfd_riscv_relax_pc.

The R_RISCV_DELETE relocations are no longer deleted at another relax pass,
so we should reset 'again' flag to true for _bfd_riscv_relax_pc, while the
deleted bytes are marked as R_RISCV_DELETE.

bfd/
    * elfnn-riscv.c (_bfd_riscv_relax_pc): Set `again' to true while the
    deleted bytes are marked as R_RISCV_DELETE.

20 months agoRISC-V: Improve link time complexity.
Patrick O'Neill [Mon, 17 Oct 2022 01:37:35 +0000 (09:37 +0800)]
RISC-V: Improve link time complexity.

The riscv port does deletion and symbol table update for each relocation
while relaxing, so we are moving section bytes and scanning symbol table once
for each relocation.  Compared to microblaze port, they record the relaxation
changes into a table, then do the deletion and symbol table update once per
section, rather than per relocation.  Therefore, they should have better link
time complexity than us.

To improve the link time complexity, this patch try to make the deletion in
linear time.  Compared to record the relaxation changes into a table, we
replace the unused relocation with R_RISCV_DELETE for the deleted bytes, and
then resolve them at the end of the section.  Assuming the number of
R_RISCV_DELETE is m, and the number of symbols is n, the total link complexity
should be O(m) for moving section bytes, and O(m*n^2) for symbol table update.
If we record the relaxation changes into the table, and then sort the symbol
table by values, then probably can reduce the time complexity to O(m*n*log(n))
for updating symbol table, but it doesn't seem worth it for now.

bfd/
    * elfnn-riscv.c (_riscv_relax_delete_bytes): Renamed from
    riscv_relax_delete_bytes, updated to reduce the tiem complexity to O(m)
    for memmove.
    (typedef relax_delete_t): Function pointer declaration of delete functions.
    (riscv_relax_delete_bytes): Can choose to use _riscv_relax_delete_piecewise
    or _riscv_relax_delete_immediate for deletion.
    (_riscv_relax_delete_piecewise): Just mark the deleted bytes as R_RISCV_DELETE.
    (_riscv_relax_delete_immediate): Delete some bytes from a section while
    relaxing.
    (riscv_relax_resolve_delete_relocs): Delete the bytes for R_RISCV_DELETE
    relocations from a section, at the end of _bfd_riscv_relax_section.
    (_bfd_riscv_relax_call): Mark deleted bytes as R_RISCV_DELETE by reusing
    R_RISCV_RELAX.
    (_bfd_riscv_relax_lui): Likewise, but reuse R_RISCV_HI20 for lui, and reuse
    R_RISCV_RELAX for c.lui.
    (_bfd_riscv_relax_tls_le): Likewise, but resue R_RISCV_TPREL_HI20 and
    R_RISCV_TPREL_ADD.
    (_bfd_riscv_relax_pc): Likewise, but resue R_RISCV_PCREL_HI20 for auipc.
    (_bfd_riscv_relax_align): Updated, don't need to resue relocation since
    calling _riscv_relax_delete_immediate.
    (_bfd_riscv_relax_delete): Removed.
    (_bfd_riscv_relax_section): Set riscv_relax_delete_bytes for each relax_func,
    to delete bytes immediately or later.  Call riscv_relax_resolve_delete_relocs
    to delete bytes for DELETE relocations from a section.

20 months agoAutomatic date update in version.in
GDB Administrator [Tue, 25 Oct 2022 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agogdb/doc: reword description of DisassembleInfo.read_memory
Andrew Burgess [Mon, 24 Oct 2022 17:04:42 +0000 (18:04 +0100)]
gdb/doc: reword description of DisassembleInfo.read_memory

While reading the documentation of DisassembleInfo.read_memory I
spotted the word 'available' in one sentence where it didn't make
sense.

20 months agosim/lm32: fix some missing function declaration warnings
Andrew Burgess [Wed, 19 Oct 2022 14:31:28 +0000 (15:31 +0100)]
sim/lm32: fix some missing function declaration warnings

In the lm32 simulator, I was seeing some warnings about missing
function declarations.

The lm32 simulator has a weird header structure, in order to pull in
the full cpu.h header we need to define WANT_CPU_LM32BF.  This is done
in some files, but not in others.  Critically, it's not done in some
files that then use functions declared in cpu.h

In this commit I added the missing #define so that the full cpu.h can
be included.

After doing this there are still a few functions that are used
undeclared, these functions appear to be missing any declarations at
all, so I've added some to cpu.h.

With this done all the warnings when compiling lm32 are resolved for
both gcc and clang, so I've removed the SIM_WERROR_CFLAGS line from
Makefile.in, this allows lm32 to build with -Werror.

20 months agosim/h8300: avoid self assignment
Andrew Burgess [Wed, 19 Oct 2022 14:19:18 +0000 (15:19 +0100)]
sim/h8300: avoid self assignment

There are two places in the h8300 simulator where we assign a variable
to itself.  Clang gives a warning for this, which is converted into an
error by -Werror.

Silence the warning by removing the self assignments.  As these
assignments were in a complex if/then/else tree, rather than try to
adjust all the conditions, I've just replaced the self assignments
with a comment and an empty statement.

20 months agosim/aarch64: remove two unused functions
Andrew Burgess [Wed, 19 Oct 2022 14:16:53 +0000 (15:16 +0100)]
sim/aarch64: remove two unused functions

These functions are not used.  Clang warns about the unused functions,
which is then converted into an error by -Werror.

Delete the unused functions.

20 months agosim/ppc: fix for operator precedence warning from clang
Andrew Burgess [Wed, 19 Oct 2022 14:12:57 +0000 (15:12 +0100)]
sim/ppc: fix for operator precedence warning from clang

In the ppc simulator, clang was warning about some code like this:

  busy_ptr->nr_writebacks = 1 + (PPC_ONE_BIT_SET_P(out_vmask)) ? 1 : 2;

The warning was:

  operator '?:' has lower precedence than '+'; '+' will be evaluated first

I suspect that this is not the original authors intention.
PPC_ONE_BIT_SET_P is going to be 0 or 1, so if we evaluate the '+'
first, the condition will always be non-zero, so true.  The whole
expression could then be simplified to just '1', which doesn't make
much sense.

I suspect the answer the author was expecting was either 2 or 3.  Why
they didn't just write:

  busy_ptr->nr_writebacks = (PPC_ONE_BIT_SET_P(out_vmask)) ? 2 : 3;

I have no clue, however, to keep the structure of the code unchanged,
I've updated things to:

  busy_ptr->nr_writebacks = 1 + (PPC_ONE_BIT_SET_P (out_vmask) ? 1 : 2);

which silences the warning from clang, and is, I am guessing, what the
original author intended.

20 months agosim/ppc: initialize a memory buffer in all cases
Andrew Burgess [Wed, 19 Oct 2022 14:07:40 +0000 (15:07 +0100)]
sim/ppc: initialize a memory buffer in all cases

In the ppc simulator's do_fstat function, which provides the fstat
call for the simulator, if the fstat is going to fail then we
currently write an uninitialized buffer into the simulated target.

In theory, I think this is fine, we also write the error status into
the simulated target, so, given that the fstat has failed, the target
shouldn't be relying on the buffer contents.

However, writing an uninitialized buffer means we might leak simulator
private data into the simulated target, which is probably a bad thing.
Plus it probably makes life easier if something consistent, like all
zeros, is written rather than random junk, which might look like a
successful call (except for the error code).

So, in this commit, I initialize the stat buffer to zero before
it is potentially used.  If the stat call is not made then the buffer
will be left initialized as all zeros.

20 months agosim/ppc: don't try to print an uninitialized variable
Andrew Burgess [Wed, 19 Oct 2022 14:06:10 +0000 (15:06 +0100)]
sim/ppc: don't try to print an uninitialized variable

The ppc simulator, in sim_create_inferior, tries to print the function
local entry_point variable before the variable is initialized.

In this commit, I defer the debug print line until the variable has
been initialized.

20 months agosim/sh: use fabs instead of abs
Andrew Burgess [Wed, 19 Oct 2022 14:04:14 +0000 (15:04 +0100)]
sim/sh: use fabs instead of abs

The sh simulator incorrectly uses integer abs instead of the floating
point fabs on some floating point values, fixed in this commit.

20 months ago[gdb] Fix rethrow exception slicing in insert_bp_location
Tom de Vries [Mon, 24 Oct 2022 12:20:49 +0000 (14:20 +0200)]
[gdb] Fix rethrow exception slicing in insert_bp_location

The preferred way of rethrowing an exception is by using throw without
expression, because it avoids object slicing of the exception [1].

Fix this in insert_bp_location.

Tested on x86_64-linux.

[1] https://en.cppreference.com/w/cpp/language/throw

Approved-By: Andrew Burgess <aburgess@redhat.com>
20 months ago[gdb] Fix rethrow exception slicing in pretty_print_insn
Tom de Vries [Mon, 24 Oct 2022 12:20:49 +0000 (14:20 +0200)]
[gdb] Fix rethrow exception slicing in pretty_print_insn

The preferred way of rethrowing an exception is by using throw without
expression, because it avoids object slicing of the exception [1].

Fix this in gdb_pretty_print_disassembler::pretty_print_insn.

Tested on x86_64-linux.

[1] https://en.cppreference.com/w/cpp/language/throw

Approved-By: Andrew Burgess <aburgess@redhat.com>
20 months agold/testsuite: adjust ld-arm to run shared tests only when supported
Clément Chigot [Thu, 20 Oct 2022 13:32:00 +0000 (15:32 +0200)]
ld/testsuite: adjust ld-arm to run shared tests only when supported

If a custom arm-elf target is disabling the shared support, a lot of
failures are reported by the testsuite.
Moreover, some tests try to access libraries which have been explicitly
skipped earlier (eg mixed-lib.so).

ld/ChangeLog:

* testsuite/ld-arm/arm-elf.exp: Separate tests needing shared
lib support.

20 months agold/testsuite: skip ld-elf/exclude when -shared is not supported
Clément Chigot [Thu, 20 Oct 2022 13:31:24 +0000 (15:31 +0200)]
ld/testsuite: skip ld-elf/exclude when -shared is not supported

ld/ChangeLog:

* testsuite/ld-elf/exclude.exp: Call check_shared_lib_support.
to skip for all targets without shared lib support.

20 months agox86: consolidate VPCLMUL tests
Jan Beulich [Mon, 24 Oct 2022 07:34:23 +0000 (09:34 +0200)]
x86: consolidate VPCLMUL tests

There's little point in having Intel syntax disassembler tests when the
purpose of a test is assembler functionality: Drop all
*avx512*_vpclmulqdq-wig1-intel.

For *avx512*_vpclmulqdq-wig1 share source with *avx512*_vpclmulqdq.

Finally put in place similar tests for -mvexwig=1.

20 months agox86: consolidate VAES tests
Jan Beulich [Mon, 24 Oct 2022 07:32:59 +0000 (09:32 +0200)]
x86: consolidate VAES tests

There's little point in having Intel syntax disassembler tests when the
purpose of a test is assembler functionality: Drop all
*avx512*_vaes-wig1-intel.

For *avx512*_vaes-wig1 share source with *avx512*_vaes. This in
particular makes sure that the 32-bit VL test actually tests any EVEX
encodings in the first place.

Finally put in place similar tests for -mvexwig=1.

20 months agox86: emit {evex} prefix when disassembling ambiguous AVX512VL insns
Jan Beulich [Mon, 24 Oct 2022 07:30:58 +0000 (09:30 +0200)]
x86: emit {evex} prefix when disassembling ambiguous AVX512VL insns

When no AVX512-specific functionality is in use, the disassembly of
AVX512VL insns is indistinguishable from their AVX counterparts (if such
exist). Emit the {evex} pseudo-prefix in such cases.

Where applicable drop stray uses of PREFIX_OPCODE from table entries.

20 months ago[gdb/testsuite] Add skip_python_tests in gdb.python/tui-window-names.exp
Tom de Vries [Mon, 24 Oct 2022 06:36:42 +0000 (08:36 +0200)]
[gdb/testsuite] Add skip_python_tests in gdb.python/tui-window-names.exp

I did a gdb build without python support, and during testing ran into FAILs in
test-case gdb.python/tui-window-names.exp.

Fix this by adding the missing skip_python_test.

Tested on x86_64-linux.

20 months agoAutomatic date update in version.in
GDB Administrator [Mon, 24 Oct 2022 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agosim: testsuite: update ignored .exp files [PR sim/29596]
Mike Frysinger [Sun, 23 Oct 2022 19:43:15 +0000 (01:28 +0545)]
sim: testsuite: update ignored .exp files [PR sim/29596]

Now that we run `check/foo.exp` instead of `check/./foo.exp`,
update the config/ & lib/ exceptions to cover both paths.

Bug: https://sourceware.org/PR29596

20 months agosim: testsuite: tweak parallel find invocation [PR sim/29596]
Mike Frysinger [Sun, 23 Oct 2022 19:11:46 +0000 (00:56 +0545)]
sim: testsuite: tweak parallel find invocation [PR sim/29596]

Make sure we invoke runtest with the same exp filenames when running in
parallel as it will find when run single threaded.  When `runtest` finds
files itself, it will use paths like "aarch64/allinsn.exp".  When we run
`find .` with the %p option, it produces "./aarch64/allinsn.exp".  Switch
to %P to get "aarch64/allinsn.exp".

Bug: https://sourceware.org/PR29596

20 months agosim: mips/ppc/riscv: re-add AC_CANONICAL_SYSTEM [PR sim/29439]
Mike Frysinger [Sun, 23 Oct 2022 17:01:16 +0000 (22:46 +0545)]
sim: mips/ppc/riscv: re-add AC_CANONICAL_SYSTEM [PR sim/29439]

These configure scripts check $target and change behavior.  They
shouldn't be doing that, but until we can rework the sim to change
behavior based on the input ELF, restore AC_CANONICAL_SYSTEM to
these so that $target is correctly populated.

This was lost in the d3562f83a7b8a1ae6e333cd5561419d3da18fcb4
("sim: unify toolchain probing logic") refactor as the logic was
hoisted up to the common code.  But the fact the vars weren't
passed down to the sub-configure scripts was missed.

Bug: https://sourceware.org/PR29439

20 months agoAutomatic date update in version.in
GDB Administrator [Sun, 23 Oct 2022 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agogdb/testsuite: add max number of instructions check in gdb.base/unwind-on-each-insn.exp
Simon Marchi [Sat, 22 Oct 2022 03:58:15 +0000 (23:58 -0400)]
gdb/testsuite: add max number of instructions check in gdb.base/unwind-on-each-insn.exp

This test sends my CI in an infinite loop of failures.   We expect to
have a handful of iterations (5 on my development machine, where the
test passes fine)but the log shows that it went up to 104340 iterations:

    FAIL: gdb.base/unwind-on-each-insn.exp - instruction 104340: maint print frame-id
    DUPLICATE: gdb.base/unwind-on-each-insn.exp - instruction 104340: maint print frame-id
    FAIL: gdb.base/unwind-on-each-insn.exp - instruction 104340: [string equal $fid $main_fid]
    FAIL: gdb.base/unwind-on-each-insn.exp - instruction 104340: get hexadecimal valueof "$pc"

Add a max instruction check, exit the loop if we reach 100 iterations.
This should allow the test to fail fast if there's a problem, but 100
iterations should be more than enough for when things are working.

Change-Id: I77978d593aca046068f9209272d82e1675ba17c2

20 months agoAutomatic date update in version.in
GDB Administrator [Sat, 22 Oct 2022 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agoImprove Python Unwinders documentation
Pedro Alves [Fri, 30 Sep 2022 16:23:03 +0000 (17:23 +0100)]
Improve Python Unwinders documentation

- avoid "GDB proper" to refer to global locus, as object files and
  program spaces are also GDB proper.

- gdb.register_unwinder does not accept locus=gdb.

- "a unwinder" -> "an unwinder"

Approved-by: Eli Zaretskii <eliz@gnu.org>
Change-Id: I98c1b1000e1063815238e945ca71ec6f37b5702e

20 months agogdb: make inherit_abstract_dies use vector iterators
Simon Marchi [Fri, 21 Oct 2022 13:17:53 +0000 (09:17 -0400)]
gdb: make inherit_abstract_dies use vector iterators

Small cleanup to use std::vector iterators rather than raw pointers.

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

20 months agogdb: check for empty offsets vector in inherit_abstract_dies
Simon Marchi [Fri, 21 Oct 2022 13:08:03 +0000 (09:08 -0400)]
gdb: check for empty offsets vector in inherit_abstract_dies

When building GDB with clang and --enable-ubsan, I get:

  UNRESOLVED: gdb.dwarf2/frame-inlined-in-outer-frame.exp: starti prompt

The cause being:

    $ ./gdb --data-directory=data-directory -nx -q -readnow testsuite/outputs/gdb.dwarf2/frame-inlined-in-outer-frame/frame-inlined-in-outer-frame
    Reading symbols from testsuite/outputs/gdb.dwarf2/frame-inlined-in-outer-frame/frame-inlined-in-outer-frame...
    Expanding full symbols from testsuite/outputs/gdb.dwarf2/frame-inlined-in-outer-frame/frame-inlined-in-outer-frame...
    /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:11954:47: runtime error: applying non-zero offset 8 to null pointer

I found this to happen with ld-linux on at least Arch Linux and Ubuntu
22.04:

    $ ./gdb --data-directory=data-directory -nx -q -readnow -iex "set debuginfod enabled on" /lib64/ld-linux-x86-64.so.2
    Reading symbols from /lib64/ld-linux-x86-64.so.2...
    Reading symbols from /home/simark/.cache/debuginfod_client/22bd7a2c03d8cfc05ef7092bfae5932223189bc1/debuginfo...
    Expanding full symbols from /home/simark/.cache/debuginfod_client/22bd7a2c03d8cfc05ef7092bfae5932223189bc1/debuginfo...
    /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:11954:47: runtime error: applying non-zero offset 8 to null pointer

The problem happens when doing this:

    sect_offset *offsetp = offsets.data () + 1

When `offsets` is an empty vector, `offsets.data ()` returns nullptr.
Fix it by wrapping that in a `!offsets.empty ()` check.

Change-Id: I6d29ba2fe80ba4308f68effd9c57d4ee8d67c29f
Approved-By: Tom Tromey <tom@tromey.com>
20 months agoreadelf: support zstd compressed debug sections [PR 29640]
Fangrui Song [Fri, 21 Oct 2022 16:33:38 +0000 (09:33 -0700)]
readelf: support zstd compressed debug sections [PR 29640]