]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
17 months agobinutils: Fix calloc argument order in srconv.c
Mark Wielaard [Sun, 21 Jan 2024 23:47:46 +0000 (00:47 +0100)] 
binutils: Fix calloc argument order in srconv.c

GCC 14 will warn about calling calloc with swapped size and count
arguments.

binutils/srconv.c: In function ‘nints’:
binutils/srconv.c:598:36: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  598 |   return (int *) (xcalloc (sizeof (int), x));
      |                                    ^~~
binutils/srconv.c:598:36: note: earlier argument should specify number of elements, later size of each element

binutils/

* srconv.c (nints): Swap xcalloc arguments.
(wr_du): Likewise.
(wr_dus): Likewise.

17 months agobinutils: Fix calloc argument order in coffgrok.c
Mark Wielaard [Sun, 21 Jan 2024 23:36:09 +0000 (00:36 +0100)] 
binutils: Fix calloc argument order in coffgrok.c

GCC 14 will warn about calling calloc with swapped size and count
arguments.

binutils-gdb/binutils/coffgrok.c: In function ‘do_sections_p1’:
binutils-gdb/binutils/coffgrok.c:116:72: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  116 |   struct coff_section *all = (struct coff_section *) (xcalloc (sizeof (struct coff_section),
      |                                                                        ^~~~~~
binutils-gdb/binutils/coffgrok.c:116:72: note: earlier argument should specify number of elements, later size of each element

binutils/

* coffgrok.c (empty_scope): Swap xcalloc arguments.
(empty_symbol): Likewise.
(do_lines): Likewise.
(doit): Likewise.
(coff_grok): Likewise.

17 months agolibsframe: Fix calloc argument order in dump_sframe_header
Mark Wielaard [Sun, 21 Jan 2024 23:12:45 +0000 (00:12 +0100)] 
libsframe: Fix calloc argument order in dump_sframe_header

GCC14 warns about the order of the arguments to calloc

libsframe/sframe-dump.c: In function ‘dump_sframe_header’:
libsframe/sframe-dump.c:70:39: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
   70 |   flags_str = (char*) calloc (sizeof (char), SFRAME_HEADER_FLAGS_STR_MAX_LEN);
      |                                       ^~~~
libsframe/sframe-dump.c:70:39: note: earlier argument should specify number of elements, later size of each element

Fix this by swapping the size and count arguments.

libsframe/

* sframe-dump.c (dump_sframe_header): Swap arguments to calloc

17 months agoopcodes: tic4x_disassemble swap xcalloc arguments
Mark Wielaard [Sun, 21 Jan 2024 20:51:26 +0000 (21:51 +0100)] 
opcodes: tic4x_disassemble swap xcalloc arguments

GCC 14 will detect when the size and count arguments of calloc are
swapped.

binutils-gdb/opcodes/tic4x-dis.c: In function ‘tic4x_disassemble’:
binutils-gdb/opcodes/tic4x-dis.c:710:32: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  710 |       optab = xcalloc (sizeof (tic4x_inst_t *), (1 << TIC4X_HASH_SIZE));
      |                                ^~~~~~~~~~~~
binutils-gdb/opcodes/tic4x-dis.c:710:32: note: earlier argument should specify number of elements, later size of each element
binutils-gdb/opcodes/tic4x-dis.c:712:40: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  712 |       optab_special = xcalloc (sizeof (tic4x_inst_t *), TIC4X_SPESOP_SIZE);
      |                                        ^~~~~~~~~~~~
binutils-gdb/opcodes/tic4x-dis.c:712:40: note: earlier argument should specify number of elements, later size of each element

opcodes/ChangeLog:

* /tic4x-dis.c (tic4x_disassemble): Swap size and count xcalloc
arguments.

17 months agoHandle EOF more gracefully in DAP
Tom Tromey [Wed, 10 Jan 2024 19:51:10 +0000 (12:51 -0700)] 
Handle EOF more gracefully in DAP

A user pointed out that gdb will print a Python exception when it gets
an EOF in DAP mode.  And, it turns out that an EOF like this also
causes gdb not to exit.  This is due to the refactoring that moved the
JSON reader to its own thread -- previously this caused an exception
to propagate and cause an exit, but now it just leaves the reader
hung.

This patch fixes these problems by arranging to handle EOF more
gracefully.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31217

17 months agoFix handling of DW_OP_GNU_push_tls_address
Tom Tromey [Wed, 17 Jan 2024 11:29:59 +0000 (04:29 -0700)] 
Fix handling of DW_OP_GNU_push_tls_address

In one spot, DW_OP_GNU_push_tls_address is handled differently from
DW_OP_form_tls_address.  However, I think they should always be
treated identically.

Approved-by: Kevin Buettner <kevinb@redhat.com>
17 months agosim: Fix -Werror=shadow=local by changing mem to addr in sim_{read,write}
Mark Wielaard [Mon, 22 Jan 2024 11:58:11 +0000 (12:58 +0100)] 
sim: Fix -Werror=shadow=local by changing mem to addr in sim_{read,write}

m32c/cpu.h defines mem as enum value, which causes GCC 14 to emit

sim/m32c/gdb-if.c: In function ‘sim_read’:
sim/m32c/gdb-if.c:162:33: error: declaration of ‘mem’ shadows a previous local [-Werror=shadow=local]
  162 | sim_read (SIM_DESC sd, uint64_t mem, void *buf, uint64_t length)
      |                        ~~~~~~~~~^~~
In file included from ../../binutils-gdb/sim/m32c/gdb-if.c:38:
sim/m32c/cpu.h:83:3: note: shadowed declaration is here
   83 |   mem,
      |   ^~~

Fix this by renaming mem to addr in all sim_read and sim_write functions.
Most already used addr instead of mem. In one file, sim/rx/gdb-if.c, this
also meant renaming the local addr variable to vma.

17 months agosim: Fix some -Werror=shadow=compatible-local issues in aarch64/simulator.c
Mark Wielaard [Sun, 21 Jan 2024 22:47:35 +0000 (23:47 +0100)] 
sim: Fix some -Werror=shadow=compatible-local issues in aarch64/simulator.c

With GCC 14 -Werror=shadow=compatible-local flags the reuse of single
capital letters used in aarch64/cpustate.h enums

   88 | expand_logical_immediate (uint32_t S, uint32_t R, uint32_t N)
      |                                                   ~~~~~~~~~^
In file included from ../../binutils-gdb/sim/aarch64/aarch64-sim.h:27,
                 from ../../binutils-gdb/sim/aarch64/simulator.c:33:
  217 |   N = 1 << N_IDX
      |   ^

sim/aarch64/simulator.c: In function ‘expand_logical_immediate’:
sim/aarch64/simulator.c:88:60: error: declaration of ‘N’ shadows a previous local [-Werror=shadow=compatible-local]
sim/aarch64/cpustate.h:217:3: note: shadowed declaration is here

17 months agosim: Fix cc -Werror=shadow=local in cr16/simops.c
Mark Wielaard [Sun, 21 Jan 2024 22:52:50 +0000 (23:52 +0100)] 
sim: Fix cc -Werror=shadow=local in cr16/simops.c

include/opcode/cr16.h defines cc as an enum value, which causes GCC 14
to warn

sim/cr16/simops.c: In function ‘cond_stat’:
sim/cr16/simops.c:138:26: error: declaration of ‘cc’ shadows a previous local [-Werror=shadow=local]
  138 | static int cond_stat(int cc)
      |                      ~~~~^~
In file included from ../../binutils-gdb/sim/cr16/cr16-sim.h:26,
                 from ../../binutils-gdb/sim/cr16/simops.c:39:
sim/../include/opcode/cr16.h:149:3: note: shadowed declaration is here
  149 |   cc,
      |   ^~

Fix this by renaming cc in cr16/simops.c to cond.

17 months agogdb/testsuite: relax filename restriction in some gdb.btrace tests
Guinevere Larsen [Thu, 14 Dec 2023 09:52:29 +0000 (10:52 +0100)] 
gdb/testsuite: relax filename restriction in some gdb.btrace tests

The test gdb.btrace/tailcall.exp has multiple tests that include the
filename in the output. When testing with gcc, only a relative path is
printed, but when using clang, the full file path is printed instead.
This makes most of those tests fail, with the exception of "record goto
4" which allows for more characters before the file name. The test
gdb.btrace/recod_goto.exp suffers with the same issue

This commit allows for text before the filename. However, instead of how
the aforementioned "record goto 4", it uses a regexp that doesn't allow
for newlines, just in case some off output happens.

Approved-By: Tom Tromey <tom@tromey.com>
17 months agogdb/testsuite: modernize gdb.dwarf2/dw2-noloc.exp
Guinevere Larsen [Wed, 20 Dec 2023 11:46:42 +0000 (12:46 +0100)] 
gdb/testsuite: modernize gdb.dwarf2/dw2-noloc.exp

The test gdb.dwarf2/dw2-noloc.exp predates the dwarf assembler, and uses
some unreliable assumptions about where global labels get put.
Specifically, when using clang to compile the test, both labels it uses
to gauge the adresses of the main function get reshuffled to be side-by-side,
and the debug information ends up making it look like main's high pc is equal
to low pc, meaning we never enter the main function's scope, and that leads to
22 failures because the "main_*" variables are technically never in scope.

This patch modernizes the aforementioned test to use the dwarf
assembler, which removes all failures when using clang.  It also renames
the .c file to be more inline with current standard.

Approved-By: Tom Tromey <tom@tromey.com>
17 months agoLoongArch: Fix some test failures about TLS desc and TLS relaxation
Xi Ruoyao [Fri, 19 Jan 2024 16:38:24 +0000 (00:38 +0800)] 
LoongArch: Fix some test failures about TLS desc and TLS relaxation

There are two issues causing 11 test failures:

1. The TLS desc tests are matching the entire disassemble of a linked
   executable.  But if ld is configured --enable-default-hash-style=gnu
   (note that most modern distros use this option), the layout of the
   linked executables will be different and the immediate operands in
   the linked executables will also be different.  So we add
   "--hash-style=both" for these tests to cancel the effect of
   --enable-default-hash-style=gnu, like [x86_64 mark-plt tests].
2. By default objdump disassemble uses [pseudo-instructions] so "addi.w"
   is outputed as "li.w", causing mismatches in TLS relaxation tests.
   We can turn off the pseudo-instruction usage in objdump using "-M
   no-aliases" to fix them.

[x86_64 mark-plt tests]: 16666ccc91295d1568c5c2cb0e7600694840dfd9
[pseudo-instructions]: 17f9439038257b1de0c130a416a9a7645c653cb0

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
17 months agoLoongArch: Do not add DF_STATIC_TLS for TLS LE
Tatsuyuki Ishi [Thu, 28 Dec 2023 14:58:00 +0000 (23:58 +0900)] 
LoongArch: Do not add DF_STATIC_TLS for TLS LE

TLS LE is exclusively for executables, while DF_STATIC_TLS is for DLLs.
DF_STATIC_TLS should only be set for TLS IE (and when it's DLL), not LE.

17 months agoLoongArch: Use tab to indent assembly in TLSDESC test suite
Tatsuyuki Ishi [Thu, 28 Dec 2023 14:58:01 +0000 (23:58 +0900)] 
LoongArch: Use tab to indent assembly in TLSDESC test suite

The usual convention is to use tabs. Not all test are following this,
but at least when using tabs, let's use it consistently throughout the
file.

17 months agox86/APX: also amend the PUSH2/POP2 testcase
Jan Beulich [Mon, 22 Jan 2024 07:52:30 +0000 (08:52 +0100)] 
x86/APX: also amend the PUSH2/POP2 testcase

Commit f530d5f1bab6 ("Update x86/APX: VROUND{P,S}{S,D} can generally be
encoded") took care of only half of the remaining issue. Add #pass here
as well.

17 months agoAutomatic date update in version.in
GDB Administrator [Mon, 22 Jan 2024 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

17 months agogdb/infrun: lazily load curr_frame_id in process_event_stop_test
Lancelot SIX [Thu, 28 Dec 2023 11:51:31 +0000 (11:51 +0000)] 
gdb/infrun: lazily load curr_frame_id in process_event_stop_test

A recent(ish) change in gdb/infrun.c made process_event_stop_test load
debug information where it would not have done so previously.  The
change is:

    commit bf2813aff8f2988ad3d53e819a0415abf295c91f
    AuthorDate: Fri Sep 1 13:47:32 2023 +0200
    CommitDate: Mon Nov 20 10:54:03 2023 +0100

        gdb/record: print frame information when exiting a recursive call

        Currently,  when GDB is reverse stepping out of a function into the same
        function due to a recursive call, it doesn't print frame information, as
        reported by PR record/29178. This happens because when the inferior
        leaves the current frame, GDB decides to refresh the step information,
        clobbering the original step_frame_id, making it impossible to figure
        out later on that the frame has been changed.

        This commit changes GDB so that, if we notice we're in this exact
        situation, we won't refresh the step information.

        Because of implementation details, this change can cause some debug
        information to be read when it normally wouldn't before, which showed up
        as a regression on gdb.dwarf2/dw2-out-of-range-end-of-seq. Since that
        isn't a problem, the test was changed to allow for the new output.

        Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29178

Although there is nothing wrong with this change in principle, it
happens to break most of the tests in gdb/testsuite/gdb.rocm/*.exp.
This is because those tests do rely on GDB not loading debug
information.  This is necessary because the debug information produced
for AMDGPU code is using DWARF extensions which are not supported by GDB
at this point.

In this patch, I propose to use a lazy loading mechanism so the frame_id
for the current frame is only computed when required instead of when
entering process_event_stop_test.  The lazy_loader class is currently
defined locally in infrun.c, but if it turns out to be useful elsewhere,
it could go somewhere under gdbsupport.

This patch should restore the behavior GDB had before
bf2813aff8f2988ad3d53e819a0415abf295c91f when it comes to load debug
info.

Another approach could have been to revert
fb84fbf8a51f5be2e78765508ebd9753af96b492 (gdb/infrun: simplify
process_event_stop_test) and adjust the implementation of
bf2813aff8f2988ad3d53e819a0415abf295c91f (gdb/record: print frame
information when exiting a recursive call).  However, I think that the
lazy loading works well with the simplification done recently, so I went
down that route.

Regression tested on x86_64-linux (Ubuntu 22.04) with AMDGPU support.

Change-Id: Ib63a162128130d1786a77c98623e9e3dcbc363b7
Approved-by: Kevin Buettner <kevinb@redhat.com>
17 months agoLoongArch: Do not emit R_LARCH_RELAX for two register macros
mengqinggang [Wed, 10 Jan 2024 01:55:13 +0000 (09:55 +0800)] 
LoongArch: Do not emit R_LARCH_RELAX for two register macros

For two register macros (e.g. la.local $t0, $t1, symbol) used in extreme code
model, do not emit R_LARCH_RELAX relocations.

17 months agoAutomatic date update in version.in
GDB Administrator [Sun, 21 Jan 2024 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

17 months agogdb: remove SYMBOL_*_OPS macros
Simon Marchi [Fri, 19 Jan 2024 20:32:32 +0000 (15:32 -0500)] 
gdb: remove SYMBOL_*_OPS macros

Remove SYMBOL_BLOCK_OPS, SYMBOL_COMPUTED_OPS and SYMBOL_REGISTER_OPS, in
favor of methods on struct symbol.  More changes could be done here to
improve the design and make things safer, but I just wanted to do a
straightforward change to remove the macros for now.

Change-Id: I27adb74a28ea3c0dc9a85c2953413437cd95ad21
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
17 months agoSimplify DWARF symtab inclusion handling
Tom Tromey [Mon, 15 Jan 2024 01:21:42 +0000 (18:21 -0700)] 
Simplify DWARF symtab inclusion handling

In the past, dwarf2_per_cu_data was allocated using malloc, so special
handling was needed for the vector used for symtab handling.  We
changed this to use 'new' a while back, so this code can now be
greatly simplified.

Regression tested on x86-64 Fedora 38.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoAutomatic date update in version.in
GDB Administrator [Sat, 20 Jan 2024 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

17 months agogdb: remove deprecated_exec_file_display_hook and associated code
Andrew Burgess [Fri, 29 Dec 2023 09:50:10 +0000 (09:50 +0000)] 
gdb: remove deprecated_exec_file_display_hook and associated code

This commit removes deprecated_exec_file_display_hook and the
associated specify_exec_file_hook.

The specify_exec_file_hook is used to add a new hook function to
deprecated_exec_file_display_hook, but is only used from the insight
debugger.

I posted a patch to remove the use of specify_exec_file_hook from
insight, and instead use gdb::observers::executable_changed, this
patch can be found here (it has now been merged):

  https://inbox.sourceware.org/insight/6abeb45e97d9004ec331e94cf2089af00553de76.1702379379.git.aburgess@redhat.com/T/#u

With this merged we can now cleanup the GDB side as this code is now
unused.

There should be no user visible changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
17 months agoFix remote serial read
Сергей Чернов [Fri, 19 Jan 2024 18:01:18 +0000 (11:01 -0700)] 
Fix remote serial read

After closing "Bug 30770 - serial.c does not preserve errno correctly"
https://sourceware.org/bugzilla/show_bug.cgi?id=30770
remote debugging became impossible due to an attempt to recv() by a call intended for the socket, and not for the character device file. The
documentation implicitly states that it is possible to use the read() call to work with a socket. But this does not mean in the general case that it is
permissible to use recv in the case of a non-socket.

condition:
os: Distributor ID:    Ubuntu
Description:    Ubuntu 23.10
Release:    23.10
Codename:    mantic

libc:
ldd (Ubuntu GLIBC 2.38-1ubuntu6) 2.38
kernel:
Linux klen-dev-um790pro 6.5.0-14-generic #14-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 14 14:59:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
gdb: build from trank at 15.0.50.20231226-git

GDB output:
$ arm-kgp-eabi-gdb
GNU gdb (Klen's_GNU_package_(KGP)_for_target::arm-kgp-eabi<rmprofile/lto>_host::x86_64-kgp-linux-gnu_znver4-avx512<<ílex>>)
15.0.50.20231226-git
....
(gdb) tar ext /dev/ttyACM1
Remote debugging using /dev/ttyACM1
Remote communication error.  Target disconnected: error while reading: Socket operation on non-socket.
(gdb)

after fix gdb work fine

$ arm-kgp-eabi-gdb -q
(gdb) tar ext /dev/ttyACM0
Remote debugging using /dev/ttyACM0
(gdb) mon swd
Target voltage: 0.0V
Available Targets:
No. Att Driver
       STM32F40x M4
(gdb) att 1
Attaching to Remote target
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
0x08020c80 in ?? ()
(gdb)

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30770

17 months agogdb/ui-out.h: Fix exception handling in do_with_buffered_output
Aaron Merey [Fri, 19 Jan 2024 16:20:19 +0000 (11:20 -0500)] 
gdb/ui-out.h: Fix exception handling in do_with_buffered_output

Replace throw with throw_exeception in do_with_buffered_output.

This patch fixes regressions in gdb.dwarf2/dw2-dir-file-name.exp
caused by commit 519d63439.

do_with_buffered_output needs to use throw_exception instead of
throw to ensure that exceptions of the correct type are thrown.
If using throw, gdb_exception_error may be wrongly converted into
gdb_exception during print_frame_info.  This prevents the exception
from being caught in print_stack_frame.

17 months ago[gdb/testsuite] Update xfail in gdb.threads/attach-many-short-lived-threads.exp
Tom de Vries [Fri, 19 Jan 2024 16:40:03 +0000 (17:40 +0100)] 
[gdb/testsuite] Update xfail in gdb.threads/attach-many-short-lived-threads.exp

With test-case gdb.threads/attach-many-short-lived-threads.exp, I run into:
...
(gdb) attach 7773^M
Attaching to program: attach-many-short-lived-threads, process 7773^M
Cannot attach to lwp 7776: Operation not permitted (1)^M
(gdb) PASS: $exp: iter 1: attach
info threads^M
No threads.^M
(gdb) PASS: $exp: iter 1: no new threads
set breakpoint always-inserted on^M
(gdb) PASS: $exp: iter 1: set breakpoint always-inserted on
break break_fn^M
Breakpoint 1 at 0x400b4d: file attach-many-short-lived-threads.c, line 57.^M
(gdb) PASS: $exp: iter 1: break break_fn
continue^M
The program is not being run.^M
(gdb) FAIL: $exp: iter 1: break at break_fn: 1 \
  (the program is no longer running)
...

There's some code in the test-case dealing with a similar warning:
...
  -re "warning: Cannot attach to lwp $decimal: Operation not permitted" {
...

But since commit c6f7f9c80c3 ("Bail out of "attach" if a thread cannot be
traced"), the warning has been changed into an error.

Fix the FAIL by updating the test-case to expect an error instead of a
warning.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
17 months agogdb: remove unnecessary NULL checks for return value of value_from_register
Simon Marchi [Fri, 19 Jan 2024 15:35:37 +0000 (10:35 -0500)] 
gdb: remove unnecessary NULL checks for return value of value_from_register

value_from_register can't return nullptr, remove some NULL checks.

Change-Id: Ia6b32b8f86e593c535e3678a89dffe5544eb7ab0
Approved-By: Tom Tromey <tom@tromey.com>
17 months agold: Remove scripttempl/elf_chaos.sc
H.J. Lu [Fri, 19 Jan 2024 16:05:49 +0000 (08:05 -0800)] 
ld: Remove scripttempl/elf_chaos.sc

scripttempl/elf_chaos.sc is unused.  Remove it.

* scripttempl/elf_chaos.sc: Removed.

17 months agoRemove hosts/mipsbsd.h and scripttempl/mipsbsd.sc
H.J. Lu [Fri, 19 Jan 2024 15:15:30 +0000 (07:15 -0800)] 
Remove hosts/mipsbsd.h and scripttempl/mipsbsd.sc

Remove hosts/mipsbsd.h and scripttempl/mipsbsd.sc which are unused
after

commit 3596d8ceb2cdc35b4fd702ee9daace5a2d880174
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Apr 18 15:39:34 2018 +0930

    Remove mips aout, coff, and pe support

bfd/

* hosts/mipsbsd.h: Removed.

ld/

* scripttempl/mipsbsd.sc: Removed.

17 months agold: fix 32-bit mingw DLL symbol export bug
Oleg Tolmatcev [Fri, 19 Jan 2024 15:02:45 +0000 (15:02 +0000)] 
ld: fix 32-bit mingw DLL symbol export bug

I think there's a bug in ld on 32-bit Windows.  Here is a tiny project for reproducing the problem:
https://github.com/oltolm/ld-mingw32-bug

A 32-bit DLL exports two stdcall functions "myfunc" and "myfunc64". The functions would normally get
exported as "myfunc@0" and "myfunc64@0". The "DEF" file exports them as "myfunc" and "myfunc64"
without the decorations. When you run the executable it shows an error message saying that it cannot
find "myfunc64".

I think it happens because the sorting in ld is wrong. I think it should use the exported names
"myfunc" and "myfunc64", but instead it uses the decorated names "myfunc@0" or "myfunc65@0". The
ordering of functions in the DLL is different depending on which names you use.

My patch changes ld to use undecorated exported names for sorting and it seems to fix the problem.
When I execute ctest in my project, it runs successfully.

17 months agoUpdate x86/APX: VROUND{P,S}{S,D} can generally be encoded
H.J. Lu [Fri, 19 Jan 2024 14:42:20 +0000 (06:42 -0800)] 
Update x86/APX: VROUND{P,S}{S,D} can generally be encoded

Append "#pass" to APX tests for targets which pad text sections with NOPs.

* testsuite/gas/i386/x86-64-apx-evex-promoted-intel.d: Append
"#pass".
* testsuite/gas/i386/x86-64-apx-evex-promoted.d: Likewise.

17 months agoUpdate readelf's and objdump's debug frame displaying feature to include the contents...
Nick Clifton [Fri, 19 Jan 2024 14:39:08 +0000 (14:39 +0000)] 
Update readelf's and objdump's debug frame displaying feature to include the contents of the .eh_frame_hdr section, if present.

17 months agold: Put all emulation options in ldlex.h
H.J. Lu [Wed, 17 Jan 2024 15:46:37 +0000 (07:46 -0800)] 
ld: Put all emulation options in ldlex.h

For each command line option, parse_args() calls ldemul_parse_args()
to check if the command line option is an emulation option.  But when
there is a conflict between the emulation option value and the default
option value, the default command line option will be processed as if
the emulation option is used.  Remove PARSE_AND_LIST_PROLOGUE and move
all emulation options to ldlex.h to avoid conflicts.

PR ld/31247
* ldlex.h (option_values): Add all emulation options.
* emulparams/elf32mcore.sh (PARSE_AND_LIST_PROLOGUE): Removed.
* emulparams/plt_unwind.sh (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/aarch64elf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/alphaelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/armelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/avrelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/bfin.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/cskyelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/hppaelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/ia64elf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/m68hc1xelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/m68kelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/metagelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/mipself.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/nds32elf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/nto.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/ppc32elf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/ppc64elf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/riscvelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/rxelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/s390.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/scoreelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/spuelf.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/tic6xdsbt.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/vxworks.em (PARSE_AND_LIST_PROLOGUE): Likewise.
* emultempl/aix.em: Include "ldlex.h".
(OPTION_XXX): Removed.
(gld${EMULATION_NAME}_read_file): Replace lineno with linenumber.
* emultempl/beos.em (OPTION_XXX): Removed.
* emultempl/elf.em: Include "ldlex.h".
Don't check PARSE_AND_LIST_PROLOGUE.
(OPTION_XXX): Removed.
* emultempl/msp430.em: Include "ldlex.h".
(OPTION_XXX): Removed.
* emultempl/pe.em (OPTION_XXX): Removed.
* emultempl/pep.em (OPTION_XXX): Likewise.
* emultempl/ticoff.em: Include "ldlex.h".
(OPTION_XXX): Removed.
* emultempl/vms.em: Include "ldlex.h".
(OPTION_XXX): Removed.
* emultempl/xtensaelf.em (elf32xtensa_size_opt,
elf32xtensa_no_literal_movement, elf32xtensa_abi): Moved out of
PARSE_AND_LIST_PROLOGUE.
(PARSE_AND_LIST_PROLOGUE): Removed.

17 months agoAdd multilib.am to the list of top level files included in any release created by...
Nick Clifton [Fri, 19 Jan 2024 11:45:10 +0000 (11:45 +0000)] 
Add multilib.am to the list of top level files included in any release created by the src-release.sh script

17 months agox86-64: Dwarf2 register numbers for %bnd<N>
Jan Beulich [Fri, 19 Jan 2024 09:19:15 +0000 (10:19 +0100)] 
x86-64: Dwarf2 register numbers for %bnd<N>

I don't see why we shouldn't record them when they have been allocated,
even if they're (bogusly) named as reserved in the ABI right now.

17 months agox86/APX: VROUND{P,S}{S,D} can generally be encoded
Jan Beulich [Fri, 19 Jan 2024 09:18:32 +0000 (10:18 +0100)] 
x86/APX: VROUND{P,S}{S,D} can generally be encoded

VRNDSCALE{P,S}{S,D} is the AVX512 generalization of these AVX insns. As
long as the immediate has the top 4 bits clear, they are equivalent to
the earlier VEX-encoded insns, and hence can be used to permit use of
eGPR-s in the memory operand. Since this is the normal way of using
these insns, also alter the resulting diagnostic to complain about the
immediate, not the eGPR use.

17 months agox86/APX: be consistent with insn suffixes
Jan Beulich [Fri, 19 Jan 2024 09:17:44 +0000 (10:17 +0100)] 
x86/APX: be consistent with insn suffixes

When there's a suitably disambiguating register operand, suffixes are
generally omitted (unless in suffix-always mode). All NDD insns have a
suitable register operand, so they shouldn't have suffixes by default.

17 months agox86: drop redundant EVex128 from PUSH2/POP2
Jan Beulich [Fri, 19 Jan 2024 09:16:28 +0000 (10:16 +0100)] 
x86: drop redundant EVex128 from PUSH2/POP2

EVexMap4 already covers that.

17 months agox86: support APX forms of U{RD,WR}MSR
Jan Beulich [Fri, 19 Jan 2024 09:16:00 +0000 (10:16 +0100)] 
x86: support APX forms of U{RD,WR}MSR

This was missed in 6177c84d5edc ("Support APX GPR32 with extend evex
prefix").

17 months agogdb: Buffer output streams during events that might download debuginfo
Aaron Merey [Fri, 12 Jan 2024 19:38:45 +0000 (14:38 -0500)] 
gdb: Buffer output streams during events that might download debuginfo

Introduce new ui_file buffering_file to temporarily collect output
written to gdb_std* output streams during print_thread, print_frame_info
and print_stop_event.

This ensures that output during these functions is not interrupted
by debuginfod progress messages.

With the addition of deferred debuginfo downloading it is possible
for download progress messages to print during these events.
Without any intervention we can end up with poorly formatted output:

    (gdb) backtrace
    [...]
    #8  0x00007fbe8af7d7cf in pygi_invoke_c_callable (Downloading separate debug info for /lib64/libpython3.11.so.1.0
    function_cache=0x561221b224d0, state=<optimized out>...

To fix this we buffer writes to gdb_std* output streams while allowing
debuginfod progress messages to skip the buffers and print to the
underlying output streams immediately.  Buffered output is then written
to the output streams.  This ensures that progress messages print first,
followed by uninterrupted frame/thread/stop info:

    (gdb) backtrace
    [...]
    Downloading separate debug info for /lib64/libpython3.11.so.1.0
    #8  0x00007fbe8af7d7cf in pygi_invoke_c_callable (function_cache=0x561221b224d0, state=<optimized out>...

Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
17 months agoAutomatic date update in version.in
GDB Administrator [Fri, 19 Jan 2024 00:00:54 +0000 (00:00 +0000)] 
Automatic date update in version.in

17 months agoRewrite .debug_names writer
Tom Tromey [Mon, 4 Dec 2023 01:20:37 +0000 (18:20 -0700)] 
Rewrite .debug_names writer

This rewrites GDB's .debug_names writer.  It is now closer to the form
imagined in the DWARF spec.  In particular, names are emitted exactly
as they appear in the original DWARF.

In order to make the reader work nicely, some extensions were needed.
These were all documented in an earlier patch.  Note that in
particular this writer solves the "main name" problem by putting a
flag into the table.

GDB does not use the .debug_names hash table, so it also does not
write one.  I consider this hash table to be essentially useless in
general, due to the name canonicalization problem -- while DWARF says
that writers should use the system demangling style, (1) this style
varies across systems, so it can't truly be relied on; and (2) at
least GCC and one other compiler don't actually follow this part of
the spec anyway.

It's important to note, though, that even if the hash was somehow
useful, GDB probably still would not use it -- a sorted list of names
is needed for completion and performs reasonably well for other
lookups, so a hash table is just overhead, IMO.

String emission is also simplified.  There's no need in this writer to
ingest the contents of .debug_str.

A couple of tests are updated to reflect the fact that they now "fail"
because the tests don't include .debug_aranges in the .S file.
Arguably the .debug_names writer should also create this section; but
I did not implement that in this series, and there is a separate bug
about it.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24820
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24549

17 months agoExport dwarf5_augmentation
Tom Tromey [Sun, 3 Dec 2023 22:05:35 +0000 (15:05 -0700)] 
Export dwarf5_augmentation

I don't know why gdb had the .debug_names augmentation string in two
separate places; this patch exports it in one spot, to be used in
another.

17 months agoRewrite .debug_names reader
Tom Tromey [Sat, 2 Dec 2023 20:18:13 +0000 (13:18 -0700)] 
Rewrite .debug_names reader

This rewrites the .debug_names reader to follow the spec.

Since it was first written, gdb's .debug_names writer has been
incorrect -- while the form of the section has been ok, the contents
have been very gdb-specific.

This patch fixes the reader side of this equation, rewriting the
reader to create a cooked index internally -- an important detail
because it allows for the deletion of a lot of code, and it means the
various readers will agree more often.

This reader checks for a new augmentation string.  For the time being,
all other producers are ignored -- the old GDB ones because they are
wrong, and clang because it does not emit DW_IDX_parent.  (If there
are any other producers, I'm unaware of them.)

While the new reader mostly runs in a worker thread, it does not try
to distribute its work.  This could be done by partitioning the name
table.  The parent computations could also be done in parallel after
all names have been read.  I haven't attempted this.

Note that this patch temporarily regresses gdb.base/gdb-index-err.exp.
This test writes an index using gdb -- but at this particular stage,
gdb cannot read the indexes it creates.  Rather than merge the patches
into a mega-patch, I've chosen to just accept this temporary
regression.

In v1 of this patch, I made the new reader more strict about requiring
.debug_aranges.  In v2, I've backed this out and kept the previous
logic.  This solved a few test failures, though it's arguably not the
right approach.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25950

17 months agoAllow other results in DW_TAG_entry_point test
Tom Tromey [Wed, 17 Jan 2024 16:15:22 +0000 (09:15 -0700)] 
Allow other results in DW_TAG_entry_point test

DW_TAG_entry_point is implemented by adding a new LOC_BLOCK symbol --
that is, another function symbol.  However, the test case assumes that
"bt" will never pick this symbol.

This assumption seems unwarranted to me, and in fact this test will
regress with the debug-names target board after the .debug_names
rewrite.

This patch changes the test to allow either answer in the backtrace.
If only the main entry point is desired, then it seems that more work
must be done to handle DW_TAG_entry_point properly, as nothing
currently guarantees this property.

17 months agoRemove some .debug_names tests
Tom Tromey [Wed, 6 Dec 2023 23:16:55 +0000 (16:16 -0700)] 
Remove some .debug_names tests

These .debug_names tests were hand-written to mimic clang.  However,
they are difficult to update, and in any case the new reader won't
accept clang-generated indices.  Therefore this patch removes these
tests.

17 months agoExplicitly expand CUs in dw2-inline-with-lexical-scope.exp
Tom Tromey [Thu, 7 Dec 2023 19:18:00 +0000 (12:18 -0700)] 
Explicitly expand CUs in dw2-inline-with-lexical-scope.exp

dw2-inline-with-lexical-scope.exp relies on the main CU being
expanded.  However, it doesn't guarantee that this actually happens,
and with the new .debug_names reader, it won't, because the "main"
program will be found in the index without requiring CU expansion.

This patch fixes the problem by explicitly expanding the CU in
question.

Note that this is an artificial bug -- it occurs because the generated
.debug_aranges isn't correct.

17 months agoFix dw2-zero-range.exp when an index is in use
Tom Tromey [Wed, 6 Dec 2023 21:24:08 +0000 (14:24 -0700)] 
Fix dw2-zero-range.exp when an index is in use

dw2-zero-range.exp looks for a certain complaint, but this won't be
issued when an index is in use.  This patch changes the test to not
fail in this case.

17 months agoEmpty hash table fix in .debug_names reader
Tom Tromey [Mon, 4 Dec 2023 14:58:48 +0000 (07:58 -0700)] 
Empty hash table fix in .debug_names reader

The handling of an empty hash table in the .debug_names reader is
slightly wrong.

Currently the code assumes there is always an array of hashes.
However, section 6.1.1.4.5 Hash Lookup Table says:

    The optional hash lookup table immediately follows the list of
    type signatures.

and then:

    The hash lookup table is actually two separate arrays: an array of
    buckets, followed immediately by an array of hashes.

My reading of this is that the hash table as a whole is optional, and
so the hashes will not exist in this case.  (This also makes sense
because the hashes are not useful without the buckets anyway.)

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25950

17 months agoRemove cooked_index_worker::start_reading
Tom Tromey [Sun, 3 Dec 2023 19:40:06 +0000 (12:40 -0700)] 
Remove cooked_index_worker::start_reading

I noticed that cooked_index_worker::start_reading isn't really needed.
This patch removes it, and also removes the SCOPED_EXIT, in favor of a
direct call.

17 months agoChange cooked_index_worker to abstract base class
Tom Tromey [Sun, 3 Dec 2023 19:34:49 +0000 (12:34 -0700)] 
Change cooked_index_worker to abstract base class

This changes cooked_index_worker to be an abstract base class.  The
base class implementation is moved to cooked-index.c, and a concrete
subclass is added to read.c.

This change is preparation for the new .debug_names reader, which will
supply its own concrete implementation of the worker.

17 months agoDo not write the index cache from an index
Tom Tromey [Sun, 3 Dec 2023 19:10:14 +0000 (12:10 -0700)] 
Do not write the index cache from an index

The new .debug_names reader will work by creating a cooked index from
.debug_names.  This patch updates cooked_index::maybe_write_index to
avoid writing the index in this case.

However, in order to do this in a clean way, the readers are changed
so that a nullptr result from index_for_writing means "cannot be
done", and then the error message is moved into write_dwarf_index
(where it historically lived).

17 months agoMove cooked_index_functions to cooked-index.h
Tom Tromey [Wed, 6 Dec 2023 21:35:21 +0000 (14:35 -0700)] 
Move cooked_index_functions to cooked-index.h

This moves the declaration of cooked_index_functions to
cooked-index.h.  This makes it visible for use by the rewritten
.debug_names reader, and it also lets us move the implementation of
make_quick_functions into cooked-index.c, where it really belongs.

17 months agoAdd language to cooked_index_entry
Tom Tromey [Sat, 2 Dec 2023 22:42:42 +0000 (15:42 -0700)] 
Add language to cooked_index_entry

This adds a new 'lang' member to cooked_index_entry.  This holds the
language of the symbol.  This is primarily useful for the new
.debug_names reader, which will not scan the CUs for languages up
front.

This also changes cooked_index_shard::add to return a non-const
pointer.  This doesn't impact the current code, but is needed for the
new reader.

17 months agoDocument GDB extensions to DWARF .debug_names
Tom Tromey [Sun, 3 Dec 2023 20:42:29 +0000 (13:42 -0700)] 
Document GDB extensions to DWARF .debug_names

GDB's new .debug_names implementation uses some extensions.  This
patch adds some documentation on this to the manual.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
17 months agoRemove IS_ENUM_CLASS from cooked_index_flag
Tom Tromey [Sun, 3 Dec 2023 00:19:55 +0000 (17:19 -0700)] 
Remove IS_ENUM_CLASS from cooked_index_flag

I noticed that cooked_index_flag::IS_ENUM_CLASS is not needed.  This
patch removes it.

17 months agoRefactor quick-function installation in DWARF reader
Tom Tromey [Wed, 6 Dec 2023 21:29:40 +0000 (14:29 -0700)] 
Refactor quick-function installation in DWARF reader

While working on the previous patch, I saw that the handling of
quick-function installation could be unified
dwarf2_initialize_objfile.  In particular, at the end of the function,
if there is an index table, then it can be used to create the quick
function object.

This cleanup will be useful when rewriting the .debug_names reader.

17 months agoRefactor 'maint set dwarf synchronous' handling
Tom Tromey [Wed, 6 Dec 2023 15:32:52 +0000 (08:32 -0700)] 
Refactor 'maint set dwarf synchronous' handling

The new .debug_names reader will reuse the background reading
infrastructure of the cooked index code.  In order to share the
handling of 'maint set dwarf synchronous' -- and to avoid having to
export this global -- this patch refactors this to be handled directly
in dwarf2_initialize_objfile.

17 months agoAdd note to translators not to translate z/Architecture
Nick Clifton [Thu, 18 Jan 2024 11:25:48 +0000 (11:25 +0000)] 
Add note to translators not to translate z/Architecture

17 months agoUpdated translations for various sub-directories
Nick Clifton [Thu, 18 Jan 2024 11:23:48 +0000 (11:23 +0000)] 
Updated translations for various sub-directories

17 months ago[gdb/testsuite] Call ldd --version in gdb.testsuite/dump-system-info.exp
Tom de Vries [Thu, 18 Jan 2024 10:14:19 +0000 (11:14 +0100)] 
[gdb/testsuite] Call ldd --version in gdb.testsuite/dump-system-info.exp

Once in a while I'm looking at the gdb.log of an entire testsuite run, and I'm
trying to establish what glibc version is used.  Sometimes this is possible,
sometimes not.

Make this easy by calling ldd --version in test-case
gdb.testsuite/dump-system-info.exp, which for instance on openSUSE Leap 15.4
gives:
...
$ ldd --version
ldd (GNU libc) 2.31
  ...
$
...

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
17 months agosim: ppc: implement 128-bit register read/writes with sim-endian APIs
Mike Frysinger [Thu, 11 Jan 2024 05:44:27 +0000 (00:44 -0500)] 
sim: ppc: implement 128-bit register read/writes with sim-endian APIs

We have APIs in sim-endian for working with 128-bit values like this code
is already doing for 8/16/32/64-bit values.  Switch over to that to make
it a bit simpler, and drop the WITH_ALTIVEC check.  The code probably is
only used when altivec is enabled, but it doesn't add much to always
compile it in, and avoids #ifdef rot by not actually compiling it.

17 months agosim: ppc: switch register read/writes to union to avoid aliasing issues
Mike Frysinger [Thu, 11 Jan 2024 04:35:49 +0000 (23:35 -0500)] 
sim: ppc: switch register read/writes to union to avoid aliasing issues

This code creates a small buffer on the stack w/alloca, then proceeds to
write to it with a cast to a pointer type based on the register type, then
reads from it with a cast to a pointer type based on the register size.
gcc will flags only one of these lines as "maybe used uninitialized", but
it seems to track back to this memory abuse.

Create a large union with all the possible types that this code will read
or write as, and then use those.  It's a bit ugly, but is probably better
than using raw memcpy's everywhere.

17 months agoAutomatic date update in version.in
GDB Administrator [Thu, 18 Jan 2024 00:00:59 +0000 (00:00 +0000)] 
Automatic date update in version.in

17 months agoPR30824 internal error with -z pack-relative-relocs
Alan Modra [Tue, 16 Jan 2024 00:36:23 +0000 (11:06 +1030)] 
PR30824 internal error with -z pack-relative-relocs

This corrects a counting problem, where prior to relocate_section relr
encoded relative relocs were allowed when it was known they were on
even boundaries, but relocate_section can only put relative relocs
(non-relr) on eight byte boundaries.

PR 30824
* elf64-ppc.c (RELR_ALIGN): Define, use throughout.
(maybe_relr): New function, use throughout.

17 months agoUpdate x86-64: Add -z mark-plt and -z nomark-plt
H.J. Lu [Wed, 17 Jan 2024 16:03:29 +0000 (08:03 -0800)] 
Update x86-64: Add -z mark-plt and -z nomark-plt

Pass --hash-style=both to ld for -z mark-plt tests to support linker
configured with --enable-default-hash-style=gnu.

* testsuite/ld-x86-64/mark-plt-1b-x32.d: Pass --hash-style=both
to ld.
* testsuite/ld-x86-64/mark-plt-1b.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1d-x32.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1d.d: Likewise.

17 months agogdb/testsuite: handle long filenames in gdb.base/startup-with-shell.exp
Andrew Burgess [Wed, 17 Jan 2024 09:53:16 +0000 (09:53 +0000)] 
gdb/testsuite: handle long filenames in gdb.base/startup-with-shell.exp

I got a report of a failure from Linaro's CI testing for the test
gdb.base/startup-with-shell.exp.

Looking at the log I see this:

  (gdb) PASS: gdb.base/startup-with-shell.exp: startup_with_shell = on; run_args = *.unique-extension: inferior started
  print argv[1]
  $1 = 0xfffed978 "/home/tcwg-build/workspace/tcwg_gnu_4/abe/builds/armv8l-unknown-linux-gnueabihf/armv8l-unknown-linux-gnueabihf/gdb-gdb.git~master/gdb/testsuite/outputs/gdb.base/startup-with-shell/unique-file.unique-e"...
  (gdb) FAIL: gdb.base/startup-with-shell.exp: startup_with_shell = on; run_args = *.unique-extension: first argument expanded

Notice that the value of $1 was truncated (indicated by the trailing
ellipses), and as a result it isn't going to match the expected output
pattern.

Avoid this by adding a call to 'set print characters unlimited' which
allows GDB to print strings of any length.

Approved-By: Tom de Vries <tdevries@suse.de>
17 months agoFix crash in struct-with-sig-2.exp with debug-names target board
Tom Tromey [Wed, 17 Jan 2024 02:10:12 +0000 (19:10 -0700)] 
Fix crash in struct-with-sig-2.exp with debug-names target board

When I run the struct-with-sig-2.exp test with the .debug_names-using
target board, I see a gdb crash.  This happens because the reader
throws an exception without calling finalize_all_units.  This causes
an assertion failure later because the number of CUs and TUs doesn't
match.

The fix is to clear 'all_units' on failure.

Approved-By: Tom de Vries <tdevries@suse.de>
17 months agoImport gcc commit 65388b28656d65595bdaf191df85af81c35ca63 which adds support for...
Nick Clifton [Wed, 17 Jan 2024 12:06:48 +0000 (12:06 +0000)] 
Import gcc commit 65388b28656d65595bdaf191df85af81c35ca63 which adds support for explicit object member function mangling.

17 months agoLoongArch: Adapt R_LARCH_{PCALA,GOT,TLS_IE,TLS_DESC}64_* handling per psABI v2.30
Xi Ruoyao [Tue, 16 Jan 2024 07:00:16 +0000 (15:00 +0800)] 
LoongArch: Adapt R_LARCH_{PCALA,GOT,TLS_IE,TLS_DESC}64_* handling per psABI v2.30

In LoongArch psABI v2.30, an offset (-8 for LO20 and -12 for HI12)
should be applied on PC for these reloc types to avoid wrong relocation
when the instruction sequence crosses a page boundary.

The lld linker has already adapted the change.  Make it for the bfd
linker too.

Link: https://github.com/loongson/la-abi-specs/releases/v2.30
Link: https://github.com/loongson-community/discussions/issues/17
Link: https://github.com/llvm/llvm-project/pull/73387
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
17 months agoAutomatic date update in version.in
GDB Administrator [Wed, 17 Jan 2024 00:00:37 +0000 (00:00 +0000)] 
Automatic date update in version.in

17 months agoAutomatic date update in version.in
GDB Administrator [Tue, 16 Jan 2024 00:00:34 +0000 (00:00 +0000)] 
Automatic date update in version.in

17 months agogdb/testsuite: remove spurious $ in save_vars
Simon Marchi [Mon, 15 Jan 2024 16:23:42 +0000 (16:23 +0000)] 
gdb/testsuite: remove spurious $ in save_vars

I noticed that running the whole testsuite in serial mode (which means
all the .exp files are ran in the same TCL environment, one after the
other) with the native-extended-gdbserver board caused some weird
failures, for instance a lot of internal errors in the reverse tests,
like:

    continue^M
    Continuing.^M
    /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/deb12-amd64/target_board/native-extended-gdbserver/src/binutils-gdb/gdb/remot        e.c:6922: internal-error: resume: Assertion `scope_ptid == inferior_ptid' failed.^M
    A problem internal to GDB has been detected,^M
    further debugging may prove unreliable.^M
    ----- Backtrace -----^M
    FAIL: gdb.reverse/break-precsave.exp: run to end of main (GDB internal error)

This only happens after running gdb.multi/attach-while-running.exp.
That test does not restore GDBFLAGS properly when it's done, it leaves
`-ex \"maint set target-non-stop on\""` in there, which breaks some
subsequent tests.  The problem is that this line:

    save_vars { $::GDBFLAGS } {

should not use a `$` before the variable name.  Passes the content of
`::GDBFLAGS` to save_vars, which is not what we want.  We want to pass
the `::GDBFLAGS` string.  Fix that.

Change-Id: I5ad32c527795fd10d0d94020e4fd15cebaca3a77

17 months agoRemove addrmap_fixed::set_entry
Tom Tromey [Sun, 14 Jan 2024 18:20:39 +0000 (11:20 -0700)] 
Remove addrmap_fixed::set_entry

It occurred to me that there is no reason for addrmap_fixed::set_entry
to exist.  This patch removes it and removes the abstract virtual
function from the base class.  This then required a few minor changes
in the DWARF reader.  I consider this a type-safety improvement.

Tested by rebuilding.

Reviewed-By: Tom de Vries <tdevries@suse.de>
17 months agogdb: remove unnecessary braces
Simon Marchi [Mon, 15 Jan 2024 17:00:20 +0000 (12:00 -0500)] 
gdb: remove unnecessary braces

Change-Id: I5e96c0f38aa788462ab19a9becfe22030e913c2a

17 months agox86-64: Skip SCFI tests for x32 targets
H.J. Lu [Mon, 15 Jan 2024 15:31:29 +0000 (07:31 -0800)] 
x86-64: Skip SCFI tests for x32 targets

Since SCFI isn't supported on x32:

Fatal error: SCFI is not supported for this ABI

skip SCFI tests for x32 targets.

PR gas/31245
* testsuite/gas/scfi/x86_64/scfi-x86-64.exp: Skip for x32
targets.

17 months agoUpdate HOWTO document after creating the 2.42 branch
Nick Clifton [Mon, 15 Jan 2024 15:35:01 +0000 (15:35 +0000)] 
Update HOWTO document after creating the 2.42 branch

17 months agoChange version to 2.42.50 and regenerate files
Nick Clifton [Mon, 15 Jan 2024 15:13:36 +0000 (15:13 +0000)] 
Change version to 2.42.50 and regenerate files

17 months agoRegenerate two Makefile.in files to update Copyright headers
Mark Wielaard [Mon, 15 Jan 2024 14:33:10 +0000 (15:33 +0100)] 
Regenerate two Makefile.in files to update Copyright headers

commit 1d506c26d9772bcd84e1a7b3a8c8c5bc602dbf61
Update copyright year range in header of all files managed by GDB
updated gnulib/Makefile.am but didn't regenerate gnulib/Makefile.in
also sim/Makefile.in was updated, but the Copyright hunks/years
were off. The first hunk comes from automake 1.15.1 header-vars.am
and so should have 2017 as last year, the second hunk does come from
sim/Makefile.am and so should have 2024 as last year.

* gnulib/Makefile.in: Regenerate.
* sim/Makefile.in: Likewise.

17 months agoAdd markers for 2.42 branch
Nick Clifton [Mon, 15 Jan 2024 14:42:15 +0000 (14:42 +0000)] 
Add markers for 2.42 branch

17 months agoUpdate branch/release creation documentation
Nick Clifton [Mon, 15 Jan 2024 14:21:37 +0000 (14:21 +0000)] 
Update branch/release creation documentation

17 months agoaarch64: rcpc3: Regenerate aarch64-*-2.c files
Victor Do Nascimento [Mon, 15 Jan 2024 13:02:36 +0000 (13:02 +0000)] 
aarch64: rcpc3: Regenerate aarch64-*-2.c files

17 months agoaarch64: rcpc3: Add FP load/store insns
Victor Do Nascimento [Wed, 10 Jan 2024 19:20:05 +0000 (19:20 +0000)] 
aarch64: rcpc3: Add FP load/store insns

Along with the relevant unit-tests, this adds the following rcpc3
instructions:

  STL1  { <Vt>.D }[<index>], [<Xn|SP>]
  LDAP1 { <Vt>.D }[<index>], [<Xn|SP>]

  LDAPUR <Bt>, [<Xn|SP>{, #<simm>}]
  LDAPUR <Ht>, [<Xn|SP>{, #<simm>}]
  LDAPUR <St>, [<Xn|SP>{, #<simm>}]
  LDAPUR <Dt>, [<Xn|SP>{, #<simm>}]
  LDAPUR <Qt>, [<Xn|SP>{, #<simm>}]

  STLUR <Bt>, [<Xn|SP>{, #<simm>}]
  STLUR <Ht>, [<Xn|SP>{, #<simm>}]
  STLUR <St>, [<Xn|SP>{, #<simm>}]
  STLUR <Dt>, [<Xn|SP>{, #<simm>}]
  STLUR <Qt>, [<Xn|SP>{, #<simm>}]

with `#<simm>' taking on a signed 8-bit integer value in the range
[-256,255] and `index' the values 0 or 1.

Co-authored-by: Srinath Parvathaneni <srinath.parvathaneni@arm.com>
17 months agoaarch64: rcpc3: Add integer load/store insns
Victor Do Nascimento [Thu, 4 Jan 2024 14:06:38 +0000 (14:06 +0000)] 
aarch64: rcpc3: Add integer load/store insns

Along with the relevant unit tests and updates to the existing
regression tests, this adds support for the following novel rcpc3
insns:

  LDIAPP <Wt1>, <Wt2>, [<Xn|SP>]
  LDIAPP <Wt1>, <Wt2>, [<Xn|SP>], #8
  LDIAPP <Xt1>, <Xt2>, [<Xn|SP>]
  LDIAPP <Xt1>, <Xt2>, [<Xn|SP>], #16

  STILP <Wt1>, <Wt2>, [<Xn|SP>]
  STILP <Wt1>, <Wt2>, [<Xn|SP>, #-8]!
  STILP <Xt1>, <Xt2>, [<Xn|SP>]
  STILP <Xt1>, <Xt2>, [<Xn|SP>, #-16]!

  LDAPR <Wt>, [<Xn|SP>], #4
  LDAPR <Xt>, [<Xn|SP>], #8

  STLR <Wt>, [<Xn|SP>, #-4]!
  STLR <Xt>, [<Xn|SP>, #-8]!

17 months agoaarch64: rcpc3: Define RCPC3_INSN macro
Victor Do Nascimento [Thu, 4 Jan 2024 14:04:40 +0000 (14:04 +0000)] 
aarch64: rcpc3: Define RCPC3_INSN macro

This patch adds the necessary macro for encoding FEAT_RCPC3-dependent
instructions in Binutils.

17 months agoaarch64: rcpc3: add support in general_constraint_met_p
Victor Do Nascimento [Tue, 9 Jan 2024 10:04:11 +0000 (10:04 +0000)] 
aarch64: rcpc3: add support in general_constraint_met_p

Given the introduction of the new address operand types for rcpc3
instructions, this patch adds the necessary logic to teach
`general_constraint_met_p` how to proper handle these.

17 months agoaarch64: rcpc3: New RCPC3_ADDR operand types
Victor Do Nascimento [Fri, 5 Jan 2024 17:26:09 +0000 (17:26 +0000)] 
aarch64: rcpc3: New RCPC3_ADDR operand types

The particular choices of address indexing, along with their encoding
for RCPC3 instructions lead to the requirement of a new set of operand
descriptions, along with the relevant inserter/extractor set.

That is, for the integer load/stores, there is only a single valid
indexing offset quantity and offset mode is allowed - The value is
always equivalent to the amount of data read/stored by the
operation and the offset is post-indexed for Load-Acquire RCpc, and
pre-indexed with writeback for Store-Release insns.

This indexing quantity/mode pair is selected by the setting of a
single bit in the instruction. To represent these insns, we add the
following operand types:

  - AARCH64_OPND_RCPC3_ADDR_OPT_POSTIND
  - AARCH64_OPND_RCPC3_ADDR_OPT_PREIND_WB

In the case of loads and stores involving SIMD/FP registers, the
optional offset is encoded as an 8-bit signed immediate, but neither
post-indexing or pre-indexing with writeback is available.  This
created the need for an operand type similar to
AARCH64_OPND_ADDR_OFFSET, with the difference that FLD_index should
not be checked.

We thus introduce the AARCH64_OPND_RCPC3_ADDR_OFFSET operand, a
variant of AARCH64_OPND_ADDR_OFFSET, w/o the FLD_index bitfield.

17 months agoaarch64: rcpc3: Define address operand fields and inserter/extractors
Victor Do Nascimento [Fri, 5 Jan 2024 17:27:04 +0000 (17:27 +0000)] 
aarch64: rcpc3: Define address operand fields and inserter/extractors

Beyond the need to encode any registers involved in data transfer and
the address base register for load/stores, it is necessary to specify
the data register addressing mode and whether the address register is
to be pre/post-indexed, whereby loads may be post-indexed and stores
pre-indexed with write-back.

The use of a single bit to specify both the indexing mode and indexing
value requires a novel function be written to accommodate this for
address operand insertion in assembly and another for extraction in
disassembly, along with the definition of two insn fields for use with
these instructions.

This therefore defines the following functions:

  - aarch64_ins_rcpc3_addr_opt_offset
  - aarch64_ins_rcpc3_addr_offset
  - aarch64_ext_rcpc3_addr_opt_offset
  - aarch64_ext_rcpc3_addr_offset

It extends the `do_special_{encoding|decoding}' functions and defines
two rcpc3 instruction fields:

  - FLD_opc2
  - FLD_rcpc3_size

17 months agoaarch64: rcpc3: Create implicit load/store size calc function
Victor Do Nascimento [Tue, 9 Jan 2024 16:22:07 +0000 (16:22 +0000)] 
aarch64: rcpc3: Create implicit load/store size calc function

The allowed immediate offsets in integer rcpc3 load store instructions
are not encoded explicitly in the instruction itself, being rather
implicitly equivalent to the amount of data loaded/stored by the
instruction.

This leads to the requirement that this quantity be calculated based on
the number of registers involved in the transfer, either as data
source or destination registers and their respective qualifiers.

This is done via `calc_ldst_datasize (const aarch64_opnd_info *opnds)'
implemented here, using a cumulative sum of qualifier sizes preceding
the address operand in the OPNDS operand list argument.

17 months agoaarch64: rcpc3: Add +rcpc3 architectural feature support flag
Victor Do Nascimento [Thu, 4 Jan 2024 13:34:52 +0000 (13:34 +0000)] 
aarch64: rcpc3: Add +rcpc3 architectural feature support flag

Indicating the presence of the Armv8.2-a feature adding further
support for the Release Consistency Model, the `+rcpc3' architectural
extension flag is added to the list of possible `-march' options in
Binutils, together with the necessary macro for encoding rcpc3
instructions.

17 months agobfd: riscv_maybe_function_sym check _bfd_elf_is_local_label_name
Mark Wielaard [Thu, 4 Jan 2024 00:31:31 +0000 (01:31 +0100)] 
bfd: riscv_maybe_function_sym check _bfd_elf_is_local_label_name

This fixes the ld "Handle no DWARF information" testcase. Which
currently fails on riscv because a local label name is assumed
to be the current function name.

bfd/ChangeLog:

* elfnn-riscv.c (riscv_maybe_function_sym): Also check
_bfd_elf_is_local_label_name.

17 months agoaarch64: Fix tlbi and tlbip instructions
Andrew Carlotti [Mon, 15 Jan 2024 11:20:20 +0000 (11:20 +0000)] 
aarch64: Fix tlbi and tlbip instructions

There are some tlbi operations that don't have a corresponding tlbip operation,
but we were incorrectly using the same list for both.  Add the missing tlbi
*nxs operations, and use the F_REG_128 flag to filter tlbi operations that
don't have a tlbip analogue.  For increased clarity, I have also used a macro
to reduce duplication between the 'nxs' and non-'nxs' variants, and added a
test to verify that no invalid combinations are accepted.

Additionally, fix two missing checks for AARCH64_OPND_SYSREG_TLBIP that were
preventing disassembly of tlbip instructions.

17 months agoaarch64: Refactor aarch64_sys_ins_reg_supported_p
Andrew Carlotti [Mon, 15 Jan 2024 11:19:48 +0000 (11:19 +0000)] 
aarch64: Refactor aarch64_sys_ins_reg_supported_p

Add an aarch64_feature_set field to aarch64_sys_ins_reg, and use this for
feature checks instead of testing against a list of operand codes.

17 months agonm: Replace --with-symbol-versions with --without-symbol-versions in --help output
Nick Clifton [Mon, 15 Jan 2024 12:25:00 +0000 (12:25 +0000)] 
nm: Replace --with-symbol-versions with --without-symbol-versions in --help output

  PR 31243
  nm: Fix --help output

17 months agoaarch64: Remove unused BTI feature bit
Andrew Carlotti [Mon, 15 Jan 2024 11:16:05 +0000 (11:16 +0000)] 
aarch64: Remove unused BTI feature bit

OK for master?

17 months agoAdd generated source files and fix thinko in aarch64-asm.c
Nick Clifton [Mon, 15 Jan 2024 11:45:28 +0000 (11:45 +0000)] 
Add generated source files and fix thinko in aarch64-asm.c

17 months agoaarch64: Add SVE2.1 Contiguous load/store instructions.
Srinath Parvathaneni [Mon, 15 Jan 2024 09:40:11 +0000 (09:40 +0000)] 
aarch64: Add SVE2.1 Contiguous load/store instructions.

Hi,

This patch add support for SVE2.1 instructions ld1q,
ld2q, ld3q and ld4q, st1q, st2q, st3q and st4q.

Regression testing for aarch64-none-elf target and found no regressions.

Ok for binutils-master?

Regards,
Srinath.

17 months agoPATCH 5/6][Binutils] aarch64: Add SVE2.1 fmin and fmax instructions.
Srinath Parvathaneni [Mon, 15 Jan 2024 09:38:39 +0000 (09:38 +0000)] 
PATCH 5/6][Binutils] aarch64: Add SVE2.1 fmin and fmax instructions.

Hi,

This patch add support for SVE2.1 instruction faddqv,
fmaxnmqv, fmaxqv, fminnmqv and fminqv.

Regression testing for aarch64-none-elf target and found no regressions.

Ok for binutils-master?

Regards,
Srinath.

17 months agoaarch64: Add SVE2.1 dupq, eorqv and extq instructions.
Srinath Parvathaneni [Mon, 15 Jan 2024 09:37:32 +0000 (09:37 +0000)] 
aarch64: Add SVE2.1 dupq, eorqv and extq instructions.

Hi,

This patch add support for SVE2.1 instruction dupq, eorqv and extq.

Regression testing for aarch64-none-elf target and found no regressions.

Ok for binutils-master?

Regards,
Srinath.

17 months agoaarch64: Add support for FEAT_SVE2p1.
Srinath Parvathaneni [Mon, 15 Jan 2024 09:35:55 +0000 (09:35 +0000)] 
aarch64: Add support for FEAT_SVE2p1.

Hi,

This patch add support for FEAT_SVE2p1 (SVE2.1 Extension) feature
along with +sve2p1 optional flag to enabe this feature.

Also support for following SVE2p1 instructions is added
addqv, andqv, smaxqv, sminqv, umaxqv, uminqv and uminqv.

Regression testing for aarch64-none-elf target and found no regressions.

Ok for binutils-master?

Regards,
Srinath.