Commit Graph

112382 Commits

Author SHA1 Message Date
Martin Liska
8ad93045ed ld, gold: remove support for -z bndplt (MPX prefix)
bfd/ChangeLog:

	* elf-linker-x86.h (struct elf_linker_x86_params): Remove
	bndplt.
	* elf64-x86-64.c (elf_x86_64_scan_relocs): Ignore
        R_X86_64_PLT32_BND.
	(elf_x86_64_relocate_section): Similarly here.
	(elf_x86_64_link_setup_gnu_properties): Ignore bndplt.
	* elfxx-x86.c: Likewise.
	* elfxx-x86.h: Likewise.

gold/ChangeLog:

	* NEWS: Document -z bndplt.
	* options.h (class General_options): Remove bndplt option.
	* x86_64.cc (class Output_data_plt_x86_64_bnd): Remove.
	(Target_x86_64::do_make_data_plt): Do not use
	Output_data_plt_x86_64_bnd.
	(Target_x86_64::Scan::get_reference_flags): Likewise.
	(Target_x86_64::Scan::check_non_pic): Likewise.
	(Target_x86_64::Scan::local): Likewise.
	(Target_x86_64::Scan::global): Likewise.

ld/ChangeLog:

	* NEWS: Document -z bndplt.
	* emulparams/elf_x86_64.sh: Remove bndplt option.
	* ld.texi: Likewise.
	* testsuite/ld-x86-64/x86-64.exp:
	* testsuite/ld-x86-64/bnd-branch-1-now.d: Removed.
	* testsuite/ld-x86-64/bnd-branch-1.d: Removed.
	* testsuite/ld-x86-64/bnd-branch-1.s: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-1-now.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-1.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-1.s: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-2-now.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-2.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-2.s: Removed.
	* testsuite/ld-x86-64/bnd-plt-1-now.d: Removed.
	* testsuite/ld-x86-64/bnd-plt-1.d: Removed.
	* testsuite/ld-x86-64/mpx.exp: Removed.
	* testsuite/ld-x86-64/mpx1.out: Removed.
	* testsuite/ld-x86-64/mpx1a.c: Removed.
	* testsuite/ld-x86-64/mpx1a.rd: Removed.
	* testsuite/ld-x86-64/mpx1b.c: Removed.
	* testsuite/ld-x86-64/mpx1c.c: Removed.
	* testsuite/ld-x86-64/mpx1c.rd: Removed.
	* testsuite/ld-x86-64/mpx2.out: Removed.
	* testsuite/ld-x86-64/mpx2a.c: Removed.
	* testsuite/ld-x86-64/mpx2a.rd: Removed.
	* testsuite/ld-x86-64/mpx2b.c: Removed.
	* testsuite/ld-x86-64/mpx2c.c: Removed.
	* testsuite/ld-x86-64/mpx2c.rd: Removed.
	* testsuite/ld-x86-64/mpx3.dd: Removed.
	* testsuite/ld-x86-64/mpx3a.s: Removed.
	* testsuite/ld-x86-64/mpx3b.s: Removed.
	* testsuite/ld-x86-64/mpx3n.dd: Removed.
	* testsuite/ld-x86-64/mpx4.dd: Removed.
	* testsuite/ld-x86-64/mpx4a.s: Removed.
	* testsuite/ld-x86-64/mpx4b.s: Removed.
	* testsuite/ld-x86-64/mpx4n.dd: Removed.
	* testsuite/ld-x86-64/pr20800a.S: Removed.
	* testsuite/ld-x86-64/pr20800b.S: Removed.
	* testsuite/ld-x86-64/pr21038a-now.d: Removed.
	* testsuite/ld-x86-64/pr21038a.d: Removed.
	* testsuite/ld-x86-64/pr21038a.s: Removed.
	* testsuite/ld-x86-64/pr21038b-now.d: Removed.
	* testsuite/ld-x86-64/pr21038b.d: Removed.
	* testsuite/ld-x86-64/pr21038b.s: Removed.
	* testsuite/ld-x86-64/pr21038c-now.d: Removed.
	* testsuite/ld-x86-64/pr21038c.d: Removed.
	* testsuite/ld-x86-64/pr21038c.s: Removed.
2022-12-14 08:48:13 +01:00
Alan Modra
d0517d6e33 asan: signed integer overflow in display_debug_frames
* dwarf.c (struct Frame_Chunk): Make col_offset an int64_t.
	Adjust all places allocating col_offset and col_type to use
	the size of the array element rather than the size of a type.
	(frame_display_row): Adjust printing of col_offset.
	(display_debug_frames): Factor out multiplication by
	code_factor and data_factor.  Avoid signed overflow.  Use
	64-bit variables.
2022-12-14 13:07:43 +10:30
Alan Modra
bd5efa5930 Don't access freed memory printing objcopy warning
abfd->filename will be freed if bfd_close gets far enough to delete
the bfd.  It's possible to have an error from fclose at this point.

	* objcopy.c (copy_archive): Dup filename before closing bfd for
	potential use in bfd_nonfatal_message.
2022-12-14 13:07:43 +10:30
GDB Administrator
a4b83845de Automatic date update in version.in 2022-12-14 00:04:35 +00:00
Tom Tromey
c88afe9cf5 Fix control-c handling on Windows
As Hannes pointed out, the Windows target-async patches broke C-c
handling there.  Looking into this, I found a few oddities, fixed
here.

First, windows_nat_target::interrupt calls GenerateConsoleCtrlEvent.
I think this event can be ignored by the inferior, so it's not a great
way to interrupt.  Instead, using DebugBreakProcess (or a more
complicated thing for Wow64) seems better.

Second, windows_nat_target did not implement the pass_ctrlc method.
Implementing this lets us remove the special code to call
SetConsoleCtrlHandler and instead integrate into gdb's approach to C-c
handling.  I believe that this should also fix the race that's
described in the comment that's being removed.

Initially, I thought a simpler version of this patch would work.
However, I think what happens is that some other library (I'm not sure
what) calls SetConsoleCtrlHandler while gdb is running, and this
intercepts and handles C-c -- so that the gdb SIGINT handler is not
called.  C-break continues to work, presumably because whatever
handler is installed ignores it.

This patch works around this issue by ensuring that the gdb handler
always comes first.
2022-12-13 12:51:53 -07:00
Tom Tromey
c1dc47f53c Refactor code to check for terminal sharing
This refactors the code to check for terminal sharing.
is_gdb_terminal is exported, and sharing_input_terminal_1 is renamed,
slightly refactored, and moved to posix-hdep.c.  A new
Windows-specific implementation of this function is added to
mingw-hdep.c.

MSDN has a warning about GetConsoleProcessList

    This API is not recommended and does not have a virtual terminal
    equivalent. [...] Applications remoting via cross-platform
    utilities and transports like SSH may not work as expected if
    using this API.

However, we believe this isn't likely to be an issue for gdb.
2022-12-13 12:51:53 -07:00
Tom Tromey
d2f803afd5 Use gdb::optional for sigint_ours
sigint_ours (and sigquit_ours) can be used without being set.  Avoid
this problem by changing them to gdb::optional and checking that they
are in fact set before using the value.
2022-12-13 12:51:53 -07:00
Tom Tromey
12bc5170ee Rename install_sigint_handler
A subsequent patch will introduce a global 'install_sigint_handler'
function, so first rename the static one in extension.c.
2022-12-13 12:51:53 -07:00
Tom de Vries
ea6929aaac [gdb/tdep] Fix s390_linux_nat_target::stopped_by_watchpoint
On s390x-linux, I run into:
...
(gdb) continue^M
Continuing.^M
breakpoint.c:5784: internal-error: bpstat_stop_status_nowatch: \
  Assertion `!target_stopped_by_watchpoint ()' failed.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
FAIL: gdb.threads/watchpoint-fork.exp: parent: singlethreaded: \
  breakpoint after the first fork (GDB internal error)
...

What happens is the follow:
- a watchpoint event triggers
- the event is processed, s390_linux_nat_target::stopped_by_watchpoint is called and
  it returns true, as expected
- the watchpoint event is reported by gdb, and gdb stops
- we issue a continue command
- a fork event triggers
- the event is processed, and during processing that event
  s390_linux_nat_target::stopped_by_watchpoint is called again, and returns
  true
- the assertion fails, because the function is expected to return false

The function s390_linux_nat_target::stopped_by_watchpoint returns true the
second time, because it looks at the exact same data that was looked at when
it was called the first time, and that data hasn't changed.

There's code in the same function that intends to prevent that from happening:
...
      /* Do not report this watchpoint again.  */
      memset (&per_lowcore, 0, sizeof (per_lowcore));
      if (ptrace (PTRACE_POKEUSR_AREA, s390_inferior_tid (), &parea, 0) < 0)
       perror_with_name (_("Couldn't clear watchpoint status"));
...
and that probably used to work for older kernels, but no longer does since
linux kernel commit 5e9a26928f55 ("[S390] ptrace cleanup").

Fix this by copying this:
...
  siginfo_t siginfo;
  if (!linux_nat_get_siginfo (inferior_ptid, &siginfo))
    return false;
  if (siginfo.si_signo != SIGTRAP
      || (siginfo.si_code & 0xffff) != TRAP_HWBKPT)
    return false;
...
from aarch64_linux_nat_target::stopped_data_address and remove the
obsolete watchpoint status clearing code.

Tested on s390x-linux.

Approved-By: Ulrich Weigand <uweigand@de.ibm.com>
2022-12-13 18:41:12 +01:00
H.J. Lu
1bf337caba gold: Remove BND from 64-bit x86-64 IBT PLT
Since MPX support has been removed from x86-64 psABI, remove BND from
64-bit IBT PLT by using 32-bit IBT PLT.

	PR gold/29851
	* x86_64.cc (Output_data_plt_x86_64_ibt<32>::first_plt_entry):
	Renamed to ...
	(Output_data_plt_x86_64_ibt<size>::first_plt_entry): This.
	(Output_data_plt_x86_64_ibt<64>::first_plt_entry): Removed.
	(Output_data_plt_x86_64_ibt<size>::do_fill_first_plt_entry):
	Drop the size == 32 check.
	(Output_data_plt_x86_64_ibt<32>::plt_entry): Renamed to ...
	(Output_data_plt_x86_64_ibt<size>::plt_entry): This.
	(Output_data_plt_x86_64_ibt<64>::plt_entry): Removed.
	(Output_data_plt_x86_64_ibt<32>::aplt_entry): Renamed to ...
	(Output_data_plt_x86_64_ibt<size>::aplt_entry): This.
	(Output_data_plt_x86_64_ibt<64>::aplt_entry): Removed.
	(Output_data_plt_x86_64_ibt<size>::do_fill_plt_entry): Drop the
	size == 32 check.
	(Output_data_plt_x86_64_ibt<size>::fill_aplt_entry): Likewise.
2022-12-13 09:02:36 -08:00
Tom Tromey
41daaea2cc Remove two unnecessary casts
A couple of calls to parse_probe_linespec had an unnecessary cast.  I
suspect this cast was never needed, but once commands were changed to
take a 'const' argument, they became completely obsolete.  Tested by
rebuilding.
2022-12-13 08:58:50 -07:00
Andrew Burgess
dc3fb44540 gdb/testsuite: avoid creating temp file in gdb/testsuite/ directory
After this commit:

  commit 33c1395cf5
  Date:   Fri Nov 11 15:26:46 2022 +0000

      gdb/testsuite: fix gdb.trace/unavailable-dwarf-piece.exp with Clang

The gdb.trace/unavailable-dwarf-piece.exp test script was creating a
temporary file in the build/gdb/testsuite/ directory, instead of in
the expected place in the outputs directory.

Fix this by adding a call to standard_output_file.
2022-12-13 15:37:17 +00:00
Tom de Vries
fa59ab9868 [gdb/testsuite] Fix gdb.python/py-disasm.exp on s390x
On s390x-linux, I run into:
...
(gdb) disassemble test^M
Dump of assembler code for function test:^M
   0x0000000001000638 <+0>:     stg     %r11,88(%r15)^M
   0x000000000100063e <+6>:     lgr     %r11,%r15^M
   0x0000000001000642 <+10>:    nop     0^M
=> 0x0000000001000646 <+14>:    nop     0^M
   0x000000000100064a <+18>:    nop     0^M
   0x000000000100064e <+22>:    lhi     %r1,0^M
   0x0000000001000652 <+26>:    lgfr    %r1,%r1^M
   0x0000000001000656 <+30>:    lgr     %r2,%r1^M
   0x000000000100065a <+34>:    lg      %r11,88(%r11)^M
   0x0000000001000660 <+40>:    br      %r14^M
End of assembler dump.^M
(gdb) FAIL: gdb.python/py-disasm.exp: global_disassembler=: disassemble test
...

The problem is that the test-case expects "nop" but on s390x we have instead
"nop\t0".

Fix this by allowing the insn.

Tested on s390x-linux and x86_64-linux.
2022-12-13 13:06:15 +01:00
Jan Beulich
969b9a3650 gas: re-work line number tracking for macros and their expansions
The PR gas/16908 workaround aimed at uniformly reporting line numbers
to reference macro invocation sites. As mentioned in a comment this may
be desirable for small macros, but often isn't for larger ones. As a
first step improve diagnostics to report both locations, while aiming at
leaving generated debug info unaltered.

Note that macro invocation context is lost for any diagnostics issued
only after all input was processed (or more generally for any use of
as_*_where(), as the functions can't know whether the passed in location
is related to [part of] the present stack of locations). To maintain the
intended workaround behavior for PR gas/16908, a new as_where() is
introduced to "look through" macro invocations, while the existing
as_where() is renamed (and used in only very few places for now). Down
the road as_where() will likely want to return a list of (file,line)
pairs.
2022-12-13 09:11:53 +01:00
Jan Beulich
f2e469cb47 Arm: avoid unhelpful uses of .macro in testsuite
Macros with just a single use site are a little pointless to have, and
even in further cases .irp is more suitable for the purpose. Expand such
inline, avoiding the need to touch the testcases when diagnostics are
changed for code resulting from macro expansion.

While there also make what was "iter_mla" in sp-usage-thumb2-relax cover
smlatt as well, rather than testing smlabt twice.
2022-12-13 09:11:16 +01:00
Tom Tromey
785545988c Fix crash in is_nocall_function
is_nocall_function anticipates only being called for a function or a
method.  However, PR gdb/29871 points out a situation where an unusual
expression -- but one that parses to a valid, if extremely weird,
function call -- breaks this assumption.

This patch changes is_nocall_function to remove this assert and
instead simply return 'false' in this case.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29871
2022-12-12 21:38:01 -07:00
Johnson Sun
d0d41b77c0 Replace gdbpy_should_stop with gdbpy_breakpoint_cond_says_stop
In 2014, the function `gdbpy_should_stop' has been replaced with
`gdbpy_breakpoint_cond_says_stop'

This replaces `gdbpy_should_stop' with `gdbpy_breakpoint_cond_says_stop' in the
comments.

Since `gdbpy_should_stop' has been renamed as noted in `gdb/ChangeLog-2014':

	* python/py-breakpoint.c (gdbpy_breakpoint_cond_says_stop): Renamed
	from gdbpy_should_stop.  Change result type to enum scr_bp_stop.

Change-Id: I0ef3491ce5e057c5e75ef8b569803b30a5838575
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-12-12 21:34:26 -05:00
Alan Modra
c799eddb35 asan: mips_hi16_list segfault in bfd_get_section_limit_octets
static variables like mips_hi16_list are nasty for applications using
bfd.  It is possible when opening and closing bfds with mis-matched
hi/lo relocs to leave a stale section pointer on the list.  That can
cause a segfault if multiple bfds are being processed.

Tidying the list when closing is sufficient to stop this happening
(and fixes small memory leaks).  This patch goes further and moves
mips_hi16_list to where it belongs in the bfd tdata.

	* elf32-mips.c (bfd_elf32_close_and_cleanup(: Define.
	* elf64-mips.c (bfd_elf64_close_and_cleanup): Define.
	* elfn32-mips.c (bfd_elf32_close_and_cleanup(: Define.
	* elfxx-mips.c (struct mips_hi16): Move earlier.
	(mips_hi16_list): Move to..
	(struct mips_elf_obj_tdata): ..here.
	(_bfd_mips_elf_close_and_cleanup): New function.
	(_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_lo16_reloc),
	(_bfd_elf_mips_get_relocated_section_contents): Adjust uses of
	mips_hi16_list.
	* elfxx-mips.h (_bfd_mips_elf_close_and_cleanup): Declare.
2022-12-13 11:31:43 +10:30
GDB Administrator
e0a14c5f56 Automatic date update in version.in 2022-12-13 00:00:37 +00:00
Indu Bhagat
f5b6601dae libctf: remove unnecessary zstd constructs
This patch is essentially a revert of
commit-id: 8818c80cbd
(libctf: Add ZSTD_LIBS to LIBS so that ac_cv_libctf_bfd_elf can be true)

As the specific configure check now uses libtool, this explicit mention of the
dependency $ZSTD_LIBS is not needed anymore.

ChangeLog:

	* libctf/Makefile.in: Regenerated.
	* libctf/aclocal.m4: Likewise.
	* libctf/config.h.in: Likewise.
	* libctf/configure: Likewise.
	* libctf/configure.ac: Remove ZSTD_LIBS from LIBS.  Cleanup
	unused AC_ZSTD.
2022-12-12 10:53:39 -08:00
Indu Bhagat
c6c1fccd8f libctf: remove AC_CONFIG_MACRO_DIR
ACLOCAL_AMFLAGS is being set already.  So using AC_CONFIG_MACRO_DIR is
unnecessary.

ChangeLog:

	* libctf/configure: Regenerated.
	* libctf/configure.ac: remove AC_CONFIG_MACRO_DIR usage.
2022-12-12 09:34:54 -08:00
Indu Bhagat
78eb490c2c libctf: remove unnecessary zlib constructs
This dependency is managed via libtool.  So explicit addition to LDFLAGS
and LIBS is not necessary anymore.

ChangeLog:

	* libctf/configure: Regenerated.
	* libctf/configure.ac: remove zlib from LDFLAGS and LIBS.
2022-12-12 09:34:36 -08:00
Tom de Vries
b99ceddc91 [gdb/testsuite] Fix PR20630 regression test in gdb.base/printcmds.exp
On s390x-linux, I run into:
...
(gdb) print {unsigned char}{65}^M
$749 = 0 '\000'^M
(gdb) FAIL: gdb.base/printcmds.exp: print {unsigned char}{65}
...

In contrast, on x86_64-linux, we have:
...
(gdb) print {unsigned char}{65}^M
$749 = 65 'A'^M
(gdb) PASS: gdb.base/printcmds.exp: print {unsigned char}{65}
...

The first problem here is that the test is supposed to be a regression test
for PR20630, which can be reproduced (for an unfixed gdb) like this:
...
(gdb) p {unsigned char[]}{0x17}
gdbtypes.c:4641: internal-error: copy_type: \
  Assertion `TYPE_OBJFILE_OWNED (type)' failed.
...
but it's not due to insufficient quoting (note the dropped '[]').

That's easy to fix, but after that we have on s390 (big endian):
...
(gdb) print {unsigned char[]}{65}^M
$749 = ""^M
...
and on x86_64 (little endian):
...
(gdb) print {unsigned char[]}{65}^M
$749 = "A"^M
...

Fix this by using 0xffffffff, such that in both cases we have:
...
(gdb) print {unsigned char[]}{0xffffffff}^M
$749 = "\377\377\377\377"^M
...

Tested on x86_64-linux and s390x-linux.
2022-12-12 15:21:33 +01:00
Alan Modra
c8628c770b PR29893, buffer overflow in display_debug_addr
PR 29893
	* dwarf.c (display_debug_addr): Sanity check dwarf5 unit_length
	field.  Don't read past end.
2022-12-13 00:36:08 +10:30
Tom Tromey
67a8c89601 Another Rust operator precedence bug
My earlier patch to fix PR rust/29859 introduced a new operator
precedence bug in the Rust parser.  Assignment operators are
right-associative in Rust.  And, while this doesn't often matter, as
Rust assignments always have the value (), still as a matter of
principle we should get this correct.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29859
2022-12-12 06:42:17 -07:00
Tom de Vries
167f3beb65 [gdb/testsuite] Fix gdb.base/write_mem.exp for big endian
On s390x-linux (big endian), I run into:
...
(gdb) x /xh main^M
0x1000638 <main>:       0x0000^M
(gdb) FAIL: gdb.base/write_mem.exp: x /xh main
...

In contrast, on x86_64-linux (little endian), we have the expected:
...
(gdb) x /xh main^M
0x4004a7 <main>:        0x4242^M
(gdb) PASS: gdb.base/write_mem.exp: x /xh main
...

The problem is that the test-case hard-codes expectations about endiannes by
writing an int-sized value (4 bytes in this case) and then printing only a
halfword by using "/h" (so, two bytes).

If we print 4 bytes, we have for s390x:
...
0x1000638 <main>:       0x00004242^M
...
and for x86_64:
...
0x4004a7 <main>:        0x00004242^M
...

Fix this by removing the "/h".

Tested on x86_64-linux and s390x-linux.
2022-12-12 14:25:58 +01:00
Jan Vrany
b5661ff24f gdb: fix possible use-after-free when executing commands
In principle, `execute_command()` does following:

   struct cmd_list_element *c;
   c = lookup_cmd ( ... );
   ...
   /* If this command has been pre-hooked, run the hook first.  */
   execute_cmd_pre_hook (c);
   ...
   /* ...execute the command `c` ...*/
   ...
   execute_cmd_post_hook (c);

This may lead into use-after-free error.  Imagine the command
being executed is a user-defined Python command that redefines
itself.  In that case, struct `cmd_list_element` pointed to by
`c` is deallocated during its execution so it is no longer valid
when post hook is executed.

To fix this case, this commit looks up the command once again
after it is executed to get pointer to (possibly newly allocated)
`cmd_list_element`.
2022-12-12 13:16:14 +00:00
Jan Beulich
a28fedbc3f x86: further re-work insn/suffix recognition to also cover MOVSX
PR gas/29524

Having templates with a suffix explicitly present has always been
quirky. After prior adjustment all that's left to also eliminate the
anomaly from move-with-sign-extend is to consolidate the insn templates
and to make may_need_pass2() cope (plus extend testsuite coverage).
2022-12-12 14:01:02 +01:00
Jan Beulich
77a19f0e19 x86: drop (now) stray IsString
The need for them on the operand-less string insns has gone away with
the removal of maybe_adjust_templates() and associated logic. Since
i386_index_check() needs adjustment then anyway, take the opportunity
and also simplify it, possible again as a result of said removal (plus
the opcode template adjustments done here).
2022-12-12 13:53:40 +01:00
Jan Beulich
e3669c7f7b x86: move bad-use-of-TLS-reloc check
Having it in match_template() is unhelpful. Neither does looking for the
next template to possibly match make any sense in that case, nor is the
resulting diagnostic making clear what the problem is.

While moving the check, also generalize it to include all SIMD and VEX-
encoded insns. This way an existing conditional can be re-used in
md_assemble(). Note though that this still leaves a lof of insns which
are also wrong to use with these relocations.

Further fold the remaining check (BFD_RELOC_386_GOT32) with the XRELEASE
related one a few lines down. This again allows re-using an existing
conditional.
2022-12-12 13:53:13 +01:00
Jan Beulich
e2b983d47e x86-64: allow HLE store of accumulator to absolute 32-bit address
In commit 1212781b35 ("ix86: allow HLE store of accumulator to
absolute address") I was wrong to exclude 64-bit code. Dropping the
check also leads to better diagnostics in 64-bit code ("MOV", after
all, isn't invalid with "XRELEASE").

While there also limit the amount of further checks done: The operand
type checks that were there were effectively redundant with other ones
anyway, plus it's quite fine to also have "xrelease mov <disp>, %eax"
look for the next MOV template (in fact again also improving
diagnostics).
2022-12-12 13:52:47 +01:00
Jan Beulich
9db83a3277 ix86: don't recognize/derive Q suffix in the common case
Have its use, except where actually legitimate, result in the same "only
supported in 64-bit mode" diagnostic as emitted for other 64-bit only
insns. Also suppress deriving of the suffix in Intel mode except in the
legitimate cases. This in exchange allows dropping the respective code
from match_template().

To maintain reasonable diagnostics (in particular to avoid "`mov' is
only supported in 64-bit mode" on the SIMD forms of MOVQ) we need to
defer parse_insn()'s emitting of errors unrelated to prefix parsing.
Utilize i.error just like match_template() does.

Oddly enough despite gcc's preference towards FILDQ and FIST{,T}Q we
had no testcase whatsoever for these. Therefore such tests are being
added. Note that the removed line in the x86-64-lfence-load testcase
was redundant with the exact same one a few lines up.
2022-12-12 13:52:15 +01:00
Jan Beulich
04784e33fa x86: re-work insn/suffix recognition
Having templates with a suffix explicitly present has always been
quirky. Introduce a 2nd matching pass in case the 1st one couldn't find
a suitable template _and_ didn't itself already need to trim off a
suffix to find a match at all. This requires error reporting adjustments
(albeit luckily fewer than I was afraid might be necessary), as errors
previously reported during matching now need deferring until after the
2nd pass (because, obviously, we must not emit any error if the 2nd pass
succeeds). While also related to PR gas/29524, it was requested that
move-with-sign-extend be left as broken as it always was.

PR gas/29525
Note that with the dropped CMPSD and MOVSD Intel Syntax string insn
templates taking operands, mixed IsString/non-IsString template groups
(with memory operands) cannot occur anymore. With that
maybe_adjust_templates() becomes unnecessary (and is hence being
removed).

PR gas/29526
Note further that while the additions to the intel16 testcase aren't
really proper Intel syntax, we've been permitting all of those except
for the MOVD variant. The test therefore is to avoid re-introducing such
an inconsistency.
2022-12-12 13:51:46 +01:00
Jan Beulich
5317ad2ccc x86: constify parse_insn()'s input
The function doesn't alter its input buffer: Reflect this in its
prototype. To avoid using any kind of cast, simply calculate the update
of "line" from the function's input and output.
2022-12-12 13:50:31 +01:00
Jan Beulich
6825a3bc86 x86: revert disassembler parts of "x86: Allow 16-bit register source for LAR and LSL"
This reverts the disassembler parts of 859aa2c86d ("x86: Allow 16-bit
register source for LAR and LSL"), adjusting testcases as necessary.
That change was itself a partial revert of c9f5b96bda ("x86: correct
handling of LAR and LSL"), without actually saying so. While the earlier
commit was properly agreed upon, the partial revert was not, and hence
should not have been committed. This is even more so that the revert
part of that change wasn't even necessary to address PR gas/29844.
2022-12-12 13:49:56 +01:00
Alan Modra
65cf035b8d PR29892, Field file_table of struct module is uninitialized
PR 29892
	* vms-alphs.c (new_module): Use bfd_zmalloc to alloc file_table.
	(parse_module): Rewrite file_table reallocation code and clear.
2022-12-12 19:25:19 +10:30
Alan Modra
77c225bdeb Lack of bounds checking in vms-alpha.c parse_module
PR 29873
	PR 29874
	PR 29875
	PR 29876
	PR 29877
	PR 29878
	PR 29879
	PR 29880
	PR 29881
	PR 29882
	PR 29883
	PR 29884
	PR 29885
	PR 29886
	PR 29887
	PR 29888
	PR 29889
	PR 29890
	PR 29891
	* vms-alpha.c (parse_module): Make length param bfd_size_type.
	Delete length == -1 checks.  Sanity check record_length.
	Sanity check DST__K_MODBEG, DST__K_RTNBEG, DST__K_RTNEND lengths.
	Sanity check DST__K_SOURCE and DST__K_LINE_NUM elements
	before accessing.
	(build_module_list): Pass dst_section size to parse_module.
2022-12-12 19:25:19 +10:30
Alan Modra
b1f1cefd58 PR29872, uninitialised value in display_debug_lines_decoded dwarf.c:5413
Plus segvs if the C-library doesn't handle printf %s of NULL.

	PR 29872
	* dwarf.c (null_name): New function.
	(process_debug_info): Use it here..
	(display_debug_lines_raw): ..and here..
	(display_debug_lines_decoded): ..and here.  xcalloc directory_table.
	Simplify xcalloc of file_table.
2022-12-12 19:25:19 +10:30
Jan Beulich
af327b04a5 gas/codeview: avoid "shadowing" of glibc function name
While not "index" this time, old enough glibc also has an (unguarded)
declaration of fileno() in stdio.h, which triggers a "shadows a global
declaration" warning with our choice of warning level and with at least
some gcc versions.
2022-12-12 09:49:44 +01:00
Jan Beulich
65f440c8fb x86: generate template sets data at build time
Speed up gas startup by avoiding runtime allocation of the instances of
type "templates". At the same time cut the memory requirement to just
very little over half (not even accounting for any overhead
notes_alloc() may incur) by reusing the "end" slot of a preceding entry
for the "start" slot of the subsequent one.
2022-12-12 08:49:26 +01:00
Jan Beulich
daf15e3e96 x86: drop sentinel from i386_optab[]
Now that the table is local to gas, ARRAY_SIZE() can be used to
determine the end of the table. Re-arrange the processing loop in
md_begin() accordingly, at the same time folding the two calls to
notes_alloc() into just one.
2022-12-12 08:49:00 +01:00
Jan Beulich
313095ba2d x86: add generated tables dependency check to gas
As requested by H.J., just for the sake of people potentially building
in gas/ alone, add a check that the generated files in opcodes/ are
actually up-to-date. Personally I think this should at best be a
warning, but I can see how this may not be easily noticable among other
make output (depending in particular on the verbosity level).
2022-12-12 08:48:25 +01:00
Jan Beulich
27cf5a35ce x86: break gas dependency on libopcodes
gas doesn't use anything from libopcodes anymore - suppress linking in
that library.
2022-12-12 08:47:52 +01:00
Jan Beulich
bc30b54aef x86: remove i386-opc.c
Remove the now empty i386-opc.c. To compensate, tie table generation in
opcodes/ to the building of i386-dis.o, despite the file not really
depending on the generated data.
2022-12-12 08:47:26 +01:00
Jan Beulich
99f0fb12d5 x86: instantiate i386_{op,reg}tab[] in gas instead of in libopcodes
Unlike many other architectures, x86 does not share an opcode table
between assembly and disassembly. Any consumer of libopcodes would only
ever access one of the two. Since gas is the only consumer of the
assembly data, move it there. While doing so mark respective entities
"static" in i386-gen (we may want to do away with i386_regtab_size
altogether).

This also shrinks the number of relocations to be processed for
libopcodes.so by about 30%.
2022-12-12 08:46:47 +01:00
GDB Administrator
b35abeab8d Automatic date update in version.in 2022-12-12 00:00:52 +00:00
Alan Modra
f2f58a399c PR29870, objdump SEGV in display_debug_lines_decoded dwarf.c:5524
DWARF5 directory and file table allow more opportunity for fuzzers
to break things.  There are likely other places in dwarf.c that should
be fixed too.

	PR 29870
	* dwarf.c (display_debug_lines_decoded): Handle NULL file_table
	name entry.
2022-12-11 14:47:57 +10:30
GDB Administrator
85f9067d3a Automatic date update in version.in 2022-12-11 00:00:34 +00:00
Tom de Vries
823b2395e4 [gdb/tdep] Fix larl handling in s390_displaced_step_fixup
On s390x-linux with target board unix/-m31, I run into:
...
(gdb) PASS: gdb.guile/scm-lazy-string.exp: bad length
print ptr^M
$1 = 0x804006b0 <error: Cannot access memory at address 0x804006b0>^M
(gdb) FAIL: gdb.guile/scm-lazy-string.exp: ptr: print ptr
...

A minimal example is:
...
$ gdb -q -batch -ex "set trace-commands on" -x gdb.in
+file scm-lazy-string
+break main
Breakpoint 1 at 0x4005d2: file scm-lazy-string.c, line 23.
+run

Breakpoint 1, main () at scm-lazy-string.c:23
23        const char *ptr = "pointer";
+step
24        const char array[] = "array";
+print ptr
$1 = 0x804006b0 <error: Cannot access memory at address 0x804006b0>
...

If we delete the breakpoint after running to it, we have instead the expected:
...
+delete
+step
24        const char array[] = "array";
+print ptr
$1 = 0x4006b0 "pointer"
...

The problem is in displaced stepping, forced by the presence of the breakpoint,
when stepping over this insn:
...
  0x4005d2 <main+10>      larl    %r1,0x4006b0
...

With normal stepping we have:
...
(gdb) p /x $r1
$2 = 0x3ff004006b0
...
but with displaced stepping we have instead (note the 0x80000000 difference):
...
(gdb) p /x $r1
$1 = 0x3ff804006b0
(gdb)
...

The difference comes from this code in s390_displaced_step_fixup:
...
  /* Handle LOAD ADDRESS RELATIVE LONG.  */
  else if (is_ril (insn, op1_larl, op2_larl, &r1, &i2))
    {
      /* Update PC.  */
      regcache_write_pc (regs, from + insnlen);
      /* Recompute output address in R1.  */
      regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1,
                                      amode | (from + i2 * 2));
    }
...
where the "amode |" adds the 0x80000000.

Fix this by removing the "amode |".

Tested on s390-linux, with native and target board unix/-m31.

Approved-By: Ulrich Weigand <uweigand@de.ibm.com>
2022-12-10 15:40:34 +01:00
GDB Administrator
b813665fd2 Automatic date update in version.in 2022-12-10 00:00:30 +00:00