Commit Graph

111719 Commits

Author SHA1 Message Date
Alan Modra
f84ffabbb3 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.
2022-10-26 17:56:38 +10:30
Alan Modra
5dcae8f603 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.
2022-10-26 17:27:45 +10:30
Alan Modra
4d664d5711 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.
2022-10-26 17:27:45 +10:30
Alan Modra
b8d97d3857 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.
2022-10-26 15:36:14 +10:30
Alan Modra
2f6ba62ed3 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.
2022-10-26 15:36:14 +10:30
Alan Modra
6175be4175 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.
2022-10-26 15:34:53 +10:30
GDB Administrator
9254cd1fd8 Automatic date update in version.in 2022-10-26 00:00:08 +00:00
Simon Marchi
9efe17a3a0 gdb: remove spurious spaces after frame_info_ptr
Fix some whitespace issues introduced with the frame_info_ptr patch.

Change-Id: I158d30d8108c97564276c647fc98283ff7b12163
2022-10-25 11:04:58 -04:00
Michael Matz
a2267dbfc9 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.
2022-10-25 16:41:26 +02:00
Simon Marchi
7699dfc8d5 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>
2022-10-25 10:36:23 -04:00
Tom de Vries
0f2cd53cf4 [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 9a5911c08b
("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
2022-10-25 14:14:34 +02:00
Tom de Vries
4ff322b6fa [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.
2022-10-25 14:09:32 +02:00
Tom de Vries
47e2c30aac [gdb] Rewrite RETHROW_ON_TARGET_CLOSE_ERROR into function
Recent commit b2829fcf9b ("[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.
2022-10-25 11:32:41 +02:00
Simon Marchi
a5a0a4fd0f 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
2022-10-25 00:12:38 -04:00
Nelson Chu
845652b784 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.
2022-10-25 09:20:39 +08:00
Patrick O'Neill
43025f01a0 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.
2022-10-25 09:20:23 +08:00
GDB Administrator
4ed07377e4 Automatic date update in version.in 2022-10-25 00:00:07 +00:00
Andrew Burgess
c6d20401a2 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.
2022-10-24 18:04:42 +01:00
Andrew Burgess
1be79b1ebf 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.
2022-10-24 17:24:29 +01:00
Andrew Burgess
da8b81754b 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.
2022-10-24 17:23:47 +01:00
Andrew Burgess
36edbb454f 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.
2022-10-24 17:20:29 +01:00
Andrew Burgess
e0b3df3b4d 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.
2022-10-24 17:19:04 +01:00
Andrew Burgess
548d634f1b 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.
2022-10-24 17:12:11 +01:00
Andrew Burgess
368b8c3259 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.
2022-10-24 17:01:04 +01:00
Andrew Burgess
ffa2d04822 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.
2022-10-24 17:00:49 +01:00
Tom de Vries
b2829fcf9b [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>
2022-10-24 14:20:49 +02:00
Tom de Vries
0a9c805dfd [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>
2022-10-24 14:20:49 +02:00
Clément Chigot
67527cffcd 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.
2022-10-24 14:05:48 +02:00
Clément Chigot
13b87bbf0d 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.
2022-10-24 14:05:48 +02:00
Jan Beulich
05bb930a05 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.
2022-10-24 09:34:23 +02:00
Jan Beulich
a87cd57616 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.
2022-10-24 09:32:59 +02:00
Jan Beulich
f7cfcddd16 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.
2022-10-24 09:30:58 +02:00
Tom de Vries
b347f57895 [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.
2022-10-24 08:36:42 +02:00
GDB Administrator
05962dc48c Automatic date update in version.in 2022-10-24 00:00:07 +00:00
Mike Frysinger
e60091e4d3 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
2022-10-24 01:28:15 +05:45
Mike Frysinger
86ef36f655 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
2022-10-24 00:58:49 +05:45
Mike Frysinger
89d5fc244f 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 d3562f83a7
("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
2022-10-23 22:51:17 +05:45
GDB Administrator
df5ffabf1c Automatic date update in version.in 2022-10-23 00:00:06 +00:00
Simon Marchi
49c843e6d2 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
2022-10-22 00:04:01 -04:00
GDB Administrator
095e74caa7 Automatic date update in version.in 2022-10-22 00:00:07 +00:00
Pedro Alves
62fe72fda1 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
2022-10-21 22:05:16 +01:00
Simon Marchi
129d1afcc5 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
2022-10-21 14:27:11 -04:00
Simon Marchi
f2423983a8 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>
2022-10-21 14:26:58 -04:00
Fangrui Song
1f5a354612 readelf: support zstd compressed debug sections [PR 29640] 2022-10-21 09:33:38 -07:00
Tom Tromey
2afd002ac6 Fix incorrect .gdb_index with new DWARF scanner
PR symtab/29694 points out a regression caused by the new DWARF
scanner when the cc-with-gdb-index target board is used.

What happens here is that an older version of gdb will make an index
describing the "A" type as:

[737] A: 1 [global, type]

whereas the new gdb says:

[1008] A: 0 [global, type]

Here the old one is correct because the A in CU 0 is just a
declaration without a size:

 <1><45>: Abbrev Number: 10 (DW_TAG_structure_type)
    <46>   DW_AT_name        : A
    <48>   DW_AT_declaration : 1
    <48>   DW_AT_sibling     : <0x6d>

This patch fixes the problem by introducing the idea of a "type
declaration".  I think gdb still needs to recurse into these types,
searching for methods, but by marking the type itself as a
declaration, gdb can skip this type during lookups and when writing
the index.

Regression tested on x86-64 using the cc-with-gdb-index board.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29694
2022-10-21 09:54:38 -06:00
Tom Tromey
e379f6521a Fix crash in value_print_array_elements
A user noticed that gdb would crash when printing a packed array after
doing "set lang c".  Packed arrays don't exist in C, but it's
occasionally useful to print things in C mode when working in a non-C
language -- this lets you see under the hood a little bit.

The bug here is that generic value printing does not handle packed
arrays at all.  This patch fixes the bug by introducing a new function
to extract a value from a bit offset and width.

The new function includes a hack to avoid problems with some existing
test cases when using -fgnat-encodings=all.  Cleaning up this code
looked difficult, and since "all" is effectively deprecated, I thought
it made sense to simply work around the problems.
2022-10-21 09:40:59 -06:00
Tom Tromey
6c849804cf Fix bug in Ada packed array handling
A user found a bug where an array of packed arrays was printed
incorrectly.  The bug here is that the packed array has a bit stride,
but the outer array does not -- and should not.  However,
update_static_array_size does not distinguish between an array of
packed arrays and a multi-dimensional packed array, and for the
latter, only the innermost array will end up with a stride.

This patch fixes the problem by adding a flag to indicate whether a
given array type is a constituent of a multi-dimensional array.
2022-10-21 09:40:58 -06:00
Simon Marchi
75436c534b gdb: declare variables on first use in inherit_abstract_dies
Move variable declarations to where they are first use, plus some random
style fixes.

Change-Id: Idf40d60f9034996fa6a234165cd989a721eb4148
2022-10-21 08:58:21 -04:00
Nick Clifton
4b2e7a577c Add a -w option to the linker to suppress warning and error messages.
PR 29654
	* ld.h (struct ld_config_type): Add no_warnings field.
	* ldlex.h (enum option_values): Add OPTION_NO_WARNINGS.
	* lexsup.c (ld_options): Add --no-warnings.
	(parse_args): Add support for -w and --no-warnings.
	* ldmisc.c (vfinfo): Return early if the message is a warning and
	-w has been enabled.
	* ld.texi (options): Document new command line option.
	* NEWS: Mention the new feature.
2022-10-21 12:20:09 +01:00
Nick Clifton
816be8d8b7 Add a note to the binutils/NEWS file about DCO signed contributions. 2022-10-21 11:58:47 +01:00