Nick Clifton [Mon, 2 Oct 2023 15:23:14 +0000 (16:23 +0100)]
Fix memory leak in RiscV assembler.
PR 30861
* config/tc-riscv.c (riscv_insert_uleb128_fixes): Release duplicated memory.
Nick Clifton [Mon, 2 Oct 2023 12:24:05 +0000 (13:24 +0100)]
Use bfd_get_current_time in places where it is suitable
GDB Administrator [Mon, 2 Oct 2023 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 1 Oct 2023 00:00:30 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sat, 30 Sep 2023 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Fri, 15 Sep 2023 23:24:26 +0000 (17:24 -0600)]
Support the NO_COLOR environment variable
I ran across this site:
https://no-color.org/
... which lobbies for tools to recognize the NO_COLOR environment
variable and disable any terminal styling when it is seen.
This patch implements this for gdb.
Regression tested on x86-64 Fedora 38.
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
Neal Frager [Fri, 29 Sep 2023 15:45:46 +0000 (08:45 -0700)]
tc-microblaze.c - int compare for X_add_number.
The range check should be checking for the range
ffffffff80000000..
7fffffff, not
ffffffff70000000.
This patch has been tested for years of AMD Xilinx Yocto
releases as part of the following patch set:
https://github.com/Xilinx/meta-xilinx/tree/master/meta-microblaze/recipes-devtools/binutils/binutils
Signed-off-by: nagaraju <nagaraju.mekala@amd.com>
Signed-off-by: Neal Frager <neal.frager@amd.com>
Signed-off-by: Michael J. Eager <eager@eagercon.com>
Neal Frager [Wed, 27 Sep 2023 12:49:18 +0000 (13:49 +0100)]
bfd: microblaze: Fix bug in TLSTPREL Relocation
Fixed the problem related to the fixup/relocations TLSTPREL.
When the fixup is applied the addend is not added at the correct offset
of the instruction. The offset is hard coded considering its big endian
and it fails for Little endian. This patch allows support for both
big & little-endian compilers.
This patch has been tested for years of AMD Xilinx Yocto
releases as part of the following patch set:
https://github.com/Xilinx/meta-xilinx/tree/master/meta-microblaze/recipes-devtools/binutils/binutils
Signed-off-by: nagaraju <nagaraju.mekala@amd.com>
Signed-off-by: Neal Frager <neal.frager@amd.com>
H.J. Lu [Tue, 1 Nov 2022 18:36:04 +0000 (11:36 -0700)]
x86-64: Add -z mark-plt and -z nomark-plt
The PLT entry in executables and shared libraries contains an indirect
branch, like
jmp *foo@GOTPCREL(%rip)
push $index_foo
jmp .PLT0
or
endbr64
jmp *foo@GOTPCREL(%rip)
NOP padding
which is used to branch to the function, foo, defined in another object.
Each R_X86_64_JUMP_SLOT relocation has a corresponding PLT entry.
The dynamic tags have been added to the x86-64 psABI to mark such PLT
entries:
https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/
6d824a52a42d173eb838b879616c1be5870b593e
Add an x86-64 linker option, -z mark-plt, to mark PLT entries with
#define DT_X86_64_PLT (DT_LOPROC + 0)
#define DT_X86_64_PLTSZ (DT_LOPROC + 1)
#define DT_X86_64_PLTENT (DT_LOPROC + 3)
1. DT_X86_64_PLT: The address of the procedure linkage table.
2. DT_X86_64_PLTSZ: The total size, in bytes, of the procedure linkage
table.
3. DT_X86_64_PLTENT: The size, in bytes, of a procedure linkage table
entry.
and set the r_addend field of the R_X86_64_JUMP_SLOT relocation to the
memory offset of the indirect branch instruction. The dynamic linker
can use these tags to update the PLT section to direct branch.
bfd/
* elf-linker-x86.h (elf_linker_x86_params): Add mark_plt.
* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Set the
r_addend of R_X86_64_JUMP_SLOT to the indirect branch offset
in PLT entry for -z mark-plt.
* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Add
DT_X86_64_PLT, DT_X86_64_PLTSZ and DT_X86_64_PLTENT for
-z mark-plt.
(_bfd_x86_elf_finish_dynamic_sections): Set DT_X86_64_PLT,
DT_X86_64_PLTSZ and DT_X86_64_PLTENT.
(_bfd_x86_elf_get_synthetic_symtab): Ignore addend for
JUMP_SLOT relocation.
(_bfd_x86_elf_link_setup_gnu_properties): Set
plt_indirect_branch_offset.
* elfxx-x86.h (elf_x86_plt_layout): Add plt_indirect_branch_offset.
binutils/
* readelf.c (get_x86_64_dynamic_type): New function.
(get_dynamic_type): Call get_x86_64_dynamic_type.
include/
* elf/x86-64.h (DT_X86_64_PLT): New.
(DT_X86_64_PLTSZ): Likewise.
(DT_X86_64_PLTENT): Likewise.
ld/
* ld.texi: Document -z mark-plt and -z nomark-plt.
* emulparams/elf32_x86_64.sh: Source x86-64-plt.sh.
* emulparams/elf_x86_64.sh: Likewise.
* emulparams/x86-64-plt.sh: New file.
* testsuite/ld-x86-64/mark-plt-1.s: Likewise.
* testsuite/ld-x86-64/mark-plt-1a-x32.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1a.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1b-x32.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1b.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1c-x32.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1c.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1d-x32.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1d.d: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run -z mark-plt tests.
Nick Clifton [Fri, 29 Sep 2023 14:24:26 +0000 (15:24 +0100)]
Fix: Segmentation fault caused by npd in objdump
PR 30906
* elf.c (_bfd_elf_slurp_version_tables): Test that the verref section header has been initialised before using it.
Nick Clifton [Fri, 29 Sep 2023 10:23:25 +0000 (11:23 +0100)]
Update README file's installation instructions
Sam James [Fri, 29 Sep 2023 04:35:36 +0000 (05:35 +0100)]
gdb: add Sam James to MAINTAINERS
Acked-by: Tom de Vries <tdevries@suse.de>
Kevin Buettner [Fri, 22 Sep 2023 00:58:05 +0000 (17:58 -0700)]
gdb/testsuite: Add relative versus absolute LD_LIBRARY_PATH test
At one time, circa 2006, there was a bug, which was presumably fixed
without adding a test case:
If you provided some relative path to the shared library, such as
with
export LD_LIBRARY_PATH=.
then gdb would fail to match the shared library name during the
TLS lookup.
I think there may have been a bit more to it than is provided by that
explanation, since the test also takes care to split the debug info
into a separate file.
In any case, this commit is based on one of Red Hat's really old
local patches. I've attempted to update it and remove a fair amount
of cruft, hopefully without losing any critical elements from the
test.
Testing on Fedora 38 (correctly) shows 1 unsupported test for
native-gdbserver and 5 PASSes for the native target as well as
native-extended-gdbserver.
In his review of v1 of this patch, Lancelot SIX observed that
'thread_local' could be used in place of '__thread' in the C source
files. But it only became available via the standard in C11, so I
used additional_flags=-std=c11 for compiling both the shared object
and the main program.
Also, while testing with CC_FOR_TARGET=clang, I found that
'additional_flags=-Wl,-soname=${binsharedbase}' caused clang
to complain that this linker flag was unused when compiling
the source file, so I moved this linker option to 'ldflags='.
My testing for this v2 patch shows the same results as with v1,
but I've done additional testing with CC_FOR_TARGET=clang as
well. The results are the same as when gcc is used.
Co-Authored-by: Jan Kratochvil <jan@jankratochvil.net>
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Simon Marchi [Thu, 28 Sep 2023 17:47:46 +0000 (13:47 -0400)]
gdb: remove nbsd_{ilp32,lp64}_solib_svr4_fetch_link_map_offsets
They are unused.
Change-Id: I9b78837d41126ce1957aa1e8b08c82a422f06cbf
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Simon Marchi [Thu, 28 Sep 2023 17:47:45 +0000 (13:47 -0400)]
gdb: remove unused imports in solib*.[ch]
I'm starting to work on these files, I thought it would be a good time
to remove unused imports. These were identified by
include-what-you-use. Tested by rebuilding.
Change-Id: I3eaf3fa0ea3506c7ecfbc8ecff5031433b1dadb8
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
GDB Administrator [Fri, 29 Sep 2023 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in
Michael J. Eager [Thu, 28 Sep 2023 20:08:49 +0000 (13:08 -0700)]
Added support in gas for mlittle-endian and mbig-endian flags as options.
Updated show usage for MicroBlaze specific assembler options
to include new entries.
This patch has been tested for years of AMD Xilinx Yocto
releases as part of the following patch set:
https://github.com/Xilinx/meta-xilinx/tree/master/meta-microblaze/recipes-devtools/binutils/binutils
Signed-off-by: nagaraju <nagaraju.mekala@amd.com>
Signed-off-by: Neal Frager <neal.frager@amd.com>
---
V1->V2:
- removed new options which were unnecessary
- added documentation for MicroBlaze specific options
Signed-off-by: Michael J. Eager <eager@eagercon.com>
Tom de Vries [Thu, 28 Sep 2023 18:17:33 +0000 (20:17 +0200)]
[gdb/tui] Fix segfault in tui_find_disassembly_address
PR29040 describes a FAIL for test-case gdb.threads/next-fork-other-thread.exp
and target board unix/-m32.
The FAIL happens due to the test executable running into an assert, which is
caused by a forked child segfaulting, like so:
...
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00000000 in ?? ()
...
I tried to reproduce the segfault with exec next-fork-other-thread-fork, using
TUI layout asm.
I set a breakpoint at fork and ran to the breakpoint, and somewhere during the
following session I ran into a gdb segfault here in
tui_find_disassembly_address:
...
/* Disassemble forward. */
next_addr = tui_disassemble (gdbarch, asm_lines, new_low, max_lines);
last_addr = asm_lines.back ().addr;
...
due to asm_lines being empty after the call to tui_disassemble, while
asm_lines.back () assumes that it's not empty.
I have not been able to reproduce that segfault in that original setting, I'm
not sure of the exact scenario (though looking back it probably involved
"set detach-on-fork off").
What likely happened is that I managed to reproduce PR29040, and TUI (attempted
to) display the disassembly for address 0, which led to the gdb segfault.
When gdb_print_insn encounters an insn it cannot print because it can't read
the memory, it throws a MEMORY_ERROR that is caught by tui_disassemble.
The specific bit that causes the gdb segfault is that if gdb_print_insn throws
a MEMORY_ERROR for the first insn in tui_disassemble, it returns an empty
asm_lines.
FWIW, I did manage to reproduce the gdb segfault as follows:
...
$ gdb -q \
-iex "set pagination off" \
/usr/bin/rustc \
-ex "set breakpoint pending on" \
-ex "b dl_main" \
-ex run \
-ex "up 4" \
-ex "layout asm" \
-ex "print \$pc"
...
<TUI>
...
$1 = (void (*)()) 0x1
(gdb)
...
Now press <up>, and the segfault triggers.
Fix the segfault by handling asm_lines.empty () results of tui_disassemble in
tui_find_disassembly_address.
I've written a unit test that exercises this scenario.
Tested on x86_64-linux.
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
PR tui/30823
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30823
Tom Tromey [Thu, 24 Aug 2023 15:25:10 +0000 (09:25 -0600)]
Remove old gdb_bfd_openr_iovec
This removes the old gdb_bfd_openr_iovec entirely. I think any new
code should use the type-safe approach.
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Tom Tromey [Thu, 24 Aug 2023 15:23:46 +0000 (09:23 -0600)]
Convert solib-rocm to new type-safe gdb_bfd_openr_iovec
This converts the solib-rocm BFD iovec implementations to the new
type-safe gdb_bfd_openr_iovec. They were already essentially using
this approach, just without the type-safe wrapper.
Thanks to Lancelot Six for testing and fixing this patch.
Co-Authored-By: Lancelot Six <lancelot.six@amd.com>
Acked-by: Lancelot Six <lancelot.six@amd.com>
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Tom Tromey [Thu, 24 Aug 2023 15:16:43 +0000 (09:16 -0600)]
Convert minidebug to new type-safe gdb_bfd_openr_iovec
This converts the minidebug BFD iovec implementation to the new
type-safe gdb_bfd_openr_iovec.
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Tom Tromey [Thu, 24 Aug 2023 15:11:16 +0000 (09:11 -0600)]
Convert target fileio to new type-safe gdb_bfd_openr_iovec
This converts the target fileio BFD iovec implementation to use the
new type-safe gdb_bfd_openr_iovec.
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Tom Tromey [Thu, 24 Aug 2023 14:59:14 +0000 (08:59 -0600)]
Convert mem_bfd_iovec to new type-safe gdb_bfd_openr_iovec
This converts the mem_bfd_iovec / target_buffer code to use the new
type-safe gdb_bfd_openr_iovec.
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Tom Tromey [Thu, 24 Aug 2023 14:53:30 +0000 (08:53 -0600)]
Small constructor change to target_buffer
This changes the target_buffer constructor to initialize m_filename
rather than assign to it.
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Tom Tromey [Thu, 24 Aug 2023 14:47:54 +0000 (08:47 -0600)]
Introduce type-safe variant of gdb_bfd_openr_iovec
This patch adds a new, type-safe variant of gdb_bfd_openr_iovec. In
this approach, the underlying user data is simply an object, the
callbacks are methods, and the "open" function is a function view.
Nothing uses this new code yet.
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Andrew Burgess [Fri, 15 Sep 2023 17:40:21 +0000 (18:40 +0100)]
gdb: use reopen_exec_file from reread_symbols
This commit fixes an issue that was discovered while writing the tests
for the previous commit.
I noticed that, when GDB restarts an inferior, the executable_changed
event would trigger twice. The first notification would originate
from:
#0 exec_file_attach (filename=0x4046680 "/tmp/hello.x", from_tty=0) at ../../src/gdb/exec.c:513
#1 0x00000000006f3adb in reopen_exec_file () at ../../src/gdb/corefile.c:122
#2 0x0000000000e6a3f2 in generic_mourn_inferior () at ../../src/gdb/target.c:3682
#3 0x0000000000995121 in inf_child_target::mourn_inferior (this=0x2fe95c0 <the_amd64_linux_nat_target>) at ../../src/gdb/inf-child.c:192
#4 0x0000000000995cff in inf_ptrace_target::mourn_inferior (this=0x2fe95c0 <the_amd64_linux_nat_target>) at ../../src/gdb/inf-ptrace.c:125
#5 0x0000000000a32472 in linux_nat_target::mourn_inferior (this=0x2fe95c0 <the_amd64_linux_nat_target>) at ../../src/gdb/linux-nat.c:3609
#6 0x0000000000e68a40 in target_mourn_inferior (ptid=...) at ../../src/gdb/target.c:2761
#7 0x0000000000a323ec in linux_nat_target::kill (this=0x2fe95c0 <the_amd64_linux_nat_target>) at ../../src/gdb/linux-nat.c:3593
#8 0x0000000000e64d1c in target_kill () at ../../src/gdb/target.c:924
#9 0x00000000009a19bc in kill_if_already_running (from_tty=1) at ../../src/gdb/infcmd.c:328
#10 0x00000000009a1a6f in run_command_1 (args=0x0, from_tty=1, run_how=RUN_STOP_AT_MAIN) at ../../src/gdb/infcmd.c:381
#11 0x00000000009a20a5 in start_command (args=0x0, from_tty=1) at ../../src/gdb/infcmd.c:527
#12 0x000000000068dc5d in do_simple_func (args=0x0, from_tty=1, c=0x35c7200) at ../../src/gdb/cli/cli-decode.c:95
While the second originates from:
#0 exec_file_attach (filename=0x3d7a1d0 "/tmp/hello.x", from_tty=0) at ../../src/gdb/exec.c:513
#1 0x0000000000dfe525 in reread_symbols (from_tty=1) at ../../src/gdb/symfile.c:2517
#2 0x00000000009a1a98 in run_command_1 (args=0x0, from_tty=1, run_how=RUN_STOP_AT_MAIN) at ../../src/gdb/infcmd.c:398
#3 0x00000000009a20a5 in start_command (args=0x0, from_tty=1) at ../../src/gdb/infcmd.c:527
#4 0x000000000068dc5d in do_simple_func (args=0x0, from_tty=1, c=0x35c7200) at ../../src/gdb/cli/cli-decode.c:95
In the first case the call to exec_file_attach first passes through
reopen_exec_file. The reopen_exec_file performs a modification time
check on the executable file, and only calls exec_file_attach if the
executable has changed on disk since it was last loaded.
However, in the second case things work a little differently. In this
case GDB is really trying to reread the debug symbol. As such, we
iterate over the objfiles list, and for each of those we check the
modification time, if the file on disk has changed then we reload the
debug symbols from that file.
However, there is an additional check, if the objfile has the same
name as the executable then we will call exec_file_attach, but we do
so without checking the cached modification time that indicates when
the executable was last reloaded, as a result, we reload the
executable twice.
In this commit I propose that reread_symbols be changed to
unconditionally call reopen_exec_file before performing the objfile
iteration. This will ensure that, if the executable has changed, then
the executable will be reloaded, however, if the executable has
already been recently reloaded, we will not reload it for a second
time.
After handling the executable, GDB can then iterate over the objfiles
list and reload them in the normal way.
With this done I now see the executable reloaded only once when GDB
restarts an inferior, which means I can remove the kfail that I added
to the gdb.python/py-exec-file.exp test in the previous commit.
Approved-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Mon, 28 Aug 2023 15:22:36 +0000 (16:22 +0100)]
gdb/python: make the executable_changed event available from Python
This commit makes the executable_changed observable available through
the Python API as an event. There's nothing particularly interesting
going on here, it just follows the same pattern as many of the other
Python events we support.
The new event registry is called events.executable_changed, and this
emits an ExecutableChangedEvent object which has two attributes, a
gdb.Progspace called 'progspace', this is the program space in which
the executable changed, and a Boolean called 'reload', which is True
if the same executable changed on disk and has been reloaded, or is
False when a new executable has been loaded.
One interesting thing did come up during testing though, you'll notice
the test contains a setup_kfail call. During testing I observed that
the executable_changed event would trigger twice when GDB restarted an
inferior. However, the ExecutableChangedEvent object is identical for
both calls, so the wrong information is never sent out, we just see
one too many events.
I tracked this down to how the reload_symbols function (symfile.c)
takes care to also reload the executable, however, I've split fixing
this into a separate commit, so see the next commit for details.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Fri, 8 Sep 2023 15:02:13 +0000 (16:02 +0100)]
gdb: pass more arguments to the executable_changed observer
This commit continues the work of the previous few commits.
My goal is to expose the executable_changed observer through the
Python API as an event.
At this point adding executable_changed as an event to the Python API
is trivial, but before I do that I would like to add some additional
arguments to the observable, which currently has no arguments at all.
The new arguments I wish to add are:
1. The program_space in which the executable was changed, and
2. A boolean flag that will indicate if the executable changed to a
whole new path, or if GDB just spotted that the executable changed on
disk (e.g. the user recompiled the executable).
In this commit I change the signature of the observable and then pass
the arguments through at the one place where this observable is
notified.
As there are (currently) no users of this observable nothing else
needs updating. In the next commit I'll add a listener for this
observable in the Python code, and expose this as an event in the
Python API.
Additionally, with this change, it should be possible to update the
insight debugger to make use of this observable rather than using the
deprecated_exec_file_display_hook (as it currently does), which will
then allow this hook to be removed from GDB.
There should be no user visible changes after this commit.
Approved-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Fri, 8 Sep 2023 14:50:19 +0000 (15:50 +0100)]
gdb: remove unnecessary notification of executable_changed observer
This commit continues the work of the previous two commits.
My goal, in the next couple of commits, is to expose the
executable_changed observable in the Python API as an event. However,
before I do that I want to remove the use of the executable_changed
observable from the reread_symbols function in symfile.c as this use
isn't directly associated with a change of the executable file, and so
seems wrong.
In the previous two commits I have removed all users of the
executable_changed observer as I believe those users can, and should,
actually be listening for the new_objfile observable instead, so now
there are no users of the executable_changed observable.
As such, I think removing the use of executable_changed from the
function reread_symbols is perfectly safe, and correct. At this point
the executable has not been changed, so we shouldn't be sending an
executable_changed notification, and, as there is nobody listening to
this observable, we can't break anything by removing this call.
There should be no user visible changes after this commit.
Approved-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Fri, 8 Sep 2023 14:48:16 +0000 (15:48 +0100)]
gdb: remove final user of the executable_changed observer
This commit continues with the task started in the previous commit,
and is similar in many ways.
The goal of the next couple of commits is to expose the
executable_changed observable in the Python API as an event. Before I
do this I would like to remove the additional call to the
executable_changed observable which can be found in the reread_symbols
function in the symfile.c file, as I don't believe that this use
actually corresponds to a change in the current executable.
The previous commit removed one user of the executable_changed
observable and replaced it with a new_obfile observer instead, and
this commit does the same thing.
In auxv.c we use the executable_changed observable to call
invalidate_auxv_cache, which then calls:
invalidate_auxv_cache_inf (current_inferior ());
The auxv cache is already (additionally) cleared when an inferior
exits and when an inferior appears.
As with the previous commit, I think we can safely replace the use of
the executable_changed observable with a use of the new_obfile
observable. All the tests still pass, and with some locally placed
printf calls, I think that the cache is still being cleared in all the
cases that should matter.
Approved-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Fri, 8 Sep 2023 14:44:40 +0000 (15:44 +0100)]
gdb: remove one user of the executable changed observer
My goal for the next few commits is to expose the executable_changed
observable from the Python API.
However, there is call to the executable_changed observable in the
reread_symbols function (in symfile.c), and this doesn't actually
correspond to the executable changing. My idea then, is to remove
this use of the executable_changed observable, but, before I can do
that, I need to check that nothing is going to break, and that
requires my to think about the current users of this observable.
One current user of executable_changed is in symtab.c. We add an
executable_changed observer that calls:
set_main_name (nullptr, language_unknown);
to discard all information about the main function when the executable
changes.
However, changing the executable doesn't actually change the debug
information. The debug information changes when the symbol-file
changes, so I think this observer is in slightly the wrong place.
The new_objfile observable is (unfortunately) overloaded, it is called
when a new objfile is loaded, and also (when its argument is nullptr),
when all debug information should be discarded.
It turns out that there is already a new_objfile observer in
symtab.c. I propose that, when the argument is nullptr (indicating
all debug info should be discarded), that we should call set_main_name
to discard the information about the main function. We can then
remove the executable_changed observer from symtab.c.
All tests still pass, and, in my local world, I added some debug
printf calls, and I think we are still discarded the main information
everywhere we need to.
Approved-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Thu, 7 Sep 2023 14:47:07 +0000 (15:47 +0100)]
gdb/python: new Progspace.executable_filename attribute
Add a new Progspace.executable_filename attribute that contains the
path to the executable for this program space, or None if no
executable is set.
The path within this attribute will be set by the "exec-file" and/or
"file" commands.
Accessing this attribute for an invalid program space will raise an
exception.
This new attribute is similar too, but not the same as the existing
gdb.Progspace.filename attribute. If I could change the past, I'd
change the 'filename' attribute to 'symbol_filename', which is what it
actually represents. The old attribute will be set by the
'symbol-file' command, while the new attribute is set by the
'exec-file' command. Obviously the 'file' command sets both of these
attributes.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Thu, 7 Sep 2023 10:18:16 +0000 (11:18 +0100)]
gdb/python: new Progspace.symbol_file attribute
Add a new Progspace.symbol_file attribute. This attribute holds the
gdb.Objfile object that corresponds to Progspace.filename, or None if
there is no main symbol file currently set.
Currently, to get this gdb.Objfile, a user would need to use
Progspace.objfiles, and then search for the objfile with a name that
matches Progspace.filename -- which should work just fine, but having
direct access seems a little nicer.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
Andrew Burgess [Mon, 28 Aug 2023 15:58:12 +0000 (16:58 +0100)]
gdb/doc: extend the description for Progspace.filename
Extend the description for Progspace.filename in the documentation to
mention what the returned string is actually the filename
for (e.g. that it is the filename passed to the 'symbol-file' or
'file' command).
Also document that this attribute will be None if no symbol file is
currently loaded.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Wed, 27 Sep 2023 16:15:22 +0000 (12:15 -0400)]
gdb/x86: use size of XSAVE area of enabled features
Since commit
b42405a1594 ("gdb: Update x86 Linux architectures to
support XSAVE layouts."), the test gdb.base/gcore.exp fails on my AMD
Ryzen 3700X machine:
FAIL: gdb.base/gcore.exp: corefile restored all registers
The test gets the register state (saves the output of "info
all-registers"), saves a core with the "gcore" command, loads the core,
and checks the register state against the one previously saved. The
problem is that when reading registers from the core file, the last half
of ymm registers is unavailable:
(gdb) print $ymm0.v32_int8
$1 = {0, -77, -23, -9, -1, 127, 0, 0, 0, -77, -23, -9, -1, 127, 0, 0, <unavailable> <repeats 16 times>}
One strange thing with this machine is that the bitset of state
components supported by XCR0 is 0x207, meaning "x87 | SSE | AVX | PKRU",
but XCR0 at runtime is 0x7, meaning "x87 | SSE | AVX". So, PKRU appears
to be supported by the processor, but disabled by the kernel. I didn't
find why yet.
From CPUID leaf EAX=0Dh, ECX=00h, GDB can get:
- from EBX: max size of the XSAVE area required by features currently
enabled in XCR0. On my machine, it's 0x340 (832).
- from ECX: max size of the XSAVE area required by all features
supported by XCR0. On my machine, it's 0x380 (896).
At runtime, GDB uses ECX (max size required by all supported features)
to fill the x86_xsave_layout::sizeof_xsave. So, when writing the core
file note for the XSAVE state, it writes a note of size 896, even though
it doesn't write the PKRU state. When loading back the core, GDB tries
to figure out the layout of the XSAVE area based on what features are
enabled in XCR0 and the size of the note (the size of the XSAVE area).
Since my combination of XCR0 and size of XSAVE area doesn't match any
combination known by GDB, GDB falls back to a gdbarch supporting only
x87 and SSE.
This patch changes GDB to populate the x86_xsave_layout::sizeof_xsave
field (and consequently the size of the XSAVE state note in core files)
using EBX, the size of the XSAVE area required by currently enabled
features in XCR0. This makes i387_guess_xsave_layout recognize my case
with this condition:
else if (HAS_AVX (xcr0) && xsave_size == 832)
{
/* Intel and AMD CPUs supporting AVX. */
layout.avx_offset = 576;
}
In other words, just as if my machine didn't support PKRU at all.
Another reason why I think this change makes sense is that XSAVE state
notes in kernel-generated cores on this machine have size 832. So this
change makes GDB-generated cores more similar to kernel-generated ones,
reducing the diversity of XSAVE state notes that GDB needs to be able to
figure out.
Note that if PKRU was enabled on my machine, then the effective XSAVE
area size would be 896 bytes. We would need to add a case in
i387_guess_xsave_layout for that combination, since there is no
currently. But I don't have a way to test that right now, since I don't
know why PKRU is disabled.
Relevant review note from John Baldwin:
One further note is that the Linux x86 arches use x86_xsave_length()
to infer ("guess") the size of the XSAVE register set that the Linux
kernel writes out in core dumps. On FreeBSD x86 arches, GDB is able
to query this size directly from the kernel via ptrace. My use of ECX
for this guess earlier was just not the best guess. In the case that
the kernel enables all of the available features, then ECX and EBX
have the same values, so this only matters for a system where the
kernel has enabled a subset of available XSAVE extensions.
Change-Id: If64f30307f3a2e5ca3e1fd1cb7379ea840805a85
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Frederic Cambus [Thu, 28 Sep 2023 12:39:01 +0000 (13:39 +0100)]
Add support to readelf for the PT_OPENBSD_NOBTCFI segment type.
Nick Clifton [Thu, 28 Sep 2023 11:37:59 +0000 (12:37 +0100)]
Fix: nm: SEGV on unknow address at nm.c:718 in print_symname
PR 30886 * elf-bfd.h (struct elf_obj_tdata): Add dt_strsz field.
* elf.c (_bfd_elf_get_dynamic_symbols): Add a NUL byte at the end of the string table. Initialise the dt_strsz field. (_bfd_elf_slurp_version_tables): Only free the contents if they were malloc'ed. Add checks before setting string pointers in the dt_strtab buffer.
Tom de Vries [Thu, 28 Sep 2023 07:47:36 +0000 (09:47 +0200)]
[gdb/testsuite] Add nopie to gdb.base/unwind-on-each-insn-amd64-2.exp
When running test-case gdb.base/unwind-on-each-insn-amd64-2.exp with target
board unix/-fPIE/-pie, I run into:
...
gdb compile failed, ld: unwind-on-each-insn-amd64-21.o: relocation \
R_X86_64_32S against `.text' can not be used when making a PIE object; \
recompile with -fPIE
ld: failed to set dynamic section sizes: bad value
...
Fix this by hardcoding nopie in the test-case, and for good measure in the
other test-cases that source unwind-on-each-insn.exp.tcl and use a .s file.
Tested on x86_64-linux.
Approved-by: Kevin Buettner <kevinb@redhat.com>
GDB Administrator [Thu, 28 Sep 2023 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in
Aaron Merey [Wed, 27 Sep 2023 19:11:13 +0000 (15:11 -0400)]
config/debuginfod.m4: Add check for libdebuginfod 0.188
Add check for libdebuginfod 0.188 in AC_DEBUGINFOD and if found
define macro HAVE_LIBDEBUGINFOD_FIND_SECTION.
This macro indicates support for downloading ELF sections from
debuginfod servers.
Nick Clifton [Wed, 27 Sep 2023 15:09:06 +0000 (16:09 +0100)]
nm: heap-buffer-overflow at elfcode.h:1507 in bfd_elf64_slurp_symbol_table
PR 30885
* elfcode.h (elf_slurp_symbol_table): Compute the symcount for non dynamic symbols in the same way as _bfd_elf_get_symtab_upper_bound.
Jan Beulich [Wed, 27 Sep 2023 14:53:09 +0000 (16:53 +0200)]
x86: prefer VEX encodings over EVEX ones when possible
AVX-* features / insns paralleling earlier introduced AVX512* ones can
be encoded more compactly when the respective feature was explicitly
enabled by the user.
Jan Beulich [Wed, 27 Sep 2023 14:52:08 +0000 (16:52 +0200)]
x86: drop cpu_arch_tune_flags
Apparently from its introduction the variable was only ever written (the
only read is merely to determine whether to write it with another value).
(Since, due to the need to re-indent, the adjacent lines setting
cpu_arch_tune need touching anyway, switch to using PREOCESSOR_*
constants where applicable, to make more obvious what the resulting
state is going to be.)
Jan Beulich [Wed, 27 Sep 2023 14:51:46 +0000 (16:51 +0200)]
x86: correct cpu_arch_isa_flags maintenance
These may not be set from a value derived from cpu_arch_flags: That
starts with (almost) all functionality enabled, while cpu_arch_isa_flags
is supposed to track features that were explicitly enabled (and perhaps
later disabled) by the user.
To avoid needing to do any such adjustment in two places (each),
introduce helper functions used by both command line handling and
directive processing.
Pedro Alves [Tue, 19 Sep 2023 11:26:26 +0000 (12:26 +0100)]
Adjust gdb.thread/pthreads.exp for Cygwin
The Cygwin runtime spawns a few extra threads, so using hardcoded
thread numbers in tests rarely works correctly. Thankfully, this
testcase already records the ids of the important threads in globals.
It just so happens that they are not used in a few tests. This commit
fixes that.
With this, the test passes cleanly on Cygwin [1]. Still passes cleanly on
x86-64 GNU/Linux.
[1] - with system GDB. Upstream GDB is missing a couple patches
Cygwin carries downstream.
Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I01bf71fcb44ceddea8bd16b933b10b964749a6af
Pedro Alves [Fri, 15 Sep 2023 19:06:37 +0000 (20:06 +0100)]
In gdb.threads/pthreads.c, handle pthread_attr_setscope ENOTSUP
On Cygwin, I see:
(gdb) PASS: gdb.threads/pthreads.exp: break thread1
continue
Continuing.
pthread_attr_setscope 1: Not supported (134)
[Thread 3732.0x265c exited with code 1]
[Thread 3732.0x2834 exited with code 1]
[Thread 3732.0x2690 exited with code 1]
Program terminated with signal SIGHUP, Hangup.
The program no longer exists.
(gdb) FAIL: gdb.threads/pthreads.exp: Continue to creation of first thread
... and then a set of cascading failures.
Fix this by treating ENOTSUP the same way as if PTHREAD_SCOPE_SYSTEM
were not defined. I.e., ignore ENOTSUP errors, and proceed with
testing.
Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: Iea68ff8b9937570726154f36610c48ef96101871
Pedro Alves [Fri, 15 Sep 2023 18:43:55 +0000 (19:43 +0100)]
Fix gdb.threads/pthreads.exp error handling/printing
On Cygwin, I noticed:
(gdb) PASS: gdb.threads/pthreads.exp: break thread1
continue
Continuing.
pthread_attr_setscope 1: No error
[Thread 8732.0x28f8 exited with code 1]
[Thread 8732.0xb50 exited with code 1]
[Thread 8732.0x17f8 exited with code 1]
Program terminated with signal SIGHUP, Hangup.
The program no longer exists.
(gdb) FAIL: gdb.threads/pthreads.exp: Continue to creation of first thread
Note "No error" in "pthread_attr_setscope 1: No error". That is a bug
in the test. It is using perror, but that prints errno, while the
pthread functions return the error directly. Fix all cases of the
same problem, by adding a new print_error function and using it.
We now get:
...
pthread_attr_setscope 1: Not supported (134)
...
Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I972ebc931b157bc0f9084e6ecd8916a5e39238f5
Pedro Alves [Fri, 15 Sep 2023 18:55:54 +0000 (19:55 +0100)]
Fix gdb.threads/pthreads.c formatting
Just some GNU formatting fixes throughout.
Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: Ie851e3815b839e57898263896db0ba8ddfefe09e
Pedro Alves [Fri, 15 Sep 2023 18:54:40 +0000 (19:54 +0100)]
gdb.threads/pthreads.c, K&R -> ANSI function style
gdb.threads/pthreads.c is declaring functions with old K&R style.
This commit converts them to ANSI style.
Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I1ce007c67bb4ab1e49248c014c7881e46634f8f8
Neal Frager [Wed, 27 Sep 2023 13:47:01 +0000 (14:47 +0100)]
opcodes: microblaze: Add wdc.ext.clear and wdc.ext.flush insns
Hsinyuan Xavier [Wed, 27 Sep 2023 12:21:43 +0000 (13:21 +0100)]
Fix: Output section type does not been applied to section forced output by `. = .` assignment
PR 30875
* ldlang.c (get_os_init_flag): New function. (exp_init_os, map_input_to_output_sections): Use it.
Jan Beulich [Wed, 27 Sep 2023 12:16:09 +0000 (14:16 +0200)]
x86: fold FMA VEX and EVEX templates
Following the folding of some generic AVX/AVX2 templates with their
AVX512F counterpart ones, do this for FMA ones as well, requiring one
further adjustment to cpu_flags_match().
Jan Beulich [Wed, 27 Sep 2023 12:15:44 +0000 (14:15 +0200)]
x86: fold VAES/VPCLMULQDQ VEX and EVEX templates
Following the folding of some generic AVX/AVX2 templates with their
AVX512F counterpart ones, do this for VAES and VPCLMULQDQ ones as well.
Jan Beulich [Wed, 27 Sep 2023 12:15:19 +0000 (14:15 +0200)]
x86: fold certain VEX and EVEX templates
In anticipation of APX introduce logic to reduce the number of templates
we have now, allowing to limit some the number of ones we then need to
gain.
The fundamental requirements are that
- attributes be compatible, which specifically means VexW needs to be
the same in the templates (which often isn't the case, for VEX
encodings having far more WIG tha, EVEX ones),
- the EVEX form being AVX512F (with or without AVX512VL), not any of its
extensions (the same will then be required for APX - it'll need to be
APX_F).
Note that in check_register() there's now a redundant zmm check. Since
this logic will need revisiting for APX anyway, I'd like to keep it that
way for now. (Similarly a couple of if()-s which could be folded are
kept separate, to reduce code churn when adding APX support.)
Jan Beulich [Wed, 27 Sep 2023 08:54:23 +0000 (10:54 +0200)]
x86: tighten .insn SAE and broadcast checking
SAE / embedded rounding are invalid when there's the memory operand, as
the bit encoding this specifies broadcast in that case.
Broadcast needs to be specified on the memory operand.
Jan Beulich [Wed, 27 Sep 2023 08:53:59 +0000 (10:53 +0200)]
x86-64: REX.W overrides DATA_PREFIX
REX.W needs to be respected when immediate size and relocation type are
determined.
Jan Beulich [Wed, 27 Sep 2023 08:53:38 +0000 (10:53 +0200)]
x86-64: fix suffix-less PUSH of symbol address
PR gas/30856
In
5cc007751cdb ("x86: further adjust extend-to-32bit-address
conditions") I neglected the case of PUSH, which is the only insn
allowing (proper) symbol addresses to be used as immediates (not
displacements, like CALL/JMP) in the absence of any register operands.
Since it defaults to 64-bit operand size, guessing an L suffix is wrong
there.
Sam James [Tue, 12 Sep 2023 00:46:51 +0000 (01:46 +0100)]
gdb: Fix an ODR warning with byacc with GDB_YY_REMAP
With byacc, we get an ODR warning with YYSTACKDATA between ada-exp.c.tmp
and c-exp.c.tmp. Just include it in the list of symbols we rename.
PR gdb/30839
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30839
Approved-By: Tom de Vries <tdevries@suse.de>
Copyright-paperwork-exempt: yes
mengqinggang [Mon, 18 Sep 2023 10:00:21 +0000 (18:00 +0800)]
Add support for "pcaddi rd, symbol"
Add a macro pcaddi instruction to support "pcaddi rd, symbol".
pcaddi has a 20-bit signed immediate, it can address a +/- 2MB pc relative
address, and the address should be 4-byte aligned.
GDB Administrator [Wed, 27 Sep 2023 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Fri, 8 Sep 2023 01:53:55 +0000 (21:53 -0400)]
gdb/testsuite: add xfail for gdb/29965 in gdb.threads/process-exit-status-is-leader-exit-status.exp
Bug 29965 shows on a Linux kernel >= 6.1, that test fails consistently
with:
FAIL: gdb.threads/process-exit-status-is-leader-exit-status.exp: iteration=0: continue (the program exited)
...
FAIL: gdb.threads/process-exit-status-is-leader-exit-status.exp: iteration=9: continue (the program exited)
This is due to a change in Linux kernel behavior [1] that affects
exactly what this test tests. That is, if multiple threads (including
the leader) call SYS_exit, the exit status of the process should be the
exit status of the leader. After that change in the kernel, it is no
longer the case.
Add an xfail in the test, based on the Linux kernel version. The goal
is that if a regression is introduced in GDB regarding this feature, it
should be caught if running on an older kernel where the behavior was
consistent.
[1] https://bugzilla.suse.com/show_bug.cgi?id=
1206926
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29965
Change-Id: If6ab7171c92bfc1a3b961c7179e26611773969eb
Approved-By: Tom de Vries <tdevries@suse.de>
Tom de Vries [Tue, 26 Sep 2023 16:57:49 +0000 (18:57 +0200)]
[gdb/testsuite] Fix gdb.ada/mi_task_arg.exp with newer gcc
When running test-case gdb.ada/mi_task_arg.exp on openSUSE Tumbleweed using
gcc 13.2.1, I run into (layout adapted for readability):
...
-stack-list-arguments 1^M
^done,stack-args=[
frame={level="0",args=[]},
frame={level="1",args=[{name="<_task>",value="0x464820"},
{name="<_taskL>",value="129"}]},
frame={level="2",args=[{name="self_id",value="0x464840"}]},
frame={level="3",args=[]},
frame={level="4",args=[]}
]^M
(gdb) ^M
FAIL: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1 (unexpected output)
...
On openSUSE Leap 15.4 with gcc 7.5.0 I get instead:
...
-stack-list-arguments 1^M
^done,stack-args=[
frame={level="0",args=[]},
frame={level="1",args=[{name="<_task>",value="0x444830"}]},
frame={level="2",args=[{name="self_id",value="0x444850"}]},
frame={level="3",args=[]},
frame={level="4",args=[]}]^M
(gdb) ^M
PASS: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1
...
The difference in gdb output is due to difference in the dwarf generated by
the compiler, so I don't see a problem with gdb here.
Fix this by updating the test-case to accept this output.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
Tom Tromey [Tue, 26 Sep 2023 15:51:56 +0000 (09:51 -0600)]
Remove some unnecessary qualification from printing.py
printing.py references "gdb.printing" in a few spots, but there's no
need for this. I think this is leftover from when this code was
(briefly) in some other module. This patch removes the unnecessary
qualifications. Tested on x86-64 Fedora 36.
Tom Tromey [Fri, 8 Sep 2023 19:18:17 +0000 (13:18 -0600)]
Add two new pretty-printer methods
This adds two new pretty-printer methods, to support random access to
children. The methods are implemented for the no-op array printer,
and DAP is updated to use this.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Tom Tromey [Thu, 7 Sep 2023 19:40:29 +0000 (13:40 -0600)]
Introduce gdb.ValuePrinter
There was an earlier thread about adding new methods to
pretty-printers:
https://sourceware.org/pipermail/gdb-patches/2023-June/200503.html
We've known about the need for printer extensibility for a while, but
have been hampered by backward-compatibilty concerns: gdb never
documented that printers might acquire new methods, and so existing
printers may have attribute name clashes.
To solve this problem, this patch adds a new pretty-printer tag class
that signals to gdb that the printer follows new extensibility rules.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30816
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Nick Clifton [Tue, 26 Sep 2023 15:27:28 +0000 (16:27 +0100)]
Fix a snafu in the new tests for reproducible archives that assumed a umask of 22.
Tom de Vries [Tue, 26 Sep 2023 14:28:48 +0000 (16:28 +0200)]
[gdb/testsuite] Fix gdb.server/ext-run.exp in container
When running the gdb testsuite inside a container, I run into:
...
(gdb) gdb_expect_list pattern: /1 +root +[/a-z]*(init|systemd)/
FAIL: gdb.server/ext-run.exp: get process list (pattern 2)
...
because there's no process with pid 1 and cmd init or systemd.
In the host system (where the test passes), I have:
...
$ ps -f 1
UID PID PPID C STIME TTY STAT TIME CMD
root 1 0 0 Sep25 ? Ss 0:03 /usr/lib/systemd/systemd ...
...
but in the container instead:
...
UID PID PPID C STIME TTY STAT TIME CMD
root 1 0 0 11:45 pts/0 Ss 0:00 /bin/bash
...
Fix this by also accepting bash as a valid cmd.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
Richard Sandiford [Tue, 26 Sep 2023 14:01:21 +0000 (15:01 +0100)]
aarch64: Allow feature flags to occupy >64 bits
Following on from the previous patch to make the feature macros take
a word number, this one increases the number of flag words from 1 to 2.
The patch uses some dummy features to push the number of features
over 64. The intention is that these should be reused by real
features rather than kept as-is.
Richard Sandiford [Tue, 26 Sep 2023 14:01:21 +0000 (15:01 +0100)]
aarch64: Restructure feature flag handling
The AArch64 feature-flag code is currently limited to a maximum
of 64 features. This patch reworks it so that the limit can be
increased more easily. The basic idea is:
(1) Turn the ARM_FEATURE_FOO macros into an enum, with the enum
counting bit positions.
(2) Make the feature-list macros take an array index argument
(currently always 0). The macros then return the
aarch64_feature_set contents for that array index.
An N-element array would then be initialised as:
{ MACRO (0), ..., MACRO (N - 1) }
(3) Provide convenience macros for initialising an
aarch64_feature_set for:
- a single feature
- a list of individual features
- an architecture version
- an architecture version + a list of additional features
(2) and (3) use the preprocessor to generate static initialisers.
The main restriction was that uses of the same preprocessor macro
cannot be nested. So if a macro wants to do something for N individual
arguments, it needs to use a chain of N macros to do it. There then
needs to be a way of deriving N, as a preprocessor token suitable for
pasting.
The easiest way of doing that was to precede each list of features
by the number of features in the list. So an aarch64_feature_set
initialiser for three features A, B and C would be written:
AARCH64_FEATURES (3, A, B, C)
This scheme makes it difficult to keep AARCH64_FEATURE_CRYPTO as a
synonym for SHA2+AES, so the patch expands the former to the latter.
Tom de Vries [Tue, 26 Sep 2023 13:51:27 +0000 (15:51 +0200)]
[gdb/dap] Fix dap for python < 3.8
With any gdb.dap test and python 3.6 I run into:
...
Error occurred in Python: 'code' object has no attribute 'co_posonlyargcount'
ERROR: eof reading json header
...
The attribute is not supported before python 3.8, which introduced the
"Positional−only Parameters" concept.
Fix this by using try/except AttributeError.
Tested on x86_64-linux:
- openSUSE Leap 15.4 with python 3.6, and
- openSUSE Tumbleweed with python 3.11.5.
Approved-By: Tom Tromey <tom@tromey.com>
Enze Li [Tue, 26 Sep 2023 12:55:36 +0000 (20:55 +0800)]
fbsd-nat: Fix build failure with GCC 12
A user pointed out that the build failed on FreeBSD/amd64 with my last
commit. The problem is that I'm not using the proper way to tell the
compiler that the variable has been "used". This patch fixes this issue
as suggested by John. Pushed as obvious.
Tested both on FreeBSD/amd64 and FreeBSD/aarch64 by rebuilding.
Suggested-By: John Baldwin <jhb@FreeBSD.org>
Aditya Vidyadhar Kamath [Tue, 26 Sep 2023 05:48:57 +0000 (00:48 -0500)]
Fix to step instruction due to P10 prefix instruction.
In AIX, power 10 instructions like paddi occupy 8 bytes, while the other instructions
4 bytes of space. Due to this when we do a stepi on paddi instruction we get a SIGILL interrupt. Hence, we
need to check during stepi if we are able to step 8 bytes during this instruction execution and is the
breakpoint to this instruction set correctly in both 32- and 64-bit mode.
This patch is a fix to the same.
Nick Clifton [Tue, 26 Sep 2023 13:07:23 +0000 (14:07 +0100)]
Allow the use of SOURCE_DATE_EPOCH in the timestamps for members of static archives.
(For some reason this commit was not applied at the time that the patch was approved).
Tom Tromey [Thu, 21 Sep 2023 19:31:14 +0000 (13:31 -0600)]
Use string_file::release in some places
I found a few spots like:
string_file f;
std::string x = f.string ();
However, string_file::string returns a 'const std::string &'... so it
seems to me that this must be copying the string (? I find it hard to
reason about this in C++).
This patch changes these spots to use release() instead, which moves
the string.
Reviewed-by: Keith Seitz <keiths@redhat.com>
Reviewed-by: Lancelot Six <lancelot.six@amd.com>
GDB Administrator [Tue, 26 Sep 2023 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in
Vsevolod Alekseyev [Mon, 25 Sep 2023 17:01:31 +0000 (18:01 +0100)]
Fix readelf's display of dwarf v5 range lists
PR 30792
* dwarf.h (struct debug_info): Remove range_versions field.
* dwarf.c (fetch_indexed_offset): New function. (read_and_display_attr_value): Use it for DW_FORM_rnglistx. Remove code to initialise range_versions. (skip_attribute): New function. (read_bases): Read and reccord all range and address bases in a CU. (process_debug_info): Call read_bases. (display_debug_rnglists): Rename to display_debug_rnglists_unit_header and only display the range list header information. (display_debug_ranges): Adjust.
Claudiu Zissulescu [Mon, 25 Sep 2023 14:03:35 +0000 (17:03 +0300)]
Revert "arc: Add new GAS tests for ARCv3."
This reverts commit
462693a455f04fc52c1c91ffc52ea2446a086444.
Claudiu Zissulescu [Mon, 25 Sep 2023 14:03:20 +0000 (17:03 +0300)]
Revert "arc: Add new LD tests for ARCv3."
This reverts commit
6e467e9a94c1135bd11d985e9263d43204a9258b.
Claudiu Zissulescu [Mon, 25 Sep 2023 14:03:06 +0000 (17:03 +0300)]
Revert "arc: Add new ARCv3 ISA to BFD."
This reverts commit
06e8d9861d16c5b7e6920ad0e89889ccf45c575a.
Claudiu Zissulescu [Mon, 25 Sep 2023 14:02:55 +0000 (17:02 +0300)]
Revert "arc: Add new linker emulation and scripts for ARCv3 ISA."
This reverts commit
4deb1ee57fdb711cac6f36fed75b3c8cb5112d99.
Claudiu Zissulescu [Mon, 25 Sep 2023 14:02:41 +0000 (17:02 +0300)]
Revert "arc: Update opcode related include files for ARCv3."
This reverts commit
04414221df53bb5129e34bec354dae3121db436a.
Claudiu Zissulescu [Mon, 25 Sep 2023 14:02:29 +0000 (17:02 +0300)]
Revert "arc: Update ARC's Gnu Assembler backend with ARCv3 ISA."
This reverts commit
f3d38d7d0b7346515ba603454feeddc58a3fc451.
Claudiu Zissulescu [Mon, 25 Sep 2023 14:02:19 +0000 (17:02 +0300)]
Revert "arc: Add new opcode functions for ARCv3 ISA."
This reverts commit
c99dc76089a2de97ea0ee755aa8e87037a17b6d6.
Claudiu Zissulescu [Mon, 25 Sep 2023 14:02:08 +0000 (17:02 +0300)]
Revert "arc: New ARCv3 ISA instruction table"
This reverts commit
67036dfacf87e79317984f51892bfc0eda0e597f.
Claudiu Zissulescu [Mon, 25 Sep 2023 14:01:58 +0000 (17:01 +0300)]
Revert "arc: Update arc's gas tests"
This reverts commit
ef90c0991e78c28bebdd3ed31a77c05be0444191.
Claudiu Zissulescu [Mon, 25 Sep 2023 14:01:47 +0000 (17:01 +0300)]
Revert "arc: Update NEWS files"
This reverts commit
a47d304b1229ecf8912fac17ee9c48d1bf3c729a.
Claudiu Zissulescu [Mon, 25 Sep 2023 14:01:34 +0000 (17:01 +0300)]
Revert "arc: Update bfd arc pattern file to allow enable-targets=all"
This reverts commit
5e5116071b09e187ee3c6b7e86e86114f6a65ef3.
Claudiu Zissulescu [Mon, 25 Sep 2023 12:00:49 +0000 (15:00 +0300)]
arc: Update bfd arc pattern file to allow enable-targets=all
The ARC backend uses a BFD pattern file to generate three ARC targets:
- an BFD ARC target for ARCv1 and ARCv2 CPU families. It also works
for big-endian variants.
- an BFD ARC64 target for ARCv3 64bit machines. It also allows working
with ARCv3 32bit machines.
- an BFD ARC32 target for ARCv4 32bit machines. It also allows working
with ARCv3 64bit machines.
When configuring with `--enable-targets=all` some patterns are defined
multiple times. Fix this issue.
Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
Andreas Schwab [Thu, 21 Sep 2023 14:49:41 +0000 (16:49 +0200)]
RISC-V: Protect .got with relro
Move .got before .data so that it can be protected with -zrelro. Also
separate .got.plt from .got if -znow is not in effect; the first two words
of .got.plt are placed within the relro region.
ld:
PR ld/30877
* emulparams/elf32lriscv-defs.sh (DATA_GOT, SEPARATE_GOTPLT):
Define.
* emulparams/elf64lriscv-defs.sh (SEPARATE_GOTPLT): Define.
* testsuite/ld-elf/binutils.exp (binutils_test): Remove riscv*-*-*
from relro_got expression.
Claudiu Zissulescu [Mon, 25 Sep 2023 08:33:12 +0000 (11:33 +0300)]
arc: Update NEWS files
Add ARCv3 support in NEWS files.
Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Update arc's gas tests
The disassembler can recognize the alternative register names ILINK1
and ILINK2. Update tests.
gas/testsuite/gas/arc
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* gas/testsuite/gas/arc/adc.d: Update ILINK1/INLINK2 reg names.
* gas/testsuite/gas/arc/add.d: Likewise.
* gas/testsuite/gas/arc/and.d: Likewise.
* gas/testsuite/gas/arc/asl.d: Likewise.
* gas/testsuite/gas/arc/asr.d: Likewise.
* gas/testsuite/gas/arc/bic.d: Likewise.
* gas/testsuite/gas/arc/lsr.d: Likewise.
* gas/testsuite/gas/arc/nps400-1.d: Likewise.
* gas/testsuite/gas/arc/or.d: Likewise.
* gas/testsuite/gas/arc/ror.d: Likewise.
* gas/testsuite/gas/arc/sbc.d: Likewise.
* gas/testsuite/gas/arc/sub.d: Likewise.
* gas/testsuite/gas/arc/textinsn3op.d: Likewise.
* gas/testsuite/gas/arc/warn.exp: Update predicate.
* gas/testsuite/gas/arc/arc.exp: Likewise.
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: New ARCv3 ISA instruction table
opcodes/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* opcodes/arc64-tbl.h: New file.
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Add new opcode functions for ARCv3 ISA.
opcodes/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
Cupertino Miranda <cmiranda@synopsys.com>
* opcodes/Makefile.am: Add ARC64 opcode file.
* opcodes/Makefile.in: Regenerate.
* opcodes/arc-opc.c: Move the common functionality to
arcxx-opc.inc. Keep only ARCv2 ARCv1 specifics.
* opcodes/arc-ext-tbl.h: Deleted file.
* opcodes/arcxx-opc.inc: New file.
* opcodes/arc64-opc.c: Likewise.
* opcodes/arc-fxi.h (insert_uimm9_a32_11_s): New function.
(extract_uimm9_a32_11_s): Likewise.
(insert_uimm10_13_s): Likewise.
(extract_uimm10_13_s): Likewise.
* opcodes/configure: Regenerate.
* opcodes/configure.ac: Add ARC64 target.
* opcodes/disassemble.c: Likewise.
* opcodes/arc-dis.c (regmod_t): New type.
(regmods): New structure.
(fpnames): New strings with fp-regs name.
(REG_PCL, REG_LIMM, REG_LIMM_S, REG_U32, REG_S32): New defines.
(getregname): New function.
(find_format_from_table): Discriminate between signed and unsigned
32bit immediates.
(find_format): Handle extract function for flags.
(arc_insn_length): Update insn lengths to various architectures.
(print_insn_arc): Update printing for various ARC architectures.
* opcodes/arc-flag-classes.def: New file.
* opcodes/arc-flag.def: New file.
* opcodes/arc-operands.def: New file.
* opcodes/arc-regs.h: Changed.
Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Update ARC's Gnu Assembler backend with ARCv3 ISA.
The new Synopsys ARCv3 ISA has a similar instruction format like
the old ARCv1 and ARCv2 ISA. Thus, the ARCv3 addition is using
whatever we have for old ARC processors plus some ARCv3 spcific mods.
To distinguish between various ARC variants, we introduced two new
configure defines named TARGET_ARCv3_32 and TARGET_ARCv3_64 which are
set when we choose either an ARC32 (ARCv3/32) ISA toolchain or an
ARC64 (ARCv3/64) ISA toolchain.
gas/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* gas/config/tc-arc.h: Selectively define default target macros.
* gas/configure.ac: Add ARC64 target.
* gas/configure.tgt: Likewise.
* gas/configure: Regenerate
* gas/config.in: Regenerate.
* gas/config/tc-arc.c (DEFAULT_ARCH): New macro.
(default_arch): New variable.
(md_pseudo_table): Add xword.
(md_shortopts): Only a few options are recognized by the new ARC64
assembler.
(md_longopts): Likewise.
(ARC_CPU_TYPE_A64x): New define.
(ARC_CPU_TYPE_A32x): Likewise.
(cpu_type): New arch field.
(selected_cpu): Update fields.
(arc_opcode_hash_entry_iterator_init): Formating.
(arc_opcode_hash_entry_iterator_next): Likewise.
(arc_select_cpu): Likewise.
(arc_option): Likewise.
(check_cpu_feature): Likewise.
(debug_exp): Recognize new expression operands.
(parse_reloc_symbol): Parse new signed/unsigend cases.
(parse_opcode_flags): Update for the case when the flags needs
insert/extract functions.
(find_opcode_match): Match new signed/unsigned 32-bit immediates.
(autodetect_attributes): PLT34 only available for ARC64.
(md_assemble): Extend match characters.
(declare_fp_set): New function.
(init_default_arch): Likewise.
(md_begin): Detect and initialize the correct CPU and coresponding
registers.
(md_pcrel_from_section): Add new relocs.
(arc_target_format): New function.
(md_apply_fix): Add new relocs.
(md_parse_option): Update options.
(arc_show_cpu_list): Update with ARC64 cpus.
(md_show_usage): Update messages.
(may_relax_expr): Add PLT34 case.
(assemble_insn): Update for ARC64.
(arc_make_nops): New function.
(arc_handle_align): Refurbish this function, use arc_make_nops.
(tc_arc_fix_adjustable): Update messages.
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Update opcode related include files for ARCv3.
Add new ARCv3 CPUs and required bits to decode/encode ARCv3 ISA
opcodes. Fix 32 bit relocations which were set as signed but should be
bitfield: ARC_32_ME, ARC_GLOB_DAT, ARC_JMP_SLOT, ARC_RELATIVE. Remove
non-ABI relocation ARC_32_ME_S.
include/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
Cupertino Miranda <cupertinomiranda@gmail.com>
Bruno Mauricio <brunoasmauricio@gmail.com>
* include/elf/arc-cpu.def: Add new HS5x and HS6x CPUs.
* include/elf/arc-reloc.def: Add new ARC64 relocations.
* include/elf/arc.h (EF_ARC_CPU_ARC64): New define.
* include/opcode/arc-attrs.h (FEATURE_LIST_NAME): Update predicate.
* include/opcode/arc-func.h: Update formating.
(replace_disp8ls): New function.
(replace_disp9s): Likewise.
(replace_disp6s): Likewise.
(replace_disp7s): Likewise.
(replace_disp12s): Likewise.
* include/opcode/arc.h (ARC_OPCODE_ARC64): New define.
(ARC_OPCODE_ARC32): Likewise.
(ARC_OPERAND_FP): Likewise.
(HARD_FIELDF): Likewise.
(ARC_OPCODE_ARCVx): New macro.
(arc_flag_class): Update structure to hold new extract/insert
functions for flags.
(INSN3OP): Update macro.
(FP_SIZE, TPOF, DPOF, SOPF, COPF, CONVOPS): New enums.
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Add new linker emulation and scripts for ARCv3 ISA.
Add ARCv3's linker bits. Remove obsolete tests.
ld/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* ld/Makefile.am: Add ARC64 targets.
* ld/configure.tgt: Likewise.
* ld/Makefile.in: Regenerate.
* ld/emulparams/arc64elf32.sh: New file.
* ld/emulparams/arc64elf64.sh: Likewise.
* ld/emulparams/arc64linux32.sh: Likewise.
* ld/emulparams/arc64linux64.sh: Likewise.
* ld/scripttempl/elfarc.sc: Update stack and heap definitions.
* ld/testsuite/ld-arc/got-weak.d: Deleted file.
* ld/testsuite/ld-arc/got-weak.s: Likewise.
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Add new ARCv3 ISA to BFD.
The new Synopsys's ARCv3 ISA is capable to run either 64-bit or
32-bit ISA. The new 32-bit ISA is not compatible with the old
Synopsys ARCv1/ARCv2 ISA, however, it retains a lot of common
concepts. Thus, this patch is reusing the old ARC BFD backend and
adds the necessary bits for the new architecture in a similar way as
it is done for RISCV backend.
bfd/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
Cupertino Miranda <cupertinomiranda@gmail.com>
* bfd/Makefile.am: Add ARC64 files.
* bfd/Makefile.in: Regerate.
* bfd/arc-got.h (TCB_SIZE): Depends on the target architecture.
(GOT_ENTRY_SIZE): New define.
(write_in_got): Likewise.
(read_from_got): Likewise.
(align_power): Likewise.
(arc_got_entry_type_for_reloc): Use RELA_SIZE and GOT_ENTRY_SIZE.
(arc_fill_got_info_for_reloc): Update formating.
(relocate_fix_got_relocs_for_got_info): Likewise.
(arc_static_sym_data): Deleted structure.
(get_static_sym_data): Deleted function.
(relocate_fix_got_relocs_for_got_info): Use symbol static data.
(create_got_dynrelocs_for_single_entry): Update formating.
(create_got_dynrelocs_for_got_info): Likewise.
* bfd/arc-plt.c: New file.
* bfd/arc-plt.def: Add ARC64 PLT entry.
* bfd/arc-plt.h: Clean it up, move functionality to arc-plt.c file.
* bfd/archures.c: Add ARC64 target.
* bfd/config.bfd: Likewise.
* bfd/configure.ac: Likewise.
* bfd/bfd-in2.h: Regenerate.
* bfd/configure: Likewise.
* bfd/libbfd.h: Likewise.
* bfd/cpu-arc.c: Clean it up.
* bfd/cpu-arc64.c: New file.
* bfd/elf32-arc.c: Renamed to elfnn-arc.c.
* bfd/elfnn-arc.c: New file.
* bfd/reloc.c: Add new ARC64 relocs.
* bfd/targets.c: Add ARC64 target.
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Add new LD tests for ARCv3.
Add new linker tests for ARCv3 ISA. All the new tests are added in a
distinct new folder named arc64.
ld/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* ld/testsuite/ld-arc64/arcv3_64-reloc-near-exe.dd: New file.
* ld/testsuite/ld-arc64/arcv3_64-reloc-near-so.dd: Likewise.
* ld/testsuite/ld-arc64/arcv3_64-reloc-near.s: Likewise.
* ld/testsuite/ld-arc64/arcv3_64.exp: Likewise.
* ld/testsuite/ld-arc64/bl34.dd: Likewise.
* ld/testsuite/ld-arc64/bl34.s: Likewise.
* ld/testsuite/ld-arc64/linkscript.ld: Likewise.
* ld/testsuite/ld-arc64/plt34-got.dd: Likewise.
* ld/testsuite/ld-arc64/plt34-got.s: Likewise.
* ld/testsuite/ld-arc64/plt34-reloc.dd: Likewise.
* ld/testsuite/ld-arc64/plt34-reloc.s: Likewise.
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Add new GAS tests for ARCv3.
Add new assembler tests for ARCv3 ISA. All the new tests are added in
a distinct folder named arc64.
gas/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* gas/testsuite/gas/arc64/arc64.exp: New file.
* gas/testsuite/gas/arc64/float01.d: Likewise.
* gas/testsuite/gas/arc64/float01.s: Likewise.
* gas/testsuite/gas/arc64/ldd.d: Likewise.
* gas/testsuite/gas/arc64/ldd.s: Likewise.
* gas/testsuite/gas/arc64/lddl.d: Likewise.
* gas/testsuite/gas/arc64/lddl.s: Likewise.
* gas/testsuite/gas/arc64/load.d: Likewise.
* gas/testsuite/gas/arc64/load.s: Likewise.
* gas/testsuite/gas/arc64/st.d: Likewise.
* gas/testsuite/gas/arc64/st.s: Likewise.
* gas/testsuite/gas/arc64/std.d: Likewise.
* gas/testsuite/gas/arc64/std.s: Likewise.
* gas/testsuite/gas/arc64/stdl.d: Likewise.
* gas/testsuite/gas/arc64/stdl.s: Likewise.
* gas/testsuite/gas/arc64/stl.d: Likewise.
* gas/testsuite/gas/arc64/stl.s: Likewise.
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
Claudiu Zissulescu [Mon, 25 Sep 2023 07:32:52 +0000 (10:32 +0300)]
arc: Update binutils arc predicate for tests.
binutils/testsuite/binutils-all
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* binutils/testsuite/binutils-all/arc/objdump.exp: Update predicate.
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>