Commit Graph

112353 Commits

Author SHA1 Message Date
Tom Tromey
53fd08b60d Cosmetic fix in ppc-sysv-tdep.c
This is just a couple of cosmetic fixes in ppc-sysv-tdep.c: fixing
some formatting and correcting a typo.
2022-12-06 08:59:09 -07:00
Tom Tromey
e03698c122 Fix operator precedence bug in Rust parser
PR rust/29859 points out an operator precedence bug in the Rust
parser.  This patch fixes it and adds a regression test.
2022-12-06 07:41:52 -07:00
Nick Clifton
83f18e5ebe Fix a dereference of NULL when scanning the symbol hashes array in the ARM linker.
PR 29852
	* elf32-arm.c (cmse_scan): Check for NULL entries in the
	sym_hashes array.
	(elf32_arm_gc_mark_extra_sections): Likewise.
2022-12-06 11:24:12 +00:00
Tom de Vries
8db40179f0 [gdb/testsuite] Fix test names in gdb.base/longjmp.exp
When running test-case gdb.base/longjmp.exp, we have:
...
PASS: gdb.base/longjmp.exp: next over setjmp (1)
  ...
PASS: gdb.base/longjmp.exp: next over setjmp (2)
...

The trailing " (1)" and " (2)" are interpreted as comments rather than parts
of the test name, and therefore this is a duplicate, which is currently not
detected by our duplicate detection mechanism (PR testsuite/29772).

Fix the duplicate by using with_test_prefix.

Tested on x86_64-linux.
2022-12-06 12:01:46 +01:00
Tom de Vries
6e41445bb0 [gdb/testsuite] Make gdb.base/longjmp.exp FAIL more stable across archs
When running test-case gdb.base/longjmp.exp on x86_64-linux, the master
longjmp breakpoint is set using probes and the test-case passes:
...
(gdb) PASS: gdb.base/longjmp.exp: next to longjmp (1)
next^M
0x00000000004005cc      49        if (setjmp (env) == 0) /* patt1 */^M
(gdb) PASS: gdb.base/longjmp.exp: next over longjmp(1)
next^M
56            resumes++;^M
(gdb) PASS: gdb.base/longjmp.exp: next into else block (1)
...

However, if I disable
create_longjmp_master_breakpoint_probe, we have instead:
...
(gdb) PASS: gdb.base/longjmp.exp: next to longjmp (1)
next^M
56            resumes++;^M
(gdb) FAIL: gdb.base/longjmp.exp: next over longjmp(1)
...

At first glance, the failure mode doesn't look too bad: we stop
a few insns later than the passing scenario.

For contrast, if we do the same on powerpc64le, the failure mode is:
...
(gdb) PASS: gdb.base/longjmp.exp: next to longjmp (1)
next^M
^M
Breakpoint 3, main () at longjmp.c:59^M
59        i = 1; /* miss_step_1 */^M
(gdb) FAIL: gdb.base/longjmp.exp: next over longjmp(1)
...
Here we only stop because of running into the safety net breakpoint at
miss_step_1.

So, how does this happen on x86_64?  Let's look at the code:
...
4005c7: e8 94 fe ff ff    call 400460 <_setjmp@plt>
4005cc: 85 c0             test %eax,%eax
4005ce: 75 1e             jne  4005ee <main+0x3b>
4005d0: 8b 05 8e 0a 20 00 mov  0x200a8e(%rip),%eax # 601064 <longjmps>
4005d6: 83 c0 01          add  $0x1,%eax
4005d9: 89 05 85 0a 20 00 mov  %eax,0x200a85(%rip) # 601064 <longjmps>
4005df: be 01 00 00 00    mov  $0x1,%esi
4005e4: bf 80 10 60 00    mov  $0x601080,%edi
4005e9: e8 82 fe ff ff    call 400470 <longjmp@plt>
4005ee: 8b 05 74 0a 20 00 mov  0x200a74(%rip),%eax # 601068 <resumes>
...
The next over the longjmp call at 4005e9 is supposed to stop at the longjmp
target at 4005cc, but instead we stop at 4005ee, where we have the step-resume
breakpoint inserted by the next.  In other words, we accidentally "return"
from the longjmp call to the insn immediately after it (even though
a longjmp is a noreturn function).

Try to avoid this accident and make the failure mode on x86_64 the same as on
powerpc64le, by switching the then and else branch.

Tested on x86_64-linux.
2022-12-06 12:01:46 +01:00
Xiao Zeng
c8ea5e409b gdb/riscv: correct dwarf to gdb register number mapping
According to the riscv psabi, the mapping relationship between the
DWARF registers and the machine registers is as follows:

  DWARF Number | Register Name | Description
  0 - 31       | x0 - x31      | Integer Registers
  32 - 63      | f0 - f31      | Floating-point Registers

This is not modelled quite right in riscv_dwarf_reg_to_regnum, the
DWARF register numbers 31 and 63 are not handled correctly due to a
use of '<' instead of '<='.  This commit fixes this issue.
2022-12-06 10:18:19 +00:00
Haochen Jiang
40849d84cb x86: Remove unnecessary vex.w check for xh_mode in disassembler
For all the xh_mode usage in table, they are all using %XH, which will
print "{bad}" while EVEX.W=1. This makes this vex.w check unnecessary.

opcodes/ChangeLog:

	* i386-dis.c (OP_E_memory): Remove vex.w check for xh_mode.
2022-12-06 15:49:40 +08:00
Alan Modra
da16cc96f3 Get rid of SEC_ELF_COMPRESS
This flag also isn't needed, except for some sanity checks which we
can omit.

	* elf.c (elf_fake_sections): Don't set SEC_ELF_COMPRESS for
	compressed debug sections, just leave sh_name as -1.
	(assign_file_positions_for_non_load_sections),
	(assign_file_positions_except_relocs): Decide whether a section
	needs compressing and thus should not have its file offset set
	by looking at sh_name.
	(_bfd_elf_assign_file_positions_for_non_load): Similarly decide
	which sections need compressing.
	* elflink.c (bfd_elf_final_link): Don't test SEC_ELF_COMPRESS.
	* merge.c (_bfd_write_merged_section): Likewise.
	* section.c (SEC_ELF_COMPRESS): Don't define.
	(SEC_ELF_PURECODE): Renumber.
	* bfd-in2.h: Regenerate.
2022-12-06 15:08:31 +10:30
Alan Modra
7b5f66a118 Get rid of SEC_ELF_RENAME
SEC_ELF_RENAME is a flag used to effect section name changes when
compressing/decompressing zlib-gnu debug sections.  This can be
accomplished more directly in one of the objcopy specific bfd
functions.  Renaming for ld input is simplified too.  Ld input object
files always have BFD_DECOMPRESS set.

bfd/
	* compress.c (bfd_convert_section_size): Rename to..
	(bfd_convert_section_setup): ..this.  Handle objcopy renaming
	of compressed/decompressed debug sections.
	* elf.c (_bfd_elf_make_section_from_shdr): Only rename zdebug
	input for linker.
	(elf_fake_sections): Don't handle renaming of debug sections for
	objcopy here.
	* section.c (SEC_ELF_RENAME): Delete.
	* bfd-in2.h: Regenerate.
binutils/
	* objcopy.c (setup_section): Call bfd_convert_section_setup.
	Don't call bfd_convert_section_size.
2022-12-06 14:40:10 +10:30
Alan Modra
89dbeac746 Compression header enum
Define an enum instead of using ELFCOMPRESS_ZLIB and ELFCOMPRESS_ZSTD
in bfd and binutils, and move some functions from bfd.c to compress.c.
When looking at the COFF/PE debug compression support, I wondered
about extending it to support zstd.  I likely won't do that, but
the compression header ch_type field isn't just ELF specific if these
headers are to be used in COFF/PE too.

bfd/
	* bfd.c (bfd_update_compression_header),
	(bfd_check_compression_header, bfd_get_compression_header_size),
	(bfd_convert_section_size, bfd_convert_section_contents): Move to..
	* compress.c: ..here.
	(enum compression_type): New.  Use it throughout file.
	* elf.c (_bfd_elf_make_section_from_shdr): Replace uses of
	ELFCOMPRESS_ZLIB and ELFCOMPRESS_ZSTD with ch_compress_zlib and
	ch_compress_zstd.
	* bfd-in2.h: Regenerate.
binutils/
	* readelf.c (process_section_headers, dump_section_as_strings),
	(dump_section_as_bytes, load_specific_debug_section): Replace
	uses of ELFCOMPRESS_ZLIB and ELFCOMPRESS_ZSTD with
	ch_compress_zlib and ch_compress_zstd.
2022-12-06 12:11:28 +10:30
mengqinggang
8b4d46dfdf LoongArch: Fix dynamic reloc not generated bug in some cases.
bfd/ChangeLog:

	* elfnn-loongarch.c (loongarch_elf_relocate_section): Likewise.
2022-12-06 08:48:57 +08:00
Alan Modra
5830876a0c PR29855, ch_type in bfd_init_section_decompress_status can be uninitialized
PR 29855
	* compress.c (bfd_init_section_decompress_status): Set ch_type
	to zero for zlib-gnu case.
2022-12-06 10:31:50 +10:30
GDB Administrator
60d2606411 Automatic date update in version.in 2022-12-06 00:00:38 +00:00
Simon Marchi
7154e78635 gdb/linux-nat: add ptid parameter to linux_xfer_siginfo
Make the inferior_ptid bubble up to linux_nat_target::xfer_partial.

Change-Id: I62dbc5734c26648bb465f449c2003c73751cd812
2022-12-05 16:38:45 -05:00
Simon Marchi
d29ea32868 gdb/linux-nat: use l linux_nat_get_siginfo in linux_xfer_siginfo
I noticed we could reduce duplication a bit here.

Change-Id: If24e54d1dac71b46f7c1f68a18a073d4c084b644
2022-12-05 16:38:45 -05:00
Simon Marchi
7cc662bcb7 gdb/linux-nat: check ptrace return value in linux_nat_get_siginfo
Not a big deal, but it seems strange to check errno instead of the
ptrace return value to know whether it succeeded.

Change-Id: If0a6d0280ab0e5ecb077e546af0d6fe489c5b9fd
2022-12-05 16:38:45 -05:00
Simon Marchi
8aa1556f2e gdb/linux-nat: don't memset siginfo on failure in linux_nat_get_siginfo
No caller cares about the value of *SIGINFO on failure.  It's also
documented in the function doc that *SIGINFO is uninitialized (I
understand "untouched") on failure.

Change-Id: I5ef38a5f58e3635e109b919ddf6f827f38f1225a
2022-12-05 16:38:45 -05:00
Simon Marchi
ef632b4bf8 gdb/linux-nat: bool-ify linux_nat_get_siginfo
Change return type to bool.

Change-Id: I1bf0360bfdd1b5994cd0f96c268d806f96fe51a4
2022-12-05 16:38:45 -05:00
Simon Marchi
0acd1110b6 gdb/linux-nat: use get_ptrace_pid in two spots
No behavior change expected.

Change-Id: Ifaa64ecd619483646b024fd7c62e571e92a8eedb
2022-12-05 16:38:45 -05:00
Simon Marchi
30add7ee24 gdb/testsuite: remove perror calls when failing to run
I noticed that when running these two tests in sequence:

    Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.ada/arrayptr.exp ...
    ERROR: GDB process no longer exists
    ERROR: Couldn't run foo-all
    Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.ada/assign_1.exp ...

The results in gdb.sum are:

    Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.ada/arrayptr.exp ...
    PASS: gdb.ada/arrayptr.exp: scenario=all: compilation foo.adb
    ERROR: GDB process no longer exists
    UNRESOLVED: gdb.ada/arrayptr.exp: scenario=all: gdb_breakpoint: set breakpoint at foo.adb:40 (eof)
    ERROR: Couldn't run foo-all
    Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.ada/assign_1.exp ...
    UNRESOLVED: gdb.ada/assign_1.exp: changing the language to ada
    PASS: gdb.ada/assign_1.exp: set convenience variable $xxx to 1

The UNRESOLVED for arrayptr.exp is fine, as GDB crashes in that test,
while trying to run to main.  However, the UNRESOLVED in assign_1.exp
doesn't make sense, GDB behaves as expected in that test:

    (gdb) set lang ada^M
    (gdb) UNRESOLVED: gdb.ada/assign_1.exp: changing the language to ada
    print $xxx := 1^M
    $1 = 1^M
    (gdb) PASS: gdb.ada/assign_1.exp: set convenience variable $xxx to 1

The problem is that arrayptr.exp calls perror when failing to run to
main, then returns.  perror makes it so that the next test (as in
pass/fail) will be recorded as UNRESOLVED.  However, here, the next test
(as in pass/fail) is in the next test (as in .exp).  Hence the spurious
UNRESOLVED in assign_1.exp.

These perror when failing to run to X are not really useful, especially
since runto records a FAIL on error, by default.  Remove all the
perrors on runto failure I could find.

When there wasn't one already, add a return statement when failing to
run, to avoid running the test of the test unnecessarily.

I thought of adding a check ran between test (in gdb_finish
probably) where we would emit a warning if errcnt > 0, meaning a test
quit and left a perror "active".  However, reading that variable would
poke into the DejaGNU internals, not sure it's a good idea.

Change-Id: I2203df6d06e199540b36f56470d1c5f1dc988f7b
2022-12-05 16:38:24 -05:00
Luis Machado
09a5d200e6 Add missing newline to gdbarch_tdep debugging output
The missing newline causes testsuite issues because the gdb prompt gets output
to an unexpected location.
2022-12-05 17:16:34 +00:00
Nick Clifton
3bf5bf547a Prevent an illegal memory access when comparing the prefix of a section name regexp.
PR 29849
	* ldlang.c (spec_match): Check that there is sufficient length in
	the target name to match the spec's prefix.
2022-12-05 14:57:17 +00:00
Martin Liska
76a2bcc6b8 testsuite: support mold linker
Mold linker demotes symbols like main to be local and the patch
adjusts expected output from nm.

Moreover, simplify the regex patterns.
2022-12-05 15:52:51 +01:00
Thiago Jung Bauermann
adc48a4926 gdbarch.py: Fix indentation in the generated set_gdbarch_* definitions
Use as many tabs as possible for indentation and pad with spaces to keep
the argument aligned to the opening parenthesis in the line above.

Co-developed-by: Simon Marchi <simon.marchi@efficios.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-12-05 13:52:10 +00:00
Thiago Jung Bauermann
53e03d92a6 gdbarch.py: Fix indentation in the generated gdbarch_dump function
Use tab for the first eight spaces of indentation, and align the gdb_printf
arguments to the open parenthesis of the function call.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-12-05 13:51:48 +00:00
Thiago Jung Bauermann
63b999f80b gdb: Update my email address in MAINTAINERS 2022-12-05 13:50:37 +00:00
Jan Beulich
6fdb723799 gas: add Dwarf line number test for .macro expansions
Before fiddling with the code let's put in place a test covering what
PR/gas 16908 aimed at.
2022-12-05 13:52:55 +01:00
Jan Beulich
c62e507e84 gas: squash (some) .linefile from listings
Not so long ago we started to insert these artificially when expanding
certain macro-like constructs; zap them as cluttering what actually
results from user input.
2022-12-05 13:51:24 +01:00
Jan Beulich
fde7a8e4b0 gas: avoid inserting extra newline in buffer_and_nest()
In "-alm" listings I've noticed an odd blank line following the inserted
.linefile one. This results from the explicit NL inserted being
redundant with the one left in place from the original input line by all
respective callers. Note that we need to compensate for the removed line
by bumping the directive argument (which in turn is decremented again in
s_linefile() before calling new_logical_line_flags(), and I have to
confess that when putting together the original change I was a little
puzzled by the imbalance of increments/decrements, but then I forgot to
actually go look for the cause).

While there also switch to sb_add_string() instead of effectively open-
coding it to some degree.
2022-12-05 13:50:27 +01:00
Jan Beulich
07aeb917c4 Arm: .noinit and .persistent are not supported for Linux targets
Respective tests being run means guaranteed failures.
2022-12-05 13:50:07 +01:00
Nick Clifton
942fa4fb32 Fix an illegal memory access when parsing a corrupt VMS Alpha file.
PR 29848
	* vms-alpha.c (parse_module): Fix potential out of bounds memory
	access.
2022-12-05 11:11:44 +00:00
Andrew Burgess
ecfbeec8d0 libopcodes/mips: add support for disassembler styling
This commit adds disassembler styling support for MIPS.  After this
commit objdump and GDB will style disassembler output.

This is a pretty straight forward change, we switch to use the
disassemble_info::fprintf_styled_func callback, and pass an
appropriate style through as needed.  No additional tricks were
needed (compared to say i386, or ARM).

Tested by running all of the objdump commands used by the gas
testsuite and manually inspecting the styled output, everything looks
reasonable, though I'm not a MIPS expert, so it is possible that I've
missed some corner cases.  Worst case though is that something will be
styled incorrectly, the actual content should be unchanged.

All the gas, ld, and binutils tests still pass for me.
2022-12-05 10:05:45 +00:00
Andrew Burgess
2438b771ee opcodes/mips: use .word/.short for undefined instructions
While working on disassembler styling for MIPS, I noticed that
undefined instructions are printed by the disassembler as raw number
with no assembler directive prefix (e.g. without .word or .short).

I think adding something like .word, or .short, helps to make it
clearer the size of the value that is being displayed, and is inline
with what many of the other libopcode disassemblers do.

In this commit I've added the .word and .short directives, and updated
all the tests that I spotted that failed as a result.
2022-12-05 10:05:45 +00:00
Alan Modra
47afa56ee2 Re: Renaming .debug to .zdebug and vice versa
* compress.c (bfd_debug_name_to_zdebug): Fix C++ compile error.
	(bfd_zdebug_name_to_debug): Likewise.
	* bfd-in2.h: Regenerate.
2022-12-05 15:15:15 +10:30
GDB Administrator
125b7ff73a Automatic date update in version.in 2022-12-05 00:00:28 +00:00
Alan Modra
3d3af4ba39 PR29846, segmentation fault in objdump.c compare_symbols
Fixes a fuzzed object file problem where plt relocs were manipulated
in such a way that two synthetic symbols were generated at the same
plt location.  Won't occur in real object files.

	PR 29846
	PR 20337
	* objdump.c (compare_symbols): Test symbol flags to exclude
	section and synthetic symbols before attempting to check flavour.
2022-12-04 22:32:20 +10:30
Alan Modra
2fa250529b COFF compressed debug support
Since commit 4bea06d73c COFF support for compressed debug sections
has been broken due to the "flags" variable not getting SEC_HAS_CONTENTS.

	* coffgen.c (make_a_section_from_file): Correct section flags
	handling.  Delete extraneous condition.  Update error messages
	to be the same as in elf.c.
2022-12-04 12:54:16 +10:30
Alan Modra
13917d936e Renaming .debug to .zdebug and vice versa
Move a couple of elf.c functions to compress.c.

	* compress.c (bfd_debug_name_to_zdebug): New inline function.
	(bfd_zdebug_name_to_debug): Likewise.
	* elf.c (convert_debug_to_zdebug, convert_zdebug_to_debug): Delete.
	(_bfd_elf_make_section_from_shdr, elf_fake_sections),
	(_bfd_elf_assign_file_positions_for_non_load): Adjust to suit.
	* coffgen.c (make_a_section_from_file): Use new inlines here.
2022-12-04 12:51:46 +10:30
GDB Administrator
13556f4057 Automatic date update in version.in 2022-12-04 00:00:31 +00:00
H.J. Lu
fb699bafb5 Revert "ld: Add .note.GNU-stack to ld-plugin/dummy.s"
This reverts commit 44e59b5a7d.

It works only for ELF targets.
2022-12-03 10:43:29 -08:00
H.J. Lu
44e59b5a7d ld: Add .note.GNU-stack to ld-plugin/dummy.s
* testsuite/ld-plugin/dummy.s: Add .note.GNU-stack.
2022-12-03 09:41:31 -08:00
H.J. Lu
859aa2c86d x86: Allow 16-bit register source for LAR and LSL
Since LAR and LSL only access 16 bits of the source operand, regardless
of operand size, allow 16-bit register source for LAR and LSL, and always
disassemble LAR and LSL with 16-bit source operand.

gas/

	PR gas/29844
	* testsuite/gas/i386/i386.s: Add tests for LAR and LSL.
	* testsuite/gas/i386/x86_64.s: Likewise.
	* testsuite/gas/i386/intelbad.s: Remove "lar/lsl eax, ax".
	* testsuite/gas/i386/i386-intel.d: Updated.
	* testsuite/gas/i386/i386.d: Likewise.
	* testsuite/gas/i386/intel-intel.d: Likewise.
	* testsuite/gas/i386/intel.d: Likewise.
	* testsuite/gas/i386/intelbad.l: Likewise.
	* testsuite/gas/i386/x86_64-intel.d: Likewise.
	* testsuite/gas/i386/x86_64.d: Likewise.

opcodes/

	PR gas/29844
	* i386-dis.c (MOD_0F02): Removed.
	(MOD_0F03): Likewise.
	(dis386_twobyte): Restore larS and lslS.
	(mod_table): Remove MOD_0F02 and MOD_0F03.
	* i386-opc.tbl: Allow 16-bit register source for LAR and LSL.
	* i386-tbl.h: Regenerated.
2022-12-03 08:55:40 -08:00
GDB Administrator
8169d2a118 Automatic date update in version.in 2022-12-03 00:00:51 +00:00
Simon Marchi
f9f593ddb2 gdb/linux-nat: add pid parameter to linux_proc_xfer_memory_partial
Add a pid parameter to linux_proc_xfer_memory_partial, making the
inferior_ptid reference bubble up close to the target_ops::xfer_partial
boundary.  No behavior change expected.

Change-Id: I58171b00ee1bba1ea22efdbb5dcab8b1ab3aac4c
2022-12-02 14:46:38 -05:00
Simon Marchi
f8baaa2b0b gdb: add some debug statements to solib-svr4.c
Add a few debug statements that were useful to me when debugging why the
glibc probes interface wasn't getting used.

Change-Id: Ic20744f9fc80a90f196896b0829949411620c540
2022-12-02 14:40:24 -05:00
Simon Marchi
e26d0dab10 gdb: merge solib-frv aix-solib debug options into "set/show debug solib"
solib implementations are typically used one at a time.  So it will be
rare that you will want to enable debug for one solib kind, and
absolutely want to keep the others disabled.  To make things simpler,
instead of adding separate variables / macros / commands for each solib
implementation, merge the existing ones (frv and aix) into a unified
"set/show debug solib", with the solib_debug_printf macro.

Change-Id: I6e18bbc7401724f37ae66681badb079d75ecf7fa
2022-12-02 14:40:24 -05:00
Nick Clifton
ac57bf5547 Add Jan Beulich as an x86_64 maintainer. 2022-12-02 10:08:39 +00:00
Jan Beulich
05909f2341 x86: drop most OPERAND_TYPE_* (and rework the rest)
With the general use of C99 there's no need anymore to have i386-gen
produce these. For more frequently used ones introduce local #define-s,
while others are simply spelled out directly. While doing this move
some static constants into more narrow scopes.

Note that as a "side effect" this corrects type_names[]'es imm8s entry.
2022-12-02 09:54:09 +01:00
Jan Beulich
4473201422 x86: simplify and slightly correct XCHG vs NOP checking
For one, because of CheckRegSize, there's no need to check the size of
both (register) operands. And then in process_suffix() check opcode
space rather than the (potentially ambiguous) extension opcode.
2022-12-02 09:53:33 +01:00
Jan Beulich
a33ef3c24a x86: also use D for XCHG and TEST
Leverage the C (commutative) attribute to also reduce the number of XCHG
and TEST templates we have. This way the reg <-> r/m (and reg <-> reg for
XCHG) forms can also be folded into a single template each, utilizing D.
2022-12-02 09:53:07 +01:00