Maciej W. Rozycki [Tue, 29 Aug 2023 15:12:58 +0000 (16:12 +0100)]
Revert "Gold/MIPS: Add mips64*/mips64*el triple support"
This reverts commit
5c4cdba100b66e2924a25dad9b12d8e5b84d527f. It was
applied unapproved.
Maciej W. Rozycki [Tue, 29 Aug 2023 15:12:12 +0000 (16:12 +0100)]
Revert "MIPS: Use 64-bit a ABI by default for `mipsisa64*-*-linux*' targets"
This reverts commit
025e84f93566c8ced594ef48ddee1dec7e5b4cdd. It was
applied unapproved.
Willgerodt, Felix [Tue, 29 Aug 2023 13:28:04 +0000 (13:28 +0000)]
gdbserver, linux-low: add a couple of nullptr assertions.
This safeguards a couple of places that may theoretically return NULL but
must not in this specific context. These were found by a static analysis tool.
Approved-By: Tom Tromey <tom@tromey.com>
Tsukasa OI [Wed, 30 Aug 2023 01:04:42 +0000 (01:04 +0000)]
RISC-V: Make XVentanaCondOps RV64 only
Although XVentanaCondOps instructions are XLEN-agonistic, Ventana's manual
only defines them only for RV64 (because all Ventana's processors implement
RV64).
This commit limits XVentanaCondOps instructions RV64-only to match the
behavior of the manual and LLVM.
Note that this commit alone will not make XVentanaCondOps extension with
RV32 invalid (it just makes XVentanaCondOps on RV32 empty).
opcodes/ChangeLog:
* riscv-opc.c (riscv_opcodes): Restrict "vt.maskc" and "vt.maskcn"
to XLEN=64.
gas/ChangeLog:
* testsuite/gas/riscv/x-ventana-condops-32.d: New failure test.
* testsuite/gas/riscv/x-ventana-condops-32.l: Likewise.
Alan Modra [Wed, 30 Aug 2023 01:48:01 +0000 (11:18 +0930)]
objdump: Free sorted_syms on error path
* objdump.c (disassemble_data): Free sorted_syms before returning.
Alan Modra [Wed, 30 Aug 2023 01:40:58 +0000 (11:10 +0930)]
binutils/dwarf.c abbrev list leak
* dwarf.c (process_debug_info): Call free_abrev_list on
return paths.
Alan Modra [Wed, 30 Aug 2023 01:15:03 +0000 (10:45 +0930)]
Re: readelf/objdump: Handle DWARF info with mixed types of range section
PR 30791
* dwarf.c (free_debug_information): Free range_versions.
GDB Administrator [Wed, 30 Aug 2023 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Tue, 29 Aug 2023 20:40:36 +0000 (22:40 +0200)]
[gdb/build] Fix C inclusion of nat/x86-cpuid.h
When running test-case gdb.arch/i386-avx512.exp, I run into:
...
gdb compile failed, In file included from gdb.arch/i386-avx512.c:20:0:
src/gdb/nat/x86-cpuid.h: In function 'x86_cpuid_count':
src/gdb/nat/x86-cpuid.h:63:16: error: \
'nullptr' undeclared (first use in this function)
if (__eax == nullptr)
^~~~~~~
src/gdb/nat/x86-cpuid.h:63:16: note: each \
undeclared identifier is reported only once for each function it appears in
=== gdb Summary ===
# of untested testcases 1
...
This is due to commit
e85aad4ae76 ("nat/x86-cpuid.h: Add x86_cpuid_count
wrapper around __get_cpuid_count"), which introduced the nullptr check.
The header file gdb/nat/x86-cpuid.h is a file that is included in the build
and compiled as a C++ file, but also in the testsuite and compiled as a C
file.
Fix this by replacing nullptr with (void *)0.
Tested on x86_64-linux.
Co-Authored-By: Kevin Buettner <kevinb@redhat.com>
Approved-by: Kevin Buettner <kevinb@redhat.com>
Tom Tromey [Tue, 29 Aug 2023 15:18:42 +0000 (09:18 -0600)]
More renames in array_operation::evaluate
array_operation::evaluate has variables named "tem2" and "tem3". This
patch replaces one with a better name, and entirely removes the other.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Tue, 29 Aug 2023 15:14:01 +0000 (09:14 -0600)]
Remove "highbound" parameter from value_array
value_array requires the passed-in bounds to match the length of the
array_view it is given. This patch removes the redundant "highbound"
parameter.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Mon, 28 Aug 2023 18:52:54 +0000 (12:52 -0600)]
Remove another redundant variable from array_operation::evaluate
This removes yet another redundant variable from
array_operation::evaluate -- only one index is needed.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Mon, 28 Aug 2023 18:43:35 +0000 (12:43 -0600)]
Remove redundant variable from array_operation::evaluate
In array_operation::evaluate, 'idx' and 'tem' are redundant in one
branch. This patch merges them, using the clearer name.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Mon, 28 Aug 2023 19:39:33 +0000 (13:39 -0600)]
Hoist array bounds check in array_operation::evaluate
This hoists the array bounds check in array_operation::evaluate to
before the loop.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Mon, 28 Aug 2023 18:42:51 +0000 (12:42 -0600)]
Declare 'tem' in loop header in array_operation::evaluate
This changes array_operation::evaluate to declare the 'tem' variable
in the loop header, rather than at the top of the function. This is
cleaner and easier to reason about. I also changed 'nargs' to be
'const'.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Mon, 28 Aug 2023 18:40:35 +0000 (12:40 -0600)]
Use gdb::array_view for value_array
This changes value_array to accept an array view. I also replaced an
alloca with a std::vector in array_operation::evaluate. This function
can work on any size of array, so it seems bad to use alloca.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Tue, 29 Aug 2023 16:19:02 +0000 (12:19 -0400)]
gdb/testsuite: recognize one more unsupported instruction in gdb.reverse/step-precsave.exp
When running this test on a processor that supports AVX512 (AMD EPYC
9634) on Debian 12 bookwork (system compiler is gcc 12.2.0), I see:
continue^M
Continuing.^M
Process record does not support instruction bound.^M
Process record does not support instruction 0x62 at address 0x7ffff7f49b40.^M
Process record: failed to record execution log.^M
^M
Program stopped.^M
0x00007ffff7f49b40 in ?? () from /lib/x86_64-linux-gnu/libc.so.6^M
(gdb) FAIL: gdb.reverse/step-precsave.exp: run to end of main
The instruction at this address is:
0x00007ffff7f49b40: 62 e2 7d 48 7a c6 vpbroadcastb %esi,%zmm16
This seems like an AVX512 instruction (given the use of zmm16). Match
this byte value in order to produce a KFAIL.
Change-Id: I1d20357fa538ba60b9c537160acf511a37d751ee
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30807
Approved-By: Tom Tromey <tom@tromey.com>
Tom de Vries [Tue, 29 Aug 2023 15:27:19 +0000 (17:27 +0200)]
[gdb/testsuite] Require have_compile_flag -mavx512f in gdb.arch/i386-avx512.exp
When running test-case gdb.arch/i386-avx512.exp with gcc 4.8.4, I run into:
...
Running gdb.arch/i386-avx512.exp ...
gdb compile failed, gcc: error: unrecognized command line option '-mavx512f'
...
Fix this by requiring have_compile_flag -mavx512f.
Tested on x86_64-linux.
Tom de Vries [Tue, 29 Aug 2023 15:27:19 +0000 (17:27 +0200)]
[gdb/testsuite] Require gcc >= 5 in gdb.linespec/cpls-abi-tag.exp
When running test-case gdb.linespec/cpls-abi-tag.exp with gcc 4.8.4, we run
into:
...
cpls-abi-tag.cc:71:26: error: ‘abi_tag’ attribute applied to non-function ‘s’
ABI3 test_abi_tag_struct s;
^
...
The test-case is supported starting gcc 5.
Fix this by requiring gcc >= 5, if a gcc compiler is used.
Tested on x86_64-linux.
Tom de Vries [Tue, 29 Aug 2023 15:27:19 +0000 (17:27 +0200)]
[gdb/testsuite] Handle some test-cases with older compiler
When running test-case gdb.mi/print-simple-values.exp with gcc 4.8.4, I run
into a compilation failure due to the test-case requiring c++11 and the
compiler defaulting to less than that.
Fix this by compiling with -std=c++11.
Likewise in a few other test-cases.
Tested on x86_64-linux.
Tom de Vries [Tue, 29 Aug 2023 15:27:19 +0000 (17:27 +0200)]
[gdb/testsuite] Fix false negative in have_host_locale
In test-case gdb.tui/pr30056.exp we check for:
...
require {have_host_locale C.UTF-8}
...
The "C.UTF-8" is normalized by have_host_locale to "c.utf8", before trying to
find it in the list returned by host_locales.
On my development platform, "locale -a" lists C.utf8, which is normalized to
"c.utf8" by host_locales, so there's a match and have_host_locale returns true.
On another platform however, "locale -a" lists C.UTF-8, which is normalized to
"c.utf-8" by host_locales, so there's no match and have_host_locale returns false.
Fix this by also dropping the dash in host_locales.
Tested on x86_64-linux.
Nicolas Boulenguez [Tue, 29 Aug 2023 15:04:47 +0000 (16:04 +0100)]
readelf: typos in user messages
Tom Tromey [Mon, 28 Aug 2023 20:03:31 +0000 (14:03 -0600)]
Default getpkt 'forever' parameter to 'false'
This patch changes remote.c so that the getpkt 'forever' parameter now
defaults to 'false' and fixes up all the callers.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Tom Tromey [Mon, 28 Aug 2023 16:25:57 +0000 (10:25 -0600)]
Unify getpkt and getpkt_or_notif_sane
getpkt and getpkt_or_notif_sane are just wrappers for
getpkt_or_notif_sane_1. This patch adds the is_notif parameter to
getpkt, with a suitable default, and removes the wrappers.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Tom Tromey [Mon, 28 Aug 2023 16:24:32 +0000 (10:24 -0600)]
Use bool in getpkt
This changes getpkt and related functions to use bool rather than int.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Tom Tromey [Mon, 28 Aug 2023 16:17:32 +0000 (10:17 -0600)]
Remove expecting_notif parameter from getpkt_or_notif_sane_1
For getpkt_or_notif_sane_1, expecting_notif is redundant, because it
always reflects whether the is_notif parameter is non-NULL. This
patch removes the redundant parameter.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Tom Tromey [Mon, 28 Aug 2023 16:14:54 +0000 (10:14 -0600)]
Remove getpkt_sane
I noticed that getpkt is just a wrapper around getpk_sane, so this
patch unifies the two of them.
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Tom de Vries [Tue, 29 Aug 2023 09:02:08 +0000 (11:02 +0200)]
[gdb/testsuite] Check for sys/random.h in gdb.reverse/getrandom.exp
When running test-case gdb.reverse/getrandom.exp on a system with eglibc 2.19,
we run into:
...
gdb compile failed, gdb.reverse/getrandom.c:18:24: fatal error: \
sys/random.h: No such file or directory
#include <sys/random.h>
^
compilation terminated.
=== gdb Summary ===
# of untested testcases 1
...
and:
...
UNTESTED: gdb.reverse/getrandom.exp: failed to prepare
...
Fix this by testing for the presence of the header, such that we have instead:
...
UNSUPPORTED: gdb.reverse/getrandom.exp: require failed: \
have_system_header sys/random.h
...
Tested on x86_64-linux and i686-linux.
GDB Administrator [Tue, 29 Aug 2023 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Mon, 28 Aug 2023 21:42:11 +0000 (23:42 +0200)]
[gdb/testsuite] Improve xfail in gdb.cp/nsusing.exp
In test-case gdb.cp/nsusing.exp I came across these xfails without PRMS
mentioned:
...
XFAIL: gdb.cp/nsusing.exp: print x, before using statement
XFAIL: gdb.cp/nsusing.exp: print x, only using M
...
Add the missing PRMS, such that we have:
...
XFAIL: gdb.cp/nsusing.exp: print x, before using statement (PRMS gcc/108716)
XFAIL: gdb.cp/nsusing.exp: print x, only using M (PRMS gcc/108716)
...
and limit the xfail to unfixed versions.
The PR is fixed starting gcc 13, but it has been backported to release
branches stretching back to gcc 10. For simplicity we just stick to testing
for the major version and ignore the backported fixes.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
gdbserver: Fix style of struct declarations in i387-fp.cc
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
gdbserver: Simplify handling of ZMM registers.
- Reuse num_xmm_registers directly for the count of ZMM0-15 registers
as is already done for the YMM registers for AVX rather than using
a new variable that is always the same.
- Replace 3 identical variables for the count of upper ZMM16-31
registers with a single variable. Make use of this to merge
various loops working on the ZMM XSAVE region so that all of the
handling for the various sub-registers in this region are always
handled in a single loop.
- While here, fix some bugs in i387_cache_to_xsave where if
X86_XSTATE_ZMM was set on i386 (e.g. a 32-bit process on a 64-bit
kernel), the -1 register nums would wrap around and store the value
of GPRs in the XSAVE area. This should be harmless, but is
definitely odd. Instead, check num_zmm_high_registers directly when
checking X86_XSTATE_ZMM and skip the ZMM region handling entirely if
the register count is 0.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
x86: Remove X86_XSTATE_SIZE and related constants.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Aleksandar Paunovic [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
gdbserver: Use x86_xstate_layout to parse the XSAVE extended state area.
Replace the extended state area fields of i387_xsave with methods which
return an offset into the XSAVE buffer.
The two changed functions are called within all tests which runs
gdbserver.
Signed-off-by: Aleksandar Paunovic <aleksandar.paunovic@intel.com>
Co-authored-by: John Baldwin <jhb@FreeBSD.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Aleksandar Paunovic [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
gdbserver: Refactor the legacy region within the xsave struct
Legacy fields of the XSAVE area are already defined within fx_save
struct. Use class inheritance to remove code duplication.
The two changed functions are called within all tests which run
gdbserver.
Signed-off-by: Aleksandar Paunovic <aleksandar.paunovic@intel.com>
Co-authored-by: John Baldwin <jhb@FreeBSD.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
gdbserver: Add a function to set the XSAVE mask and size.
Make x86_xcr0 private to i387-fp.cc and use i387_set_xsave_mask to set
the value instead. Add a static global instance of x86_xsave_layout
and initialize it in the new function as well to be used in a future
commit to parse XSAVE extended state regions.
Update the Linux port to use this function rather than setting
x86_xcr0 directly. In the case that XML is not supported, don't
bother setting x86_xcr0 to the default value but just omit the call to
i387_set_xsave_mask as i387-fp.cc defaults to the SSE case used for
non-XML.
In addition, use x86_xsave_length to determine the size of the XSAVE
register set via CPUID.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
gdb: Use x86_xstate_layout to parse the XSAVE extended state area.
All of the tables describing the offsets of individual registers for
XSAVE state components now hold relative offsets rather than absolute
offsets. Some tables (those for MPX registers and ZMMH registers) had
to be split into separate tables as they held entries that spanned
multiple state components.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
gdb: Support XSAVE layouts for the current host in the Linux x86 targets.
Note that this uses the CPUID instruction to determine the total size
of the XSAVE register set. If there is a way to fetch the register set
size using ptrace that would probably be better.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
gdb: Update x86 Linux architectures to support XSAVE layouts.
Refactor i386_linux_core_read_xcr0 to fetch and return a corresponding
x86_xsave_layout as well as xcr0 using the size of an existing
NT_X86_XSTATE core dump to determine the offsets via
i387_guess_xsave_layout. Use this to add an implementation of
gdbarch_core_xfer_x86_xsave_layout.
Use tdep->xsave_layout.sizeof_xsave as the size of the XSTATE register
set.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
gdb: Support XSAVE layouts for the current host in the FreeBSD x86 targets.
Use the CPUID instruction to fetch the offsets of supported state
components.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
gdb: Update x86 FreeBSD architectures to support XSAVE layouts.
Refactor i386fbsd_core_read_xcr0 to fetch and return a corresponding
x86_xsave_layout as well as xcr0 using the size of an existing
NT_X86_XSTATE core dump to determine the offsets via
i387_guess_xsave_layout. Use this to add an implementation of
gdbarch_core_xfer_x86_xsave_layout.
Use tdep->xsave_layout.sizeof_xsave as the size of the XSTATE register
set and only fetch/store the register set if this size is non-zero.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
x86 nat: Add helper functions to save the XSAVE layout for the host.
x86_xsave_length returns the total length of the XSAVE state area
standard format as queried from CPUID.
x86_fetch_xsave_layout uses CPUID to query the offsets of XSAVE
extended regions from the running host. The total length of the XSAVE
state area can either be supplied by the caller if known (e.g. from
FreeBSD's PT_GETXSTATEINFO) or it can be queried from the running host
using x86_xsave_length.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
nat/x86-cpuid.h: Add x86_cpuid_count wrapper around __get_cpuid_count.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
core: Support fetching x86 XSAVE layout from architectures.
Add gdbarch_core_read_x86_xsave_layout to fetch the x86 XSAVE layout
structure from a core file.
Current OS's do not export the offsets of XSAVE state components in
core dumps, so provide an i387_guess_xsave_layout helper function to
set offsets based on known combinations of XCR0 masks and total state
sizes. Eventually when core dumps do contain this information this
function should only be used as a fall back for older core dumps.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
gdb: Store an x86_xsave_layout in i386_gdbarch_tdep.
This structure is fetched from the current target in i386_gdbarch_init
via a new "fetch_x86_xsave_layout" target method.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
John Baldwin [Mon, 28 Aug 2023 21:18:19 +0000 (14:18 -0700)]
x86: Add an x86_xsave_layout structure to handle variable XSAVE layouts.
The standard layout of the XSAVE extended state area consists of three
regions. The first 512 bytes (legacy region) match the layout of the
FXSAVE instruction including floating point registers, MMX registers,
and SSE registers. The next 64 bytes (XSAVE header) contains a header
with a fixed layout. The final region (extended region) contains zero
or more optional state components. Examples of these include the
upper 128 bits of YMM registers for AVX.
These optional state components generally have an
architecturally-fixed size, but they are not assigned architectural
offsets in the extended region. Instead, processors provide
additional CPUID leafs describing the size and offset of each
component in the "standard" layout for a given CPU. (There is also a
"compact" format which uses an alternate layout, but existing OS's
currently export the "standard" layout when exporting XSAVE data via
ptrace() and core dumps.)
To date, GDB has assumed the layout used on current Intel processors
for state components in the extended region and hardcoded those
offsets in the tables in i387-tdep.c and i387-fp.cc. However, this
fails on recent AMD processors which use a different layout.
Specifically, AMD Zen3 and later processors do not leave space for the
MPX register set in between the AVX and AVX512 register sets.
To rectify this, add an x86_xsave_layout structure which contains the
total size of the XSAVE extended state area as well as the offset of
each known optional state component.
Subsequent commits will modify XSAVE parsing in both gdb and gdbserver
to use x86_xsave_layout.
Co-authored-by: Aleksandar Paunovic <aleksandar.paunovic@intel.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Mon, 28 Aug 2023 16:35:32 +0000 (10:35 -0600)]
Use sect_offset_str in cooked_index::dump
Mark Wielaard pointed out that cooked_index::dump uses PRIx64, and
Andreas Schwab pointed out that gdb already has sect_offset_str. This
patch applies both these observations.
Mark Wielaard [Mon, 28 Aug 2023 14:30:14 +0000 (16:30 +0200)]
Use hex_string in gdb/coffread.c instead of PRIxPTR
The getsymname function uses PRIxPTR to print and uintptr_t value in
an error message. Use hex_string instead.
Approved-By: Tom Tromey <tom@tromey.com>
Tom de Vries [Mon, 28 Aug 2023 14:27:58 +0000 (16:27 +0200)]
[gdb/symtab] Handle self-reference in inherit_abstract_dies
Building gdb with gcc 7.5.0 and -flto -O2 -flto-partition=one generates a
self-referencing DIE:
...
<2><91dace>: Abbrev Number: 405 (DW_TAG_label)
<91dad0> DW_AT_abstract_origin: <0x91dace>
...
When encountering the self-reference DIE in inherit_abstract_dies we loop
following the abstract origin, effectively hanging gdb.
Fix this by handling self-referencing DIEs in the loop in
inherit_abstract_dies.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
PR symtab/30799
https://sourceware.org/bugzilla/show_bug.cgi?id=30799
Alan Modra [Mon, 28 Aug 2023 11:37:52 +0000 (21:07 +0930)]
COFF swap_aux_in
A low level function like coff_swap_aux_in really has no business
concatenating multiple auxents for the old PE multi-aux scheme of
handling long file names. In doing so, it assumes multiple internal
auxent buffers are available, which they are not in most calls to
bfd_coff_swap_aux_in, both inside BFD and outside, eg. GDB. Buffer
overflow fun. Concatenating multiple auxents belongs at a higher
level.
This required some changes to coff_get_normalized_symtab, which now
uses the external auxents to access the concatenated file name.
(Internal auxents are larger than the x_fname array, so the pieces of
the file name are not adjacent as they are in the external auxents.)
* coffswap.h (coff_swap_aux_in): Do not write more than one
internal auxent.
* coffcode.h (coff_bigobj_swap_aux_in): Likewise.
* coffgen.c (coff_get_normalized_symtab): Normalize strings
after swapping in each symbol so that external auxents are
available. Use external auxents for multi-aux long file
names. Formatting. Wrap long lines. Remove excess parens
and unnecessary casts. Don't zalloc when only the string
terminator needs zeroing, and memcpy rather than strncpy.
Delete unnecessary sanity check with unsigned _n_offset.
Return with failure if debug section can't be read, to avoid
trying to read it multiple times. Correct sanity check
against debug section size.
Alan Modra [Mon, 28 Aug 2023 11:23:02 +0000 (20:53 +0930)]
Re: comdat_hash memory leaks
I missed another field that needs freeing. Also, oss-fuzz found a
case with a C_FILE sym using multiple auxents for a long file name
which overflowed the single auxent buffer. I'm going to fix that
problem in swap_aux_in too, but we may as well avoid it here too,
saving unnecessary work.
* coffcode.h (comdat_delf): Free comdat_name.
(fill_comdat_hash): Only look at symbols with one auxent.
Tom de Vries [Mon, 28 Aug 2023 11:46:36 +0000 (13:46 +0200)]
[gdb/testsuite] Add xfail in gdb.cp/subtypes.exp
When running test-case gdb.cp/subtypes.exp with gcc 4.8.4, we run into:
...
FAIL: gdb.cp/subtypes.exp: ptype main::Foo
FAIL: gdb.cp/subtypes.exp: ptype main::Bar
FAIL: gdb.cp/subtypes.exp: ptype main::Baz
FAIL: gdb.cp/subtypes.exp: ptype foobar<int>::Foo
FAIL: gdb.cp/subtypes.exp: ptype foobar<int>::Bar
FAIL: gdb.cp/subtypes.exp: ptype foobar<int>::Baz
FAIL: gdb.cp/subtypes.exp: ptype foobar<char>::Foo
FAIL: gdb.cp/subtypes.exp: ptype foobar<char>::Bar
FAIL: gdb.cp/subtypes.exp: ptype foobar<char>::Baz
...
The problem is gcc PR debug/55541, which generates a superfluous
DW_TAG_lexical_block.
Add a corresponding xfail.
Tested on x86_64-linux.
Tom de Vries [Mon, 28 Aug 2023 11:46:36 +0000 (13:46 +0200)]
[gdb/testsuite] Refactor gdb.cp/subtypes.exp
Make test-case gdb.cp/subtypes.exp less repetitive by using foreach.
Tested on x86_64-linux.
Tom de Vries [Mon, 28 Aug 2023 11:46:36 +0000 (13:46 +0200)]
[gdb/testsuite] Handle gdb.cp/*.exp with older compiler
When running test-cases gdb.cp/*.exp with gcc 4.8.4, I run into compilation
failures due to the test-cases requiring c++11 and the compiler defaulting
to less than that.
Fix this by compiling with -std=c++11.
This exposes two FAILs in gdb/testsuite/gdb.cp/empty-enum.exp due to
gcc PR debug/16063, so xfail those.
Also require have_compile_flag -std=c++17 in gdb.cp/constexpr-field.exp to
prevent compilation failure.
Tested on x86_64-linux.
YunQiang Su [Sun, 20 Aug 2023 17:14:57 +0000 (01:14 +0800)]
MIPS: Use 64-bit a ABI by default for `mipsisa64*-*-linux*' targets
Following the arrangement in GCC select a 64-bit ABI by default, either
n32 or n64, rather than o32 for `mipsisa64*-*-linux*' targets, just as
with the corresponding `mips64*-*-linux*' targets.
YunQiang Su [Mon, 28 Aug 2023 03:33:03 +0000 (23:33 -0400)]
Gold/MIPS: Add mips64*/mips64*el triple support
Use targ_size=64 and targ_extra_size=32
YunQiang Su [Mon, 28 Aug 2023 03:27:00 +0000 (23:27 -0400)]
Gold/MIPS: Add targ_extra_size=64 for mips32 triples
So we can enable 64bit ELF support for MIPS32 toolchain.
YunQiang Su [Sun, 20 Aug 2023 14:58:37 +0000 (22:58 +0800)]
Gold/MIPS: Drop mips*le/mips*el* triple pattern
Only mips*el triples are supported by binutils. The mips*le
or mips*el* may cause some problem with other components of
binutils, since they will consider them as big endian.
YunQiang Su [Mon, 28 Aug 2023 01:46:21 +0000 (21:46 -0400)]
Gold/MIPS: Use EM_MIPS instead of EM_MIPS_RS3_LE for little endian
EM_MIPS_RS3_LE has been deprecated quite long ago, and in fact
most of current LE ELF files are using EM_MIPS.
This problem didn't make some trouble for us, is due to that
gold is a linker, and all of the inputs to it has right EM values.
YunQiang Su [Mon, 28 Aug 2023 01:38:13 +0000 (21:38 -0400)]
Gold: Add targ_extra_little_endian to configure.ac
This option will be used by architectures which is big endian
by default, while little-endian support is also needed.
Mips(eb) ports are the examples.
GDB Administrator [Mon, 28 Aug 2023 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Sun, 27 Aug 2023 11:47:05 +0000 (21:17 +0930)]
PE dos_message
I was looking at dos_message and wondering why we have H_PUT_32
in _bfd_XXi_only_swap_filehdr_out but no H_GET_32 in pe_bfd_object_p.
On a big-endian machine this would result in scrambling the code and
strings constained in dos_message. Rather than fix the lack of
H_GET_32 in pe_bfd_object_p, I decided it doesn't make sense to store
dos_message internally as an array of ints.
include/
* coff/internal.h (struct internal_extra_pe_filehdr): Make
dos_message a char array.
* coff/msdos.h (struct external_DOS_hdr): Flatten dos_message.
* coff/pe.h (struct external_PEI_filehdr): Likewise.
bfd/
* libcoff-in.h (struct pe_tdata): Make dos_message a char array.
* libcoff.h: Regenerate.
* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): memcpy dos_message
to output.
* peicode.h (pe_mkobject): Don't memset already zeroed pe_opthdr.
Tidy allocation of tdata.pe_obj_data. Set up dos_message from..
(default_dos_message): ..this. New static array.
Alan Modra [Sun, 27 Aug 2023 03:49:01 +0000 (13:19 +0930)]
comdat_hash memory leaks
Entries added to the hash table with bfd_malloc ought to be freed when
the hash table is deleted. This patch adds the necessary del_f to the
htab_create call, and delays creating the table until an
IMAGE_SCN_LNK_COMDAT symbol is read.
* peicode.h (pe_mkobject): Move comdat_hash creation..
(htab_hash_flags, htab_eq_flags): ..and these support functions..
* coffcode.h (handle_COMDAT): ..to here, renaming support to
(comdat_hashf, comdat_eqf): ..this and adding..
(comdat_delf): ..this new function.
Alan Modra [Sun, 27 Aug 2023 03:27:16 +0000 (12:57 +0930)]
Confusion in coff_object_cleanup
A bfd_cleanup function needs to run when only tdata is correct for the
bfd. The xvec may have changed during bfd_check_format and thus the
flavour may be incorrect. The format won't have changed but checking
is superfluous. (In contrast to _bfd_free_cached_info or
_close_and_cleanup where we do need to check things.)
Not getting this correct leaked comdat_hash.
Also, pe_ILF_cleanup ought to call coff_object_cleanup as do all PE
files.
* coffgen.c (coff_object_cleanup): Don't check bfd flavour or
format.
* peicode.h (pe_ILF_cleanup): Call coff_object_cleanup.
Alan Modra [Sun, 27 Aug 2023 03:21:24 +0000 (12:51 +0930)]
sanity check n_numaux
Sanity check aux entries used by PE to extend a C_FILE name. See
coffswap.h:coff_swap_aux_in. The existing check only catered for
n_numaux == 1.
* coffcode.h (fill_comdat_hash): Properly sanity check n_numaux.
Formatting.
(handle_COMDAT): Formatting.
Alan Modra [Sat, 26 Aug 2023 12:38:50 +0000 (22:08 +0930)]
Re: ld STRINGIFY
Oops there was a reference to the old name.
* emultempl/aix.em: Use stringify.sed.
GDB Administrator [Sun, 27 Aug 2023 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Tue, 22 Aug 2023 17:32:43 +0000 (11:32 -0600)]
Simplify definition of GUILE
This patch sets GUILE to just plain 'guile'.
In the distant ("devo") past, the top-level build did support building
Guile in-tree. However, I don't think this really works any more.
For one thing, there are no build dependencies on it, so there's no
guarantee it would actually be built before the uses.
This patch also removes the use of "-s" as an option to cgen scheme
scripts. With my latest patch upstream, this is no longer needed.
After the upstream changes, either Guile 2 or Guile 3 will work, with
or without the compiler enabled.
2023-08-24 Tom Tromey <tom@tromey.com>
* cgen.sh: Don't pass "-s" to cgen.
* Makefile.in: Rebuild.
* Makefile.am (GUILE): Simplify.
Tom Tromey [Tue, 1 Aug 2023 21:09:49 +0000 (15:09 -0600)]
Use get_frame_address_in_block in print_frame
The author of 'mold' pointed out that with a certain shared library,
gdb would fail to find the shared library's name in 'bt'.
The function in question appeared at the end of the .so's .text
segment and ended with a call to 'abort'.
This turned out to be a classic case of calling get_frame_pc when
get_frame_address_in_block is needed -- the former will be off-by-one
for purposes of finding the enclosing function or shared library.
The included test fails without the patch on my system. However, I
imagine it can't be assumed to reliably fail. Nevertheless it seemed
worth doing.
Regression tested on x86-64 Fedora 38.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29074
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
Alan Modra [Sat, 26 Aug 2023 01:47:47 +0000 (11:17 +0930)]
opcodes i386 and ia64 gen file warnings
i386: warning: format ‘%u’ expects argument of type ‘unsigned int’,
but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
ia64: warning: ignoring return value of ‘fgets’
* i386-gen.c (process_i386_opcodes): Correct format string.
* ia64-gen.c (load_insn_classes, load_depfile): Don't ignore
fgets return value.
Alan Modra [Sat, 26 Aug 2023 01:06:54 +0000 (10:36 +0930)]
ld STRINGIFY
Delete support for old compilers that don't support string
concatentation.
* Makefile.am (stringify.sed): Delete rule.
(GEN_DEPENDS, DISTCLEANFILES): Adjust.
* configure.ac (STRINGIFY): Delete.
* emultempl/beos.em: Use stringify.sed from srcdir.
* emultempl/elf.em: Likewise.
* emultempl/generic.em: Likewise.
* emultempl/msp430.em: Likewise.
* emultempl/pdp11.em: Likewise.
* emultempl/pe.em: Likewise.
* emultempl/pep.em: Likewise.
* emultempl/stringify.sed: Renamed from..
* emultempl/astring.sed: ..this.
* emultempl/ostring.sed: Delete.
* Makefile.in: Regenerate.
* configure: Regenerate.
GDB Administrator [Sat, 26 Aug 2023 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Fri, 25 Aug 2023 23:39:13 +0000 (09:09 +0930)]
ld .deps/*.Pc files
This patch gets rid of the individual rules including the .Pc
dependency files made while generating e*.c files, replacing them with
a fancy GNU make pattern include. I've also moved creation of
ldscripts to the makefile since it is possible to run more than one
genscripts at once, resulting in "ldscripts: File exists" messages.
* Makefile.am: Replace individual include of *.Pc dependency
files with one pattern rule.
(.Pc): New dummy rule.
(ldscripts/stamp): New rule.
(GEN_DEPENDS): Add ldscripts/stamp.
(install-data-local): Exclude ldscripts/stamp from install.
* genscripts.sh: Don't make ldscripts dir.
* Makefile.in: Regenerate.
Mark Wielaard [Fri, 25 Aug 2023 21:09:18 +0000 (23:09 +0200)]
Fix gdb/coffread.c build on 32bit architectures
The getsymname function tries to emit an error using %ld for an
uintptr_t argument. Use PRIxPTR instead. Which works on any architecture
for uintptr_t.
Keith Seitz [Wed, 2 Aug 2023 15:35:11 +0000 (08:35 -0700)]
Verify COFF symbol stringtab offset
This patch addresses an issue with malformed/fuzzed debug information that
was recently reported in gdb/30639. That bug specifically deals with
an ASAN issue, but the reproducer provided by the reporter causes a
another failure outside of ASAN:
$ ./gdb --data-directory data-directory -nx -q UAF_2
Reading symbols from /home/keiths/UAF_2...
Fatal signal: Segmentation fault
----- Backtrace -----
0x59a53a gdb_internal_backtrace_1
../../src/gdb/bt-utils.c:122
0x59a5dd _Z22gdb_internal_backtracev
../../src/gdb/bt-utils.c:168
0x786380 handle_fatal_signal
../../src/gdb/event-top.c:889
0x7864ec handle_sigsegv
../../src/gdb/event-top.c:962
0x7ff354c5fb6f ???
0x611f9a process_coff_symbol
../../src/gdb/coffread.c:1556
0x611025 coff_symtab_read
../../src/gdb/coffread.c:1172
0x60f8ff coff_read_minsyms
../../src/gdb/coffread.c:549
0x60fe4b coff_symfile_read
../../src/gdb/coffread.c:698
0xbde0f6 read_symbols
../../src/gdb/symfile.c:772
0xbde7a3 syms_from_objfile_1
../../src/gdb/symfile.c:966
0xbde867 syms_from_objfile
../../src/gdb/symfile.c:983
0xbded42 symbol_file_add_with_addrs
../../src/gdb/symfile.c:1086
0xbdf083 _Z24symbol_file_add_from_bfdRKN3gdb7ref_ptrI3bfd18gdb_bfd_ref_policyEEPKc10enum_flagsI16symfile_add_flagEPSt6vectorI14other_sectionsSaISC_EES8_I12objfile_flagEP7objfile
../../src/gdb/symfile.c:1166
0xbdf0d2 _Z15symbol_file_addPKc10enum_flagsI16symfile_add_flagEPSt6vectorI14other_sectionsSaIS5_EES1_I12objfile_flagE
../../src/gdb/symfile.c:1179
0xbdf197 symbol_file_add_main_1
../../src/gdb/symfile.c:1203
0xbdf13e _Z20symbol_file_add_mainPKc10enum_flagsI16symfile_add_flagE
../../src/gdb/symfile.c:1194
0x90f97f symbol_file_add_main_adapter
../../src/gdb/main.c:549
0x90f895 catch_command_errors
../../src/gdb/main.c:518
0x9109b6 captured_main_1
../../src/gdb/main.c:1203
0x910fc8 captured_main
../../src/gdb/main.c:1310
0x911067 _Z8gdb_mainP18captured_main_args
../../src/gdb/main.c:1339
0x418c71 main
../../src/gdb/gdb.c:39
---------------------
A fatal error internal to GDB has been detected, further
debugging is not possible. GDB will now terminate.
This is a bug, please report it. For instructions, see:
<https://www.gnu.org/software/gdb/bugs/>.
Segmentation fault (core dumped)
The issue here is that the COFF offset for the fuzzed symbol's
name is outside the string table. That is, the offset is greater
than the actual string table size.
coffread.c:getsymname actually contains a FIXME about this, and that's
what I've chosen to address to fix this issue, following what is done
in the DWARF reader:
$ ./gdb --data-directory data-directory -nx -q UAF_2
Reading symbols from /home/keiths/UAF_2...
COFF Error: string table offset (256) outside string table (length 0)
(gdb)
Unfortunately, I haven't any idea how else to test this patch since
COFF is not very common anymore. GCC removed support for it five
years ago with GCC 8.
John Baldwin [Fri, 25 Aug 2023 19:37:52 +0000 (12:37 -0700)]
Update FreeBSD system calls for the upcoming 14.0-RELEASE
This matches the current set of system calls at the start of the
stable/14 branch (commit
29a16ce065dbc28bc9e87c9bfadb08bb58b137e4).
Aditya Vidyadhar Kamath [Fri, 25 Aug 2023 16:30:02 +0000 (11:30 -0500)]
Fix for call feature having 9th function parameter and beyond corrupt values.
In AIX the first eight function parameters are stored from R3 to R10.
If there are more than eight parameters in a function then we store the 9th parameter onwards in the stack.
While doing so, in 64 bit mode the words were not zero extended and was coming like 32 bit mode.
This patch is a fix to the same.
Aditya Vidyadhar Kamath [Fri, 25 Aug 2023 14:12:57 +0000 (09:12 -0500)]
Fix 64 bit red zone frame size in AIX
Jan Beulich [Fri, 25 Aug 2023 12:56:44 +0000 (14:56 +0200)]
bfd: correct relocation handling for objcopy COFF -> ELF
While documented to not be reliable, it is still odd for objcopy to
silently produce bad output when converting COFF/PE object files to ELF
ones. The issue there is that relocation addends all are screwed up by
subtracting the symbol's section offset. In the COFF/PE world, to my
knowledge, section contents stores the addends alone, not the result of
symbol value plus addend. Hence the compensation talked about in a
comment ahead of the sole use site of CALC_ADDEND() may need to account
for the VMA (which is always zero for object files anyway), but not for
the symbol value.
The coff-sh.c adjustment is based upon guessing that behavior there is
the same. Note also how coff-aarch64.c short-circuits CALC_ADDEND()
altogether, which may suggest that a much simpler macro might do for the
COFF_WITH_PE case in the three arch-specific files touched here.
For (at least) Arm/WinCE this actually results in more appropriate
objdump output as well, as can be seen in the one testcase which has its
expectations adjusted (the generated binary doesn't change).
Jan Beulich [Fri, 25 Aug 2023 12:56:07 +0000 (14:56 +0200)]
gas/ELF: widen use of $dump_opts in testsuite
Rather than special-casing rx-*-* for section30, force use of
conventional section names uniformly. By further passing $dump_opts to
a few more tests, a number of xfail-s (and one notarget) can be
eliminated (some of which had wrong justifications in associated
comments anyway). Note that section7 and section15 need to be left
alone: The harness fiddling with section names there didn't help before
and is getting in the way now. For section12b, section16b, and most of
the Dwarf tests nothing changes. Interestingly by passing $dump_opts
the need to xfail section11 for LoongArch and RISC-V also goes away.
Jan Beulich [Fri, 25 Aug 2023 12:55:12 +0000 (14:55 +0200)]
gas/ELF: allow "inheriting" section attributes and type
While --sectname-subst is nice, it isn't enough to e.g. mimic
-f{function,data}-sections in assembly code, when such use is to be
optional (e.g. dependent upon some configuration setting).
Assign meaning to '+' and '-' as section attribute letters, allowing
to inherit the prior section's attributes (and possibly type) along
with adding or removing some. Note that documenting the interaction
with '?' as undefined is a precautionary measure.
While touching the function invocation, stop using |= on the result of
obj_elf_parse_section_letters(): "attr" is firmly zero ahead of the
call.
Alan Modra [Thu, 24 Aug 2023 08:40:17 +0000 (18:10 +0930)]
Use GNU make pattern rule in ld Makefile
Use the pattern rule in a comment from commit
77ac17b8453f.
* Makefile.am (run-genscripts): Delete. Use pattern rule
e%.c instead.
* Makefile.in: Regenerate.
Alan Modra [Fri, 25 Aug 2023 06:10:10 +0000 (15:40 +0930)]
som: buffer overflow writing strings
Code in som_write_symbol_strings neglected to allow for padding, which
can result in a buffer overflow. It also used xrealloc, which we're
not supposed to use in libbfd because libbfd isn't supposed to call
exit. Also a realloc is perhaps not a good idea when none of the
buffer contents are needed, so replace with free, bfd_malloc. There
were three copies of the string handling code, so rather than fix them
all I've extracted them to a function. This necessitated making one
of the fields in struct som_symbol unsigned.
* som.c (add_string): New function.
(som_write_space_strings, som_write_symbol_strings): Use it.
* som.h (som_symbol_type <stringtab_offset>): Make unsigned.
Alan Modra [Thu, 24 Aug 2023 23:42:18 +0000 (09:12 +0930)]
PR30794, PowerPC gold: internal error in add_output_section_to_load
Caused by commit
5a97377e5513, specifically this code added to
Target_powerpc::do_relax
+ if (parameters->options().output_is_position_independent())
+ this->rela_dyn_size_
+ = this->rela_dyn_section(layout)->current_data_size();
The problem here is that if .rela.dyn isn't already created then the
call to rela_dyn_section creates it, and as this comment in
Target_powerpc::do_finalize_sections says:
// Annoyingly, we need to make these sections now whether or
// not we need them. If we delay until do_relax then we
// need to mess with the relaxation machinery checkpointing.
We can't be creating sections in do_relax.
PR 30794
* powerpc.cc (Target_powerpc::do_relax): Only set rela_dyn_size_
for size == 64, and assert that rela_dyn_ already exists.
Tidy code setting plt_thread_safe, which also only needs to be
set when size == 64 for ELFv1.
GDB Administrator [Fri, 25 Aug 2023 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in
Lancelot SIX [Wed, 26 Jul 2023 10:30:56 +0000 (11:30 +0100)]
gdb/solib-rocm: Detect SO for unsupported AMDGPU device
It is possible to debug a process which uses unsupported AMDGPU devices.
In such scenario, we can still use librocm-dbgapi.so to attach to the
process and complete the runtime activation sequence.
However, when listing shared objects loaded on the AMDGPU devices, we
might list SOs loaded on the unsupported devices. If such SO is
seen, one of two things can happen.
First, if the arch of this device is unknown to BFD,
'gdbarch_find_by_info (gdbarch_info info)' will return the gdbarch
matching default_bfd_arch. As a result,
rocm_solib_relocate_section_addresses will delegate the relocation
operation to svr4_so_ops.relocate_section_addresses, but this makes no
sense: this code object was not loaded by the system loader.
The second case is if BFD knows the micro-architecture of the device,
but dbgapi does not support it. In such case, gdbarch_info_fill will
successfully identify an amdgcn architecture (bfd_arch_amdgcn). From
there, gdbarch_find_by_info calls amdgpu_gdbarch_init which will fail to
query arch specific details from dbgapi and subsequently fail to
initialize the gdbarch object. As a result, gdbarch_find_by_info
returns nullptr, which will down the line cause some "gdb_assert
(gdbarch != nullptr)" assertion failures.
This patch proposes to add a check in rocm_solib_bfd_open to ensure that
the architecture associated with the code object to open is fully
supported by both BFD and amd-dbgapi, and error-out otherwise.
Change-Id: Ica97ab7cba45e4944b77d3080c54c1038aaeda54
Approved-By: Pedro Alves <pedro@palves.net>
Tom de Vries [Thu, 24 Aug 2023 11:40:38 +0000 (13:40 +0200)]
[gdb/build] Return gdb::array_view in thread_info_to_thread_handle
In remote_target::thread_info_to_thread_handle we return a copy:
...
gdb::byte_vector
remote_target::thread_info_to_thread_handle (struct thread_info *tp)
{
remote_thread_info *priv = get_remote_thread_info (tp);
return priv->thread_handle;
}
...
Fix this by returning a gdb::array_view instead:
...
gdb::array_view<const gdb_byte>
remote_target::thread_info_to_thread_handle (struct thread_info *tp)
...
Tested on x86_64-linux.
This fixes the build when building with -std=c++20.
Approved-By: Pedro Alves <pedro@palves.net>
Paul Iannetta [Thu, 24 Aug 2023 08:39:14 +0000 (10:39 +0200)]
kvx: fix kvx_reassemble_bundle index 8 out of bounds
opcodes/
* kvx-dis.c (print_insn_kvx): Change the loop condition so that
wordcount is always less than KVXMAXBUNDLEWORDS.
(decode_prologue_epilogue_bundle): Likewise.
Guinevere Larsen [Mon, 24 Jul 2023 08:32:21 +0000 (10:32 +0200)]
gdb/testsuite: Multiple improvements for gdb.reverse/insn-reverse.exp
This commits tackles 2 problems in the test
gdb.reverse/insn-reverse.exp. They are, broadly: flawed logic when an
unexpected error occurs, and badly formed asm expressions.
For the first, what happens is that if the inferior stops progressing
for some reason, the test will emit an UNSUPPORTED and continue testing
by reversing from the current location and checking all registers for
every instruction. However, due to how the outputs are indexed in the
test, this early exit will cause most of the subsequent tests to be
de-synced and will emit many unrelated failures.
This commit changes the UNSUPPORTED for a FAIL, since the test has in
fact failed to record the execution of the whole function, and
decrements the recorded instruction count by one so that the indexes are
in sync once more.
At the time of committing, this reduces the amount of failures when
testing with clang-15 from around 150 to 2, and correctly identifies
where the issue lies.
The second problem is in how the asm statements in the *-x86.c file
are written. As an example, let's examine the following line:
__asm__ volatile ("rdrand %%ebp;" : "=r" (number));
This statement says that number is being used as the output variable,
but is not indicating which registers were clobbered so that the
compiler is able to properly output. GCC decides to just not save
anything, whereas clang assumes that the output is in %rax, and writes
it to the variable. This hid the problem that any compiler is not good
at dealing with asm statements that change the rbp register. It can be
seen more explicitly by informing gcc that rbp has been clobbered like
so:
__asm__ volatile ("rdrand %%ebp;" : "=r" (number) : : "%ebp");
This statement gets compiled into the following assembly:
rdrandl %ebp
movl %eax, -4(%rbp)
Which is clearly using the incorrect rbp to find the memory location of
the variable. Since the test only exercises GDB's ability to record the
register changes, this commit removes the output to memory.
Finally, correctly informing the compiler of clobbered registers
makes gcc throw an error that the rsp is no longer usable at the end of
the function. To avoid that, this commit compresses the 3 asm statements
that would save, change and reset registers into a single asm statement.
Approved-By: Tom Tromey <tom@tromey.com>
Guinevere Larsen [Fri, 21 Jul 2023 09:10:42 +0000 (11:10 +0200)]
gdb/testsuite: fix testing gdb.reverse/step-reverse.exp with clang
When testing using reverse-stepi to fully step through a function, the
code checks for an infinite loop by seeing if we land on the line that
contains the return statement multiple times. This assumption only works
if there is only one instruction associated with that line, which is how
GCC handles line information, but other compilers may handle it differently.
Clang-15, for instance, associates 6. Because of this, the inferior used
to get seriously out of sync with the test expectations, and result in 13
spurious failures. The same issue occurs with gdb.reverse/step-precsave.exp.
This commit changes the test so that we check for PC instead of line
number. The test still only happens when the same line is detected, to
simplify the resulting log. With this change, no new failures are
emitted when using clang.
Approved-By: Tom Tromey <tom@tromey.com>
Guinevere Larsen [Fri, 21 Jul 2023 11:45:12 +0000 (13:45 +0200)]
gdb/testsuite: fix gdb.reverse/solib-*.exp tests when using clang
The tests gdb.reverse/solib-precsave.exp and solib-reverse.exp have the
assumption that line tables will have an entry for the closing } in a
function. Not all compiles do this, one example being clang. To fix
this, this commit changes the function in shr2.c to have multiple lines,
and the test to accept either line as a correct step location.
To properly re-sync the inferiors, the function repeat_cmd_until had to
be slightly changed to work with empty "current locations", so that we
are able to step through multiple lines.
This also changes the annotations used to determine the breakpoint
locations in solib-reverse.c, adding a simple variable assignment right
before the return statement. This way GDB will not set a breakpoint in
the closing } line.
Approved-By: Tom Tromey <tom@tromey.com>
Guinevere Larsen [Thu, 20 Jul 2023 09:47:50 +0000 (11:47 +0200)]
gdb/testsuite: Fix many errors in gdb.reverse with clang
Clang does not add line information for lines that only contain a
closing } in functions. Many tests in the gdb.reverse folder set a
breakpoint in that line, but don't seem to use information available
after the return statement is executed, so this commit moves the
breakpoint to the previous line, where the return statement is.
Approved-By: Tom Tromey <tom@tromey.com>
Alan Modra [Thu, 24 Aug 2023 05:05:20 +0000 (14:35 +0930)]
kvx: workaround gcc-4.5 bug
kvx-dis.c:1078:10: error: missing initializer
kvx-dis.c:1078:10: error: (near initialization for 'dec.nb_ops')
* kvx-dis.c (print_insn_kvx): Init dec with memset.
(decode_prologue_epilogue_bundle): Likewise.
Oleg Tolmatcev [Sun, 18 Jun 2023 17:35:38 +0000 (19:35 +0200)]
optimize handle_COMDAT
Signed-off-by: Oleg Tolmatcev <oleg.tolmatcev@gmail.com>
Alan Modra [Thu, 24 Aug 2023 01:22:19 +0000 (10:52 +0930)]
nds32, sh, kvx: DT_JMPREL/DT_PLTRELSZ
As commit
fa4f2d46f9 did for x86, there a few other targets that
wrongly use the output section rather than the dynamic section for
DT_JMPREL and others.
* elfnn-kvx.c (elfNN_kvx_finish_dynamic_sections): Use input
section for DT_JMPREL.
* elf32-sh.c (sh_elf_finish_dynamic_sections): Use input
section for DT_JMPREL and DT_PLTRELSZ.
* elf32-nds32.c (nds32_elf_finish_dynamic_sections): Likewise,
and for DT_PLTGOT and when adjusting DT_RELA.
Stafford Horne [Sat, 19 Aug 2023 07:30:54 +0000 (08:30 +0100)]
sim: or1k: Eliminate dangerous RWX load segments
This fixes test failures caused by the new linker warning which report:
./ld/ld-new: warning: load.S.x has a LOAD segment with RWX permissions
Fix this by splitting the linker MEMORY into ram and rom to avoid
generating RWX sections. This required tests to be adjusted to fix
issues with the move. Namely:
- fpu tests: were incorrectly using l.ori with ha(anchor) which now
that we pushed the anchor up in memory it exposes the bug. Update
to used the correct l.movhi instruction instead.
- adrp test: the test reports ram offset addresses, now that we have
moved memory layout around a bit I adjusted the test output. Some
padding is added before pi to show that the actual address of pi and
the adrp page offset are not the same.
Bug: https://sourceware.org/PR29957
Paul Iannetta [Wed, 23 Aug 2023 14:39:23 +0000 (16:39 +0200)]
kvx: bfd/config.bfd & ld/configure.tgt
bfd/
* config.bfd: Remove kvx_elf64_vec from targ_selvecs as it is
already in targ_defvec.
ld/
* configure.tgt: Split long line.
Paul Iannetta [Wed, 23 Aug 2023 14:39:22 +0000 (16:39 +0200)]
kvx: use {u,}int32_t and {u,}int64_t
gas/
* config/kvx-parse.c (promote_token): Use {u,}int32_t and
{u,}int64_t.
(get_token_class): Likewise.
* config/tc-kvx.c (insert_operand): Likewise.
* config/tc-kvx.h (struct token_s): Likewise.
(struct token_list): Likewise.
opcodes/
* kvx-dis.c (struct decoded_insn): Use {u,}int32_t and
{u,}int64_t.
(decode_insn): Likewise.
(print_insn_kvx): Likewise.
(decode_prologue_epilogue_bundle): Likewise.
* kvx-dis.h (struct kvx_prologue_epilogue_insn): Likewise.
Paul Iannetta [Wed, 23 Aug 2023 14:39:21 +0000 (16:39 +0200)]
kvx: fix handling of STB_GNU_UNIQUE symbols
When processing a STB_GNU_UNIQUE symbol we did not update has_gnu_osabi
correctly.
* config/tc-kvx.c (kvx_end): Do not write to e_ident.
(kvx_type): Properly handle STB_GNU_UNIQUE symbols.
Paul Iannetta [Wed, 23 Aug 2023 14:39:20 +0000 (16:39 +0200)]
kvx: remove kvx_elf64_linux_vec
* configure.ac: Remove kvx_elf64_linux_vec.
* configure: Regenerate.