]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
4 weeks agoalpha, bfd: Fixes for ALPHA_R_OP_STORE
Janne Ramstedt [Sun, 25 May 2025 17:17:20 +0000 (20:17 +0300)] 
alpha, bfd: Fixes for ALPHA_R_OP_STORE

ALPHA_R_OP_STORE copies one byte too many and also will cause out of
range error when it tries to copy from the end of section.  Since
"endbyte" is already rounded to next full byte, there is enough bits
to copy and the additional "+ 1" is erroneous in bytes count.  I also
believe size is incorrectly decreased.

4 weeks agogdb, btrace: remove record_btrace_target::supports_*()
Markus Metzger [Fri, 23 Feb 2024 07:07:39 +0000 (07:07 +0000)] 
gdb, btrace: remove record_btrace_target::supports_*()

Let's not introduce support for breakpoint types the target beneath does
not support, even though we could while replaying.

Otherwise, users may set breakpoints during replay that then couldn't be
inserted into the target when switching back to recording.

Approved-By: Andrew Burgess <aburgess@redhat.com>
4 weeks agoLoongArch: overflow and underflow checks for R_LARCH_32_PCREL
Lulu Cai [Tue, 20 May 2025 11:38:12 +0000 (19:38 +0800)] 
LoongArch: overflow and underflow checks for R_LARCH_32_PCREL

Relocation overflows can silently write incorrect value to
the file, so overflow checks are added to avoid this.

4 weeks agoAutomatic date update in version.in
GDB Administrator [Mon, 26 May 2025 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agoAutomatic date update in version.in
GDB Administrator [Sun, 25 May 2025 00:00:17 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agogdb/solib-svr4: check that solib is SVR4 in tls_maybe_fill_slot and tls_maybe_erase_slot
Simon Marchi [Fri, 23 May 2025 16:30:52 +0000 (12:30 -0400)] 
gdb/solib-svr4: check that solib is SVR4 in tls_maybe_fill_slot and tls_maybe_erase_slot

Functions tls_maybe_fill_slot and tls_maybe_erase_slot blindly assume
that the passe solibs come from solib-svr4.  This is not always the
case, because they are called even on the systems where the solib
implementation isn't solib-svr4.  Add some checks to return early in
that case.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32990
Change-Id: I0a281e1f4826aa1914460c2213f0fae1bdc9af7c
Tested-By: Hannes Domani <ssbssa@yahoo.de>
Approved-By: Andrew Burgess <aburgess@redhat.com>
4 weeks agogdb: use local addrmap_mutable in addrmap selftest
Simon Marchi [Fri, 23 May 2025 18:35:29 +0000 (14:35 -0400)] 
gdb: use local addrmap_mutable in addrmap selftest

There is no need to allocate the addrmap_mutable on the heap.

Change-Id: Ia6ec17101a44ae5eaffbf3382c9639414ce5343e
Approved-By: Andrew Burgess <aburgess@redhat.com>
4 weeks agogdb: turn CHECK_ADDRMAP_FIND into a function
Simon Marchi [Fri, 23 May 2025 18:35:28 +0000 (14:35 -0400)] 
gdb: turn CHECK_ADDRMAP_FIND into a function

Replace the macro with a function.  I don't see a need to use a macro
here, a function is easier to read.

Change-Id: I22370040cb546470498d64939b246b03700af398
Approved-By: Andrew Burgess <aburgess@redhat.com>
4 weeks ago[gdb/build] Fix unused var in lookup_dwo_unit_in_dwp
Tom de Vries [Sat, 24 May 2025 08:27:12 +0000 (10:27 +0200)] 
[gdb/build] Fix unused var in lookup_dwo_unit_in_dwp

On x86_64-linux, with gcc 7.5.0 I ran into a build breaker:
...
gdb/dwarf2/read.c: In function ‘dwo_unit* lookup_dwo_unit_in_dwp()’:
gdb/dwarf2/read.c:7403:22: error: unused variable ‘inserted’ \
  [-Werror=unused-variable]
    auto [it, inserted] = dwo_unit_set.emplace (std::move (dwo_unit));
                      ^
...

Fix this by dropping the unused variable.

Tested on x86_64-linux, by completing a build.

4 weeks agogdb: guard <mutex> include with CXX_STD_THREAD
Simon Marchi [Sat, 24 May 2025 02:27:32 +0000 (22:27 -0400)] 
gdb: guard <mutex> include with CXX_STD_THREAD

Change-Id: I4335fbfdabe49778fe37b08689eec59be94c424b

4 weeks agoAutomatic date update in version.in
GDB Administrator [Sat, 24 May 2025 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks agogdb/NEWS: minor white space fix
Andrew Burgess [Fri, 23 May 2025 18:22:12 +0000 (19:22 +0100)] 
gdb/NEWS: minor white space fix

Spotted a small white space mistake in the NEWS file.  Fixed.

5 weeks agogdb: include <mutex> in dwarf2/read.h
Simon Marchi [Fri, 23 May 2025 18:00:29 +0000 (14:00 -0400)] 
gdb: include <mutex> in dwarf2/read.h

The buildbot pointed out this compilation failure on AlmaLinux, with g++
8.5.0, which is not seen on more recent systems:

     CXX    gdbtypes.o
    In file included from ../../binutils-gdb/gdb/gdbtypes.c:39:
    ../../binutils-gdb/gdb/dwarf2/read.h:639:8: error: ‘mutex’ in namespace ‘std’ does not name a type
       std::mutex dwo_files_lock;
            ^~~~~
    ../../binutils-gdb/gdb/dwarf2/read.h:639:3: note: ‘std::mutex’ is defined in header ‘<mutex>’; did you forget to ‘#include <mutex>’?
    ../../binutils-gdb/gdb/dwarf2/read.h:35:1:
    +#include <mutex>

    ../../binutils-gdb/gdb/dwarf2/read.h:639:3:
       std::mutex dwo_files_lock;
       ^~~

Fix it by including <mutex> in dwarf2/read.h.

Change-Id: Iba334a3dad217c86841a5e804d0f386876f5ff2f

5 weeks ago[gdb] Make make-init-c more robust
Tom de Vries [Fri, 23 May 2025 16:54:43 +0000 (18:54 +0200)] 
[gdb] Make make-init-c more robust

In commit 2711e4754fc ("Ensure cooked_index_entry self-tests are run"), we
rewrite the function definition of _initialize_dwarf2_entry into a normal
form that allows the make-init-c script to detect it:
...
 void _initialize_dwarf2_entry ();
-void _initialize_dwarf2_entry ()
+void
+_initialize_dwarf2_entry ()
...

Update make-init-c to also detect the "void _initialize_dwarf2_entry ()"
variant.

Tested on x86_64-linux, by reverting commit 2711e4754fc, rebuilding and
checking that build/gdb/init.c doesn't change.

5 weeks ago[gdb/testsuite] Add gdb.dwarf2/fission-dw-form-strx.exp
Tom de Vries [Fri, 23 May 2025 16:38:20 +0000 (18:38 +0200)] 
[gdb/testsuite] Add gdb.dwarf2/fission-dw-form-strx.exp

Add a dwarf assembly test-case using a DW_FORM_strx in a .dwo file.

Tested on x86_64-linux.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks agogdb/dwarf: split dwo_lock in more granular locks
Simon Marchi [Mon, 12 May 2025 19:09:45 +0000 (15:09 -0400)] 
gdb/dwarf: split dwo_lock in more granular locks

The dwo_lock mutex is used to synchronize access to some dwo/dwp-related
data structures, such as dwarf2_per_bfd::dwo_files and
dwp_file::loaded_{cus,tus}.  Right now the scope of the lock is kind of
coarse.  It is taken in the top-level lookup_dwo_unit function, and held
while the thread:

 - looks up an existing dwo_file in the per-bfd hash table for the given
   id/signature
 - if there's no existing dwo_file, attempt to find a .dwo file, open
   it, build the list of units it contains
 - if a new dwo_file was created, insert it in the per-bfd hash table
 - look up the desired unit in the dwo_file

And something similar for the dwp code path.  This means that two
indexing thread can't read in two dwo files simultaneously.  This isn't
ideal in terms of parallelism.

This patch breaks this lock into 3 more fine grained locks:

 - one lock to access dwarf2_per_bfd::dwo_files
 - one lock to access dwp_file::loaded_{cus,tus}
 - one lock in try_open_dwop_file, where we do two operations that
   aren't thread safe (bfd_check_format and gdb_bfd_record_inclusion)

Unfortunately I don't see a clear speedup on my computer with 8 threads.
But the change shouldn't hurt, in theory, and hopefully this can be a
piece that helps in making GDB scale better on machines with many cores
(if we ever bump the max number of worker threads).

This patch uses "double-checked locking" to avoid holding the lock(s)
for the whole duration of reading in dwo files.  The idea is, when
looking up a dwo with a given name:

 - with the lock held, check for an existing dwo_file with that name in
   dwarf2_per_bfd::dwo_files, if found return it
 - if not found, drop the lock, load the dwo file and create a dwo_file
   describing it
 - with the lock held, attempt to insert the new dwo_file in
   dwarf2_per_bfd::dwo_files.  If an entry exists, it means another
   thread simultaneously created an equivalent dwo_file, but won the
   race.  Drop the new dwo_file and use the existing one.  The new
   dwo_file is automatically deleted, because it is help by a unique_ptr
   and the insertion into the unordered_set fails.

Note that it shouldn't normally happen for two threads to look up a dwo
file with the same name, since different units will point to different
dwo files.  But it were to happen, we handle it.  This way of doing
things allows two threads to read in two different dwo files
simulatenously, which in theory should help get better parallelism.  The
same technique is used for dwp_file::loaded_{cus,tus}.

I have some local CI jobs that run the fission and fission-dwp boards,
and I haven't seen regressions.  In addition to the regular testing, I
ran a few tests using those boards on a ThreadSanitizer build of GDB.

Change-Id: I625c98b0aa97b47d5ee59fe22a137ad0eafc8c25
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
5 weeks agogdb/dwarf: allocate DWP dwarf2_section_info with new
Simon Marchi [Mon, 12 May 2025 19:09:44 +0000 (15:09 -0400)] 
gdb/dwarf: allocate DWP dwarf2_section_info with new

For the same reason as explained in the previous patch (allocations on
obstacks aren't thread-safe), change the allocation of
dwarf2_section_info object for dwo files within dwp files to use "new".

The dwo_file::section object is not always owned by the dwo_file, so
introduce a new "dwo_file::section_holder" object that is only set when
the dwo_file owns the dwarf2_section_info.

Change-Id: I74c4608573c7a435bf3dadb83f96a805d21798a2
Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agogdb/dwarf: allocate dwo_unit with new
Simon Marchi [Mon, 12 May 2025 19:09:43 +0000 (15:09 -0400)] 
gdb/dwarf: allocate dwo_unit with new

The following patch reduces the duration where the dwo_lock mutex is
taken.  One operation that is not thread safe is the allocation on
dwo_units on the per_bfd obstack:

    dwo_unit *dwo_unit = OBSTACK_ZALLOC (&per_bfd->obstack, struct dwo_unit);

We could take the lock around this allocation, but I think it's just
easier to avoid the problem by having the dwo_unit objects allocated
with "new".

Change-Id: Ida04f905cb7941a8826e6078ed25dbcf57674090
Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agoHandle an argument-less operator in the C++ name parser
Tom Tromey [Thu, 8 May 2025 20:04:05 +0000 (14:04 -0600)] 
Handle an argument-less operator in the C++ name parser

While debugging a new failure in my long-suffering "search-in-psyms"
series, I found that the C++ name canonicalizer did not handle a case
like "some_name::operator new []".  This should remove the space,
resulting in "some_name::operator new[]" -- but does not.

This happens because the parser requires an operator to be followed by
argument types.  That is, it's expected.

However, it seems to me that we do want to be able to canonicalize a
name like this.  It will appear in the DWARF as a DW_AT_name, and
furthermore it could be entered by the user.

This patch fixes this problem by changing the grammar to supply the
"()" itself, then removing the trailing "()" when changing to string
form (in the functions that matter).

This isn't ideal -- it might miss a very obscure case involving the
gdb extension of providing fully-qualified names for function-local
statics -- but it improves the situation at least.

It's possible a better solution might be to rewrite the name
canonicalizer.  I was wondering if this could perhaps be done without
reference to the grammar -- just by examining the tokens.  However,
that's much more involved.

Let me know what you think.

Regression tested on x86-64 Fedora 40.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32939
Reviewed-By: Keith Seitz <keiths@redhat.com>
5 weeks agolibctf: archive, open: when opening, always set errp to something
Nick Alcock [Mon, 12 May 2025 11:31:00 +0000 (12:31 +0100)] 
libctf: archive, open: when opening, always set errp to something

ctf_arc_import_parent, called by the cached-opening machinery used by
ctf_archive_next and archive-wide lookup functions like
ctf_arc_lookup_symbol, has an err-pointer parameter like all other opening
functions.  Unfortunately it unconditionally initializes it whenever
provided, even if there was no error, which can lead to its being
initialized to an uninitialized value.  This is not technically an
API-contract violation, since we don't define what happens to the error
value except when an error happens, but it is still unpleasant.

Initialize it only when there is an actual error, so we never initialize it
to an uninitialized value.

While we're at it, improve all the opening pathways: on success, set errp to
0, rather than leaving it what it was, reducing the likelihood of
uninitialized error param returns in callers too.  (This is inconsistent
with the treatment of ctf_errno(), but the err value being a parameter
passed in from outside makes the divergence acceptable: in open functions,
you're never going to be overwriting some old error value someone might want
to keep around across multiple calls, some of which are successful and some
of which are not.)

Soup up existing tests to verify all this.

Thanks to Bruce McCulloch for the original patch, and Stephen Brennan for
the report.

libctf/
PR libctf/32903
* ctf-archive.c (ctf_arc_open_internal): Zero errp on success.
(ctf_dict_open_sections): Zero errp at the start.
(ctf_arc_import_parent): Intialize err.
* ctf-open.c (ctf_bufopen): Zero errp at the start.
* testsuite/libctf-lookup/add-to-opened.c: Make sure one-element
archive opens update errp.
* testsuite/libctf-writable/ctf-compressed.c: Make sure real archive
opens update errp.

5 weeks agoRISC-V: Add support for RISC-V Profiles 23.
Jiawei [Sun, 11 May 2025 13:38:19 +0000 (21:38 +0800)] 
RISC-V: Add support for RISC-V Profiles 23.

This patch adds support for RISC-V RVA23 and RVB23 Profiles[1].

[1] https://github.com/riscv/riscv-profiles/releases/tag/rva23-rvb23-ratified

bfd/ChangeLog:

* elfxx-riscv.c: New profiles.

gas/ChangeLog:

* testsuite/gas/riscv/attribute-19.d: New test.
* testsuite/gas/riscv/attribute-20.d: New test.

5 weeks agoRISC-V: Add support for RISC-V Profiles 20/22.
Jiawei [Sun, 11 May 2025 13:38:18 +0000 (21:38 +0800)] 
RISC-V: Add support for RISC-V Profiles 20/22.

This patch introduces support for RISC-V Profiles RV20 and RV22 [1],
enabling developers to utilize these profiles through the -march option.

[1] https://github.com/riscv/riscv-profiles/releases/tag/v1.0

bfd/ChangeLog:

* elfxx-riscv.c (struct riscv_profiles): New struct.
(riscv_parse_extensions): New argument.
(riscv_find_profiles): New checking function.
(riscv_parse_subset): Add Profiles handler.

gas/ChangeLog:

* NEWS: Add RISC-V Profiles.
* doc/as.texi: Update -march input type.
* doc/c-riscv.texi: Ditto.
* testsuite/gas/riscv/option-arch-fail.l: Modify hint info.
* testsuite/gas/riscv/attribute-17.d: New test.
* testsuite/gas/riscv/attribute-18.d: New test.
* testsuite/gas/riscv/march-fail-rvi20u64v.d: New test.
* testsuite/gas/riscv/march-fail-rvi20u64v.l: New test.

5 weeks agoAutomatic date update in version.in
GDB Administrator [Fri, 23 May 2025 00:00:14 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks agoPR 3298 Fix SuperH relaxation overriding wrong intruction
QBos07 [Fri, 9 May 2025 13:49:44 +0000 (13:49 +0000)] 
PR 3298 Fix SuperH relaxation overriding wrong intruction

when doing load store switching it wrongly adjusts the address of the
R_SH_USES reloc and not the actual offset from that instruction. This is
an issue if the pc-relative function call relaxation gets done in a
later pass wich will result in overriding the wrong instruction.

5 weeks agors_fill_nop and md_generate_nops
Alan Modra [Mon, 19 May 2025 06:37:20 +0000 (16:07 +0930)] 
rs_fill_nop and md_generate_nops

Make rs_fill_nop behave like rs_fill in using a repeat count
(fr_offset) to emit fr_var length repeated nop patterns.  Besides
being more elegant, this reduces memory required for large .nops
directives.

* as.h (rs_fill_nop): Update comment.
* config/tc-i386.c (i386_generate_nops): Handle rs_fill_nop as
for rs_align_code.
* config/tc-i386.h (MAX_MEM_FOR_RS_SPACE_NOP): Define.
* listing.c (calc_hex): Handle rs_fill_nop as for rs_fill.
* read.c (MAX_MEM_FOR_RS_SPACE_NOP): Define.
(s_nops): Use MAX_MEM_FOR_RS_SPACE_NOP setting up frag.
* write.c (write_contents): Call md_generate_nops for rs_fill_nop
before the fr_fix part is written, so that rs_fill_nop can be
handled as for rs_fill.

5 weeks agoRe: gas .align limit
Alan Modra [Sun, 18 May 2025 15:02:22 +0000 (00:32 +0930)] 
Re: gas .align limit

Now that rs_align_code has been corrected for all targets, put the
.align limit back to bits_per_address-1.  Also fix a comment.

* frags.h (fr_var): Correct comment.
* read.c (TC_ALIGN_LIMIT): Revert commit ff4c03516c change.

5 weeks agotidy x86 HANDLE_ALIGN
Alan Modra [Sun, 18 May 2025 14:57:54 +0000 (00:27 +0930)] 
tidy x86 HANDLE_ALIGN

Reduce memory requirement for .align in code.

I've changed some of the tests to use "clc" rather than "nop", so that
code emitted by .p2align can be clearly seen.

* config/tc-i386.c (i386_output_nops): Merge into..
(i386_generate_nops): ..here.  Put shorter nop first.  For
rs_align_code make use of the fact that the last fr_var bytes
are output repeatedly rather than repeating them here.
* config/tc-i386.h (HANDLE_ALIGN): Don't test max_bytes.
(MAX_MEM_FOR_RS_ALIGN_CODE): Update.
* testsuite/gas/i386/nops-1.s,
* testsuite/gas/i386/nops-2.s,
* testsuite/gas/i386/nops-3.s,
* testsuite/gas/i386/nops-4.s,
* testsuite/gas/i386/nops16-1.s: Replace "nop" with "clc".
* testsuite/gas/i386/align-branch-6.d,
* testsuite/gas/i386/nop-1-suffix.d,
* testsuite/gas/i386/nop-1.d,
* testsuite/gas/i386/nop-1.l,
* testsuite/gas/i386/nop-2.d,
* testsuite/gas/i386/nop-4.d,
* testsuite/gas/i386/nop-5.d,
* testsuite/gas/i386/nops-1-core2.d,
* testsuite/gas/i386/nops-1.d,
* testsuite/gas/i386/nops-10.d,
* testsuite/gas/i386/nops-2.d,
* testsuite/gas/i386/nops-3.d,
* testsuite/gas/i386/nops-4.d,
* testsuite/gas/i386/nops-4a-i686.d,
* testsuite/gas/i386/nops-5.d,
* testsuite/gas/i386/nops-6.d,
* testsuite/gas/i386/nops-7.d,
* testsuite/gas/i386/nops-9.d,
* testsuite/gas/i386/nops16-1.d,
* testsuite/gas/i386/x86-64-align-branch-6.d,
* testsuite/gas/i386/x86-64-nop-1.d,
* testsuite/gas/i386/x86-64-nop-5.d,
* testsuite/gas/i386/x86-64-nops-1-core2.d,
* testsuite/gas/i386/x86-64-nops-1-pentium.d,
* testsuite/gas/i386/x86-64-nops-1.d,
* testsuite/gas/i386/x86-64-nops-2.d,
* testsuite/gas/i386/x86-64-nops-3.d,
* testsuite/gas/i386/x86-64-nops-4-core2.d,
* testsuite/gas/i386/x86-64-nops-4.d,
* testsuite/gas/i386/x86-64-nops-5.d,
* testsuite/gas/i386/x86-64-nops-6.d,
* testsuite/gas/i386/x86-64-nops-7.d: Adjust to suit.

5 weeks agotidy target HANDLE_ALIGN
Alan Modra [Sat, 17 May 2025 05:41:14 +0000 (15:11 +0930)] 
tidy target HANDLE_ALIGN

avr, kvx, metag, mn10300, nds32, v850, visium, and wasm32 targets
defined HANDLE_ALIGN without defining MAX_MEM_FOR_RS_ALIGN_CODE.  This
can result in a rather large chunk of memory being allocated.  Fix
that by a combination of changing the default allocation to one byte
and/or defining a target MAX_MEM_FOR_RS_ALIGN_CODE.

arm wanted to write out the entire set of nops, and limited allowed
code alignment to 64 bytes to prevent large memory allocations.
Fix that by making use of the fact that rs_align_code frags repeat
fr_var bytes at fr_literal + fr_fix to fill out the required area.
Fix metag, nds32 and kvx too, which it seems copied either arm or x86
in similarly not making use of repeating patterns.

It's worth mentioning that my tidy to kvx changed the order of nop
bundles, placing a short bundle first rather than last.

epiphany was totally broken in that uninitialised data was written out
for any alignment requiring more than three bytes of fill.

ppc created a new frag to handle a branch over a large number of nops.
This saves 4 bytes per rs_align_code frag, and most times the branch
isn't used so it is generally a win for memory usage, but I figured
the extra code complexity wasn't worth it.  So that code of mine goes.
visium copied the same scheme, so that goes too.

This leaves x86 as the only target making large allocations for
alignment frags.

* frags.c (MAX_MEM_FOR_RS_ALIGN_CODE): Default to 1.
* config/tc-aarch64.c (aarch64_handle_align): Remove always true
condition.
* config/tc-aarch64.h (MAX_MEM_FOR_RS_ALIGN_CODE): Move to be
adjacent to HANDLE_ALIGN define.
* config/tc-arm.c (arm_handle_align): Allow alignment of more
than MAX_MEM_FOR_RS_ALIGN_CODE bytes.  Just write one repeat
of nop pattern to frag.
(arm_frag_align_code): Delete function.
* config/tc-arm.h (MAX_MEM_ALIGNMENT_BYTES): Don't define.
(MAX_MEM_FOR_RS_ALIGN_CODE): Set to 7.
(md_do_align): Don't define.
(arm_frag_align_code): Don't declare.
* config/tc-epiphany.c (epiphany_handle_align): Correct frag
so that nop_pattern repeats rather than random data.
* config/tc-epiphany.h (MAX_MEM_FOR_RS_ALIGN_CODE): Define.
* config/tc-kvx.c (kvx_make_nops): Merge into..
(kvx_handle_align): ..here.  Put short nop bundle first,
followed by repeated full nop bundle.
* config/tc-kvx.h (MAX_MEM_FOR_RS_ALIGN_CODE): Define.
* config/tc-m32c.h (HANDLE_ALIGN, MAX_MEM_FOR_RS_ALIGN_CODE):
Don't define.
* config/tc-metag.c (metag_handle_align): Just write one
repeat of nop pattern to frag.
* config/tc-metag.h (MAX_MEM_FOR_RS_ALIGN_CODE): Define.
* config/tc-nds32.c (nds32_handle_align): Just write one
repeat of nop pattern to frag.
* config/tc-nds32.h (MAX_MEM_FOR_RS_ALIGN_CODE): Define.
* config/tc-ppc.c (ppc_handle_align): Don't make a new frag
for branch.
* config/tc-ppc.h (MAX_MEM_FOR_RS_ALIGN_CODE): Increase to 8.
* config/tc-visium.c (visium_handle_align): Don't make a new
frag for branch.
* config/tc-visium.h (MAX_MEM_FOR_RS_ALIGN_CODE): Define.
* config/tc-wasm32.h (HANDLE_ALIGN): Don't define.
* testsuite/gas/epiphany/nop.d,
* testsuite/gas/epiphany/nop.s: New test.
* testsuite/gas/epiphany/allinsn.exp: Run it.
* testsuite/gas/kvx/nop-align.d: Adjust.

5 weeks agogdb: reorder checks in validate_exec_file
Andrew Burgess [Wed, 21 May 2025 09:16:08 +0000 (10:16 +0100)] 
gdb: reorder checks in validate_exec_file

While reviewing another patch I was briefly confused by a call to
target_pid_to_exec_file coming from validate_exec_file while attaching
to a process when I had not previously set an executable.

The current order of actions in validate_exec_file is:

  1. Get name of current executable.
  2. Get name of executable from the current inferior.
  3. If either of (1) or (2) return NULL, then there's nothing to
     check, early return.

I think it would be cleaner if we instead did this:

  1. Get name of current executable.
  3. If (1) returned NULL then there's nothing to check, early return.
  3. Get name of executable from the current inferior.
  4. If (3) returned NULL then there's nothing to check, early return.

This does mean there's an extra step, but I don't think the code is
any more complex really, and we now avoid trying to extract the name
of the executable from the current inferior unless we really need it.
This avoids the target_pid_to_exec_file call that I was seeing, which
for remote targets does avoid a packet round trip (not that I'm
selling this as an "optimisation", just noting the change).

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 weeks agoEnsure cooked_index_entry self-tests are run
Tom Tromey [Thu, 22 May 2025 16:46:50 +0000 (10:46 -0600)] 
Ensure cooked_index_entry self-tests are run

While looking at code coverage for gdb, I noticed that the
cooked_index_entry self-tests were not run.  I tracked this down to a
formatting error in cooked-index-entry.c.

I suspect it might be better to use a macro to define these
initialization functions.  That would probably remove the possibility
for this kind of error.

5 weeks agogprofng: fix 32892 source line level information not available with "-g -O2"
Vladimir Mezentsev [Mon, 19 May 2025 20:13:46 +0000 (13:13 -0700)] 
gprofng: fix 32892 source line level information not available with "-g -O2"

gprofng did not read the .debug_rnglists section for dwarf-5.
Another problem was that gprofng ignored DW_AT_abstract_origin
As a result, gprofng skiped Dwarf for all functions declared as:
   <1><e18b>: Abbrev Number: 43 (DW_TAG_subprogram)
      <e18c>   DW_AT_abstract_origin: <0xe168>
      <e190>   DW_AT_linkage_name:  _ZN10Bool_ArrayD2Ev

gprofng/ChangeLog
2025-05-19  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR 32892
* src/Dwarf.cc: Read the .debug_rnglists section.
Support DW_AT_abstract_origin.
* src/Dwarf.h: Likewise.
* src/DwarfLib.cc: Likewise.
* src/DwarfLib.h: Likewise.
* src/LoadObject.cc (dump_functions): Print mangled names for aliases.
* src/Stabs.cc (fixSymtabAlias): Set 'alias' correctly.
* src/Symbol.cc (find_symbols): Add argument where to collect symbols.
* src/Symbol.h: Likewise.

5 weeks agoRISC-V: Add support for Smcdeleg and Ssccfg extensions.
Jiawei [Wed, 21 May 2025 13:06:09 +0000 (21:06 +0800)] 
RISC-V: Add support for Smcdeleg and Ssccfg extensions.

This patch rebases the original patch from Nelson's implement[1].

Added new extension Smcdeleg and Ssccfg with a new CSR, scountinhibit.[2]

Co-Authored-By: Nelson Chu <nelson@rivosinc.com>
Co-Authored-By: Jiawei Chen <jiawei@iscas.ac.cn>
[1] https://patchwork.sourceware.org/project/binutils/patch/20240620045359.47513-1-nelson@rivosinc.com/
[2] https://github.com/riscvarchive/riscv-smcdeleg-ssccfg/releases/tag/v1.0.0

bfd/ChangeLog:

* elfxx-riscv.c: New extensions.

gas/ChangeLog:

* NEWS: Mention new extensions.
* config/tc-riscv.c (enum riscv_csr_class): New CSR class.
(riscv_csr_address): Add support for Ssccfg.
* testsuite/gas/riscv/csr-version-1p10.d: New test for Ssccfg CSR.
* testsuite/gas/riscv/csr-version-1p10.l: New warning for Ssccfg CSR.
* testsuite/gas/riscv/csr-version-1p11.d: New test for Ssccfg CSR.
* testsuite/gas/riscv/csr-version-1p11.l: New warning for Ssccfg CSR.
* testsuite/gas/riscv/csr-version-1p12.d: New test for Ssccfg CSR.
* testsuite/gas/riscv/csr-version-1p12.l: New warning for Ssccfg CSR.
* testsuite/gas/riscv/csr-version-1p13.d: New test for Ssccfg CSR.
* testsuite/gas/riscv/csr-version-1p13.l: New warning for Ssccfg CSR.
* testsuite/gas/riscv/csr.s: New Ssccfg CSR.
* testsuite/gas/riscv/imply.d: New imply check.
* testsuite/gas/riscv/imply.s: New implies.
* testsuite/gas/riscv/march-help.l: New helping info.

include/ChangeLog:

        * opcode/riscv-opc.h (CSR_SCOUNTINHIBIT): New CSR address.
        (DECLARE_CSR): Add Ssccfg CSR.

5 weeks agoLoongArch: Warning about incorrect 3rd argument of .align
Lulu Cai [Mon, 19 May 2025 03:05:22 +0000 (11:05 +0800)] 
LoongArch: Warning about incorrect 3rd argument of .align

344b1e0f5f7 Introduced range-check 3rd argument of .align, incorrect
value are not converted silently. added warning message to fix regression.

5 weeks agoAutomatic date update in version.in
GDB Administrator [Thu, 22 May 2025 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks agoubsan: integer overflow in tc-i386.c:offset_in_range
Alan Modra [Wed, 21 May 2025 08:27:04 +0000 (17:57 +0930)] 
ubsan: integer overflow in tc-i386.c:offset_in_range

or $9223372036854775808,%eax
runtime error: negation of -9223372036854775808 cannot be represented
in type 'offsetT' (aka 'long'); cast to an unsigned type to negate
this value to itself

* config/tc-i386.c (offset_in_range): Avoid signed overflow.

5 weeks agoMinor spelling fixes in gdb directory
Tom Tromey [Thu, 10 Apr 2025 15:01:06 +0000 (09:01 -0600)] 
Minor spelling fixes in gdb directory

I ran codespell on the gdb directory and fixed a number of minor
problems.  In a couple cases I replaced a "gdb spelling" (e.g.,
"readin") with an English one ("reading") where it seemed harmless.

I also added "Synopsis" as an accepted spelling.

gdb is nowhere near codespell-clean.

Approved-By: Tom de Vries <tdevries@suse.de>
5 weeks agoAutomatic date update in version.in
GDB Administrator [Wed, 21 May 2025 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks ago[gdb/testsuite] Fix gdb.dwarf2/dw-form-strx-out-of-bounds.exp with make-check-all.sh
Tom de Vries [Tue, 20 May 2025 09:10:29 +0000 (11:10 +0200)] 
[gdb/testsuite] Fix gdb.dwarf2/dw-form-strx-out-of-bounds.exp with make-check-all.sh

I forgot to run test-case gdb.dwarf2/dw-form-strx-out-of-bounds.exp with
make-check-all.sh, and consequently failed to notice that it fails with for
instance target board fission-dwp.

The test-case does:
...
source $srcdir/$subdir/dw-form-strx.exp.tcl
...
and in that tcl file, prepare_for_testing fails, so a -1 is returned, but
that is ignored by the source command.

Fix this by using require, but rather that testing the result of the source
command, communicate success by setting a global variable
prepare_for_testing_done.

Likewise in gdb.dwarf2/dw-form-strx.exp.

Also, the test-case gdb.dwarf2/dw-form-strx-out-of-bounds.exp fails for target
board readnow, because the DWARF error occurs during a different command than
expected.

Fix this by just skipping the test-case in that case.

Tested on x86_64-linux.

Reported-by: Simon Marchi <simark@simark.ca>
Approved-By: Tom Tromey <tom@tromey.com>
5 weeks ago[gdb/testsuite] Make gdb.debuginfod codespell-clean
Tom de Vries [Tue, 20 May 2025 09:05:55 +0000 (11:05 +0200)] 
[gdb/testsuite] Make gdb.debuginfod codespell-clean

Make gdb.debuginfod codespell-clean and add the dir to the pre-commit
configuration.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks ago[gdb/testsuite] Make gdb.guile codespell-clean
Tom de Vries [Tue, 20 May 2025 09:05:55 +0000 (11:05 +0200)] 
[gdb/testsuite] Make gdb.guile codespell-clean

Make gdb.guile codespell-clean and add the dir to the pre-commit
configuration.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks ago[gdb/testsuite] Make gdb.mi codespell-clean
Tom de Vries [Tue, 20 May 2025 09:05:55 +0000 (11:05 +0200)] 
[gdb/testsuite] Make gdb.mi codespell-clean

Make gdb.mi codespell-clean and add the dir to the pre-commit
configuration.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks ago[gdb/testsuite] Make gdb.opt codespell-clean
Tom de Vries [Tue, 20 May 2025 09:05:55 +0000 (11:05 +0200)] 
[gdb/testsuite] Make gdb.opt codespell-clean

Make gdb.opt codespell-clean and add the dir to the pre-commit
configuration.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks ago[gdb/testsuite] Make gdb.pascal codespell-clean
Tom de Vries [Tue, 20 May 2025 09:05:54 +0000 (11:05 +0200)] 
[gdb/testsuite] Make gdb.pascal codespell-clean

Make gdb.pascal codespell-clean and add the dir to the pre-commit
configuration.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks ago[gdb/testsuite] Make gdb.reverse codespell-clean
Tom de Vries [Tue, 20 May 2025 09:05:54 +0000 (11:05 +0200)] 
[gdb/testsuite] Make gdb.reverse codespell-clean

Make gdb.reverse codespell-clean and add the dir to the pre-commit
configuration.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks ago[gdb/testsuite] Make gdb.rocm codespell-clean
Tom de Vries [Tue, 20 May 2025 09:05:54 +0000 (11:05 +0200)] 
[gdb/testsuite] Make gdb.rocm codespell-clean

Make gdb.rocm codespell-clean and add the dir to the pre-commit
configuration.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks ago[gdb/testsuite] Make gdb.stabs codespell-clean
Tom de Vries [Tue, 20 May 2025 09:05:54 +0000 (11:05 +0200)] 
[gdb/testsuite] Make gdb.stabs codespell-clean

Make gdb.stabs codespell-clean and add the dir to the pre-commit
configuration.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks ago[gdb/testsuite] Make gdb.xml codespell-clean
Tom de Vries [Tue, 20 May 2025 09:05:54 +0000 (11:05 +0200)] 
[gdb/testsuite] Make gdb.xml codespell-clean

Make gdb.xml codespell-clean and add the dir to the pre-commit
configuration.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks ago[gdb/testsuite] Make gdb.tui codespell-clean
Tom de Vries [Tue, 20 May 2025 09:05:54 +0000 (11:05 +0200)] 
[gdb/testsuite] Make gdb.tui codespell-clean

Make gdb.tui codespell-clean and add the dir to the pre-commit
configuration.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks ago[gdb/testsuite] Fix gdbsever typo
Tom de Vries [Tue, 20 May 2025 09:05:54 +0000 (11:05 +0200)] 
[gdb/testsuite] Fix gdbsever typo

I noticed a typo in the testsuite, twice: gdbsever.  Fix these.

Codespell doesn't detect it, so add a new file
gdb/contrib/codespell-dictionary.txt that contains a gdbsever->gdbserver
entry, and update gdb/contrib/setup.cfg to use it.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks ago[pre-commit] Add codespell-clean gdb/testsuite dirs
Tom de Vries [Tue, 20 May 2025 09:05:54 +0000 (11:05 +0200)] 
[pre-commit] Add codespell-clean gdb/testsuite dirs

The following gdb/testsuite subdirs are codespell-clean:
...
$ for d in gdb/testsuite/gdb.*; do \
      echo -n "$d:"; \
      codespell --config ./gdb/contrib/setup.cfg $d \
          | wc -l; \
  done 2>&1 \
  | grep :0
gdb/testsuite/gdb.ctf:0
gdb/testsuite/gdb.dap:0
gdb/testsuite/gdb.gdb:0
gdb/testsuite/gdb.go:0
gdb/testsuite/gdb.modula2:0
gdb/testsuite/gdb.objc:0
gdb/testsuite/gdb.opencl:0
gdb/testsuite/gdb.perf:0
gdb/testsuite/gdb.replay:0
gdb/testsuite/gdb.server:0
gdb/testsuite/gdb.testsuite:0
...

Add them to the pre-commit configuration.

Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agolibiberty: sync with gcc
Andreas Schwab [Wed, 14 May 2025 10:44:08 +0000 (12:44 +0200)] 
libiberty: sync with gcc

Import the following commits from GCC as of r16-614-g9d039eff453f77:
31dd621796f libiberty: add ldirname function
f3d07779fdb libiberty: Append <libgen.h> to AC_CHECK_DECLS [PR119218].
90183362524 libiberty, gcc: Add memrchr to libiberty and use it [PR119283].
43717ee9064 libiberty: Fix off-by-one when collecting range expression

5 weeks agoubsan: undefined shift in loongarch_elf_add_sub_reloc_uleb128
Alan Modra [Tue, 20 May 2025 05:52:13 +0000 (15:22 +0930)] 
ubsan: undefined shift in loongarch_elf_add_sub_reloc_uleb128

An oss-fuzz testcase found:
runtime error: shift exponent 140 is too large for 32-bit type 'int'
OK, that's just a completely silly uleb, but we ought to be able to
handle 64 bits here.

* elfxx-loongarch.c (loongarch_elf_add_sub_reloc_uleb128): Formatting.
Don't left shift int.  Avoid shifts larger than bits in a bfd_vma.

5 weeks agoAutomatic date update in version.in
GDB Administrator [Tue, 20 May 2025 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks agosim: testsuite: Fix build with host GCC15
Dimitar Dimitrov [Sat, 3 May 2025 20:36:30 +0000 (23:36 +0300)] 
sim: testsuite: Fix build with host GCC15

Simulator testsuite build started failing with host GCC-15:

  bits-tst.c:323:1: error: function declaration isn’t a prototype [-Werror=strict-prototypes]
  bits-tst.c: In function ‘main’:
  bits-tst.c:323:1: error: old-style function definition [-Werror=old-style-definition]

Fix by including string.h to get the required prototypes, and changing
main's declaration to modern C.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
Approved-By: Tom Tromey <tom@tromey.com>
5 weeks agoubsan: integer overflow in s_fill
Alan Modra [Sun, 18 May 2025 10:10:34 +0000 (19:40 +0930)] 
ubsan: integer overflow in s_fill

Silence ubsan warning.  We don't worry about wrap-around in most
places that adjust abs_section_offset, so don't fuss over an overflow
in the multiplication here.

* read.c (s_fill): Replace "long" vars with offsetT and valueT.
Avoid signed overflow calculating abs_section_offset.

5 weeks agoRISC-V: Add implication from the XTheadZvamo extension
Tsukasa OI [Sun, 18 May 2025 04:35:16 +0000 (04:35 +0000)] 
RISC-V: Add implication from the XTheadZvamo extension

T-Head/XuanTie's vector extension documentation states that their vector
extensions are based on the standard vector extension draft,
version 0.7.1.

In that draft, it is rare to see dependencies between extensions as
in the ratified version ... except: "Zvamo" -> "Zaamo".

cf. <https://github.com/riscvarchive/riscv-v-spec/releases/tag/0.7.1>

> If vector AMO instructions are supported, then the scalar Zaamo
> instructions (atomic operations from the standard A extension)
> must be present.

Note that using the words like "imply" or "depend" for extensions
weren't a common practice to represent dependencies between extensions
at the time the documentation was created.

The "Zaamo" was not ratified as an extension at the time but this is a
subset of the "A" extension and defines scalar AMO operations (while
"Zvamo" -- NOT in the ratified specification -- defines vector AMO ops).

The important part is that the T-Head/XuanTie's documentation just
states that the "Zvamo" (draft) extension is renamed to "XTheadZvamo".
It means, this implication should have been preserved in some way.

> The extension Zvamo is renamed to XTheadZvamo.

cf. <https://github.com/XUANTIE-RV/thead-extension-spec/blob/2.3.0/xtheadvector.adoc>

bfd/ChangeLog:

* elfxx-riscv.c (riscv_implicit_subsets): Add implication
"XTheadZvamo" -> "Zaamo".

gas/ChangeLog:

* testsuite/gas/riscv/imply.s: Add "XTheadZvamo" implication.
* testsuite/gas/riscv/imply.d: Ditto.

5 weeks agoRISC-V: Add implicit dependency to the XTheadVector extension
Tsukasa OI [Sun, 18 May 2025 04:35:16 +0000 (04:35 +0000)] 
RISC-V: Add implicit dependency to the XTheadVector extension

While this dependency is not directly stated in the documentation,
the XTheadVector extension cannot work without the Zicsr extension
(the documentation does not specify CSR access instruction subset
either as in the Zkr extension or the seed CSR section in the manual).

Also, making an implication to the Zicsr extension is in parity with
the ratified vector extensions (in GNU Binutils, the Zve32x extension --
a dependency of V -- depends on the Zvl32b and Zicsr extensions).

This commit adds this implicit dependency.

bfd/ChangeLog:

* elfxx-riscv.c (riscv_implicit_subsets): Add implicit
dependency "XTheadVector" -> "Zicsr".

gas/ChangeLog:

* testsuite/gas/riscv/imply.s: Add implicit "XTheadVector"
dependency to the "Zicsr" extension.
* testsuite/gas/riscv/imply.d: Ditto.

5 weeks agoRISC-V: Wider conflicts with the XTheadVector extension
Tsukasa OI [Sun, 18 May 2025 04:35:16 +0000 (04:35 +0000)] 
RISC-V: Wider conflicts with the XTheadVector extension

T-Head/XuanTie's "XTheadVector" is based on a draft version of the now
standard vector extensions and it conflicts with not just the "V"
extension but all of its subsets.

This commit makes "XTheadVector" conflict with the "Zve32x" extension,
which is the smallest subset of the standard vector extensions.  Still,
a reference to "V" is preserved in the error message
as the documentation suggests:

> Therefore, the XTheadVector extension and the V extension are
> in conflict.

cf. <https://github.com/XUANTIE-RV/thead-extension-spec/blob/2.3.0/xtheadvector.adoc>

Note that, instructions in the "XTHeadZvamo" extension currently has
no conflicts with other extensions, even after addition of the "Zabha"
extension.

bfd/ChangeLog:

* elfxx-riscv.c (riscv_parse_check_conflicts):
Make "XTheadVector" conflict with not just "V" but its subsets.

gas/ChangeLog:

* testsuite/gas/riscv/x-thead-vector-fail.d: Test a vector
subset "Zve32x" to test failures.
* testsuite/gas/riscv/x-thead-vector-fail.l: Reflect change
in the error message.

5 weeks agos390: Simplify test for absolute symbol
Jens Remus [Mon, 19 May 2025 09:16:53 +0000 (11:16 +0200)] 
s390: Simplify test for absolute symbol

Simplify the test whether a symbol is absolute, by using the helper
bfd_is_abs_symbol.

bfd/
* elf64-s390.c (elf_s390_relocate_section): Use
bfd_is_abs_symbol to test whether symbol is absolute.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 weeks agos390: Prevent GOT access rewrite for misaligned symbols
Jens Remus [Mon, 19 May 2025 08:38:01 +0000 (10:38 +0200)] 
s390: Prevent GOT access rewrite for misaligned symbols

Dereferences of GOT slots with lgrl or lg for global symbols are
rewritten to larl to get get rid of the extra memory access.  However
this is invalid for:

- symbols marked for absolute addressing
- symbols at odd addresses (larl can handle only even addresses)

Commit e6213e09ed0e ("S/390: Prevent GOT access rewrite for certain
symbols") added checks for the above.  But instead of checking the
address of a symbol for being halfword aligned, it tries to deduce
this from whether the symbol value and section the symbol is defined
in are halfword aligned.  The way it is done has two issues:

1. The use of bfd_section_from_elf_index to obtain the section the
   symbol is defined in may not return the one that remains in the
   output.  For instance for COMDAT sections getting deduplicated
   the section retrieved using bfd_section_from_elf_index may not be
   the same as h->root.u.def.section.  If COMDAT sections of same
   group signature have different alignment properties the wrong
   one may be checked. This may then lead to an erroneous rewrite
   of lgrl %rX, sym@GOTENT to larl %rX, sym, although the symbol in
   the remaining section is not properly aligned, triggering an
   "relocation for misaligned symbol" error at link-time.

   This may for instance occur when mixing C++ modules compiled with
   GCC and Clang, as GCC emits a 2-byte alignment and Clang a 1-byte
   alignment for COMDAT sections containing type information:

     $ cat sample.cpp
     #include <typeinfo>
     struct A {};
     const std::type_info &q() { return typeid(A); }

     $ g++ -c sample.cpp -o sample_gcc.o
     $ clang++ -c sample.cpp -o sample_clang.o
     $ readelf -WS sample_gcc.o sample_clang.o

     Produces (reformatted and reduced):
     File           Name           Off    Size   ES Flg Lk Inf Al
     sample_gcc.o   .rodata._ZTS1A 000080 000004 00  AG  0   0  2
     sample_clang.o .rodata._ZTS1A 000058 000003 00  AG  0   0  1

2. The symbol may end up at an even address, if both the symbol value
   and the section defining the symbol are 1-byte aligned.  While this
   does not trigger an error, it fails an opportunity to rewrite a GOT
   access.

   In a Linux Kernel build this causes ~15k GOT accesses using lgrl to
   be skipped to be rewritten to larl.

Resolve both issues by simply checking whether the symbol address is
halfword aligned.  Do not check the symbol value nor section defining
the symbol for halfword alignment.

bfd/
PR ld/32969
* elf64-s390.c (elf_s390_relocate_section): Only rewrite
lgrl/lg from GOT to larl if symbol address is halfword aligned.

ld/testsuite/
PR ld/32969
* ld-s390/s390.exp (pr32969_64-1, pr32969_64-2): Add tests for
rewrite of GOT access when COMDAT section deduplication is
involved.
* ld-s390/pr32969_64-1.dd: New test for rewrite of GOT access
when COMDAT section deduplication is involved.
* ld-s390/pr32969_64-2.dd: Likewise.
* ld-s390/pr32969a.s: Likewise.
* ld-s390/pr32969b.s: Likewise.
* ld-s390/pr32969c.s: Likewise.

Bug: https://sourceware.org/PR32969
Fixes: e6213e09ed0e ("S/390: Prevent GOT access rewrite for certain symbols")
Reported-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 weeks agos390: Improve diagnostic for reloc against misaligned sym
Jens Remus [Mon, 19 May 2025 08:38:01 +0000 (10:38 +0200)] 
s390: Improve diagnostic for reloc against misaligned sym

Report the BFD in which a misaligned symbol is defined in the error
message.  This complements commit 906f69cf65da ("IBM zSystems: Issue
error for *DBL relocs on misaligned symbols").  While at it reword
the error message.

Old error message text (re-wrapped):
<sec-bfd>(<sec>+<off>): misaligned symbol `<sym>' (<addr>) for
                        relocation <rel>

New error message text (re-wrapped):
<sec-bfd>(<sec>+<off>): relocation <rel> against misaligned symbol
                        `<sym>' (<addr>) in <sym-bfd>

Note that the linker tests do not require to be updated, as they match
against the pattern ".*misaligned symbol.*", which has not changed in
the error message.

bfd/
PR ld/32969
* elf64-s390.c (elf_s390_relocate_section): Report BFD
in which a misaligned symbol is defined in error message.

Bug: https://sourceware.org/PR32969
Suggested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 weeks agogas: sframe: handle .cfi_undefined
Indu Bhagat [Mon, 19 May 2025 07:05:17 +0000 (00:05 -0700)] 
gas: sframe: handle .cfi_undefined

Fix PR gas/32952 - sframe: incorrect handling of .cfi_undefined in gas

In context of SFrame generation, it is incorrect to simply ignore all
.cfi_undefined.  We may ignore only those .cfi_undefined which are for
registers of no interest (similar to whats done for other CFI
directives).

gas/
        * gen-sframe.c (sframe_xlate_do_cfi_undefined): New definition.
        (sframe_do_cfi_insn): Handle .cfi_undefined.
gas/testsuite/
        * gas/cfi-sframe/cfi-sframe.exp: Add new tests.
        * gas/cfi-sframe/cfi-sframe-common-10.d: New test.
        * gas/cfi-sframe/cfi-sframe-common-10.s: New test.
* gas/cfi-sframe/cfi-sframe-x86_64-empty-4.d: New test.
* gas/cfi-sframe/cfi-sframe-x86_64-empty-4.s: New test.

5 weeks agogas: sframe: reword diagnostic to address ambiguity
Indu Bhagat [Mon, 19 May 2025 07:03:39 +0000 (00:03 -0700)] 
gas: sframe: reword diagnostic to address ambiguity

The current warning text of "skipping SFrame FDE" does not unabiguously
indicate that the SFrame FDE is not generated in the output section.
Reword the diagnostic to say "no SFrame FDE emitted" as requested.

Adjust the testcases for the updated warning.

5 weeks agogas: sframe: i386: have the backend specify the RA too
Indu Bhagat [Mon, 19 May 2025 07:01:29 +0000 (00:01 -0700)] 
gas: sframe: i386: have the backend specify the RA too

To process some CFI directives like .cfi_undefined and .cfi_same_value,
it is necessary for correctness to detect all cases when the register
used is one of SP, FP or RA.

Currently, the backends needed to specify the SFRAME_CFA_RA_REG only in
the case of those ABIs where RA tracking was necessary, e.g. AArch64.
For AMD64, since the return address is always at a fixed offset from the
CFA, RA tracking was disabled.

The backends must now specify the applicable return address register via
SFRAME_CFA_RA_REG.  This is necessary so that SFrame generation code can
then properly handle the cases when RA is used like so:
   .cfi_undefined <RA>
or,
   .cfi_same_value <RA>

Detecting these cases is necessary for correctness.  E.g., on AMD64, we
need to skip FDE generation as the above constructs cannot be
represented in SFrame yet.

This change is a prerequisite to fixing the two PRs:

PR gas/32952 - sframe: incorrect handling of .cfi_undefined in gas
PR gas/32953 - sframe: incorrect handling of .cfi_same_value in gas

In the SFrame generation code in gen-sframe.c, instead of using
SFRAME_FRE_RA_TRACKING ifdef's, we now simply rely on the API
sframe_ra_tracking_p () to detect if RA-tracking is enabled for the
target.

While at it, use const variables for x86 backend.

ChangeLog:

        * gas/config/tc-i386.c (x86_sframe_cfa_ra_reg): New definition.
        * gas/config/tc-i386.h (REG_RA): New definition.
(SFRAME_CFA_RA_REG): New declaration.
        * gas/gen-sframe.c (SFRAME_FRE_RA_TRACKING): Remove.

5 weeks agoAutomatic date update in version.in
GDB Administrator [Mon, 19 May 2025 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks agobfd: Handle note of type NT_X86_SHSTK
Christina Schimpe [Thu, 13 Feb 2025 16:40:23 +0000 (16:40 +0000)] 
bfd: Handle note of type NT_X86_SHSTK

5 weeks agoAutomatic date update in version.in
GDB Administrator [Sun, 18 May 2025 00:00:11 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 weeks agoAutomatic date update in version.in
GDB Administrator [Sat, 17 May 2025 00:00:11 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 weeks agoUpdate comment for find_field_create_baton
Tom Tromey [Fri, 16 May 2025 14:16:48 +0000 (08:16 -0600)] 
Update comment for find_field_create_baton

Andrew pointed out that a recent commit neglected to update the
comment for find_field_create_baton.  This patch fixes the oversight.

6 weeks agoubsan: emit_inc_line_addr integer overflow
Alan Modra [Fri, 16 May 2025 09:04:31 +0000 (18:34 +0930)] 
ubsan: emit_inc_line_addr integer overflow

Commit 07cf922195d1 fixed the one in size_inc_line_addr.  Silly me
missed the identical overflow in emit_inc_line_addr

6 weeks agogas .align limit
Alan Modra [Fri, 16 May 2025 03:01:39 +0000 (12:31 +0930)] 
gas .align limit

At the moment we allow alignment of up to half the address space,
which is stupidly large and results in OOM on x86_64.  Change that to
1G alignment in text sections.  Also fix the warning message on
exceeding max allowed alignment.

* read.c (TC_ALIGN_LIMIT): Limit to 30 in text sections.
(s_align): Correct "alignment too large" value.

6 weeks agold testsuite fail with --disable-plugins
Alan Modra [Fri, 16 May 2025 00:06:33 +0000 (09:36 +0930)] 
ld testsuite fail with --disable-plugins

* testsuite/config/default.exp (dep_plug_opt): Don't set unless
check_plugin_api_available returns true.

6 weeks agogas: adjust a comparison in s_align()
Jan Beulich [Fri, 16 May 2025 10:32:39 +0000 (12:32 +0200)] 
gas: adjust a comparison in s_align()

In 344b1e0f5f79 ("gas: range-check 3rd argument of .align et al") I
neglected to consider compilers which warn about signed/unsigned
mismatches in comparisons (which is somewhat odd when the signed value is
already known to be non-negative).

6 weeks agogas: range-check 3rd argument of .align et al
Jan Beulich [Fri, 16 May 2025 08:37:46 +0000 (10:37 +0200)] 
gas: range-check 3rd argument of .align et al

Negative values would have been silently converted to large positive
ones, which may not be the user's intention. Similarly overly large
values would have been silently truncated. Warn them instead, and zap
such values.

6 weeks agold/doc: Remove '.info' suffix in @ref, etc
Collin Funk [Fri, 16 May 2025 08:37:16 +0000 (10:37 +0200)] 
ld/doc: Remove '.info' suffix in @ref, etc

Texinfo 7.2 began showing warnings like:

    ld.texi:1026: warning: do not set .info suffix in reference for manual `gcc.info'
    ld.texi:9689: warning: do not set .info suffix in reference for manual `binutils.info'

The Texinfo developers plan to stop removing the '.info' suffix
internally in a future release so without this patch the references will
break in the future.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
6 weeks agobinutils/doc: Remove '.info' suffix in @ref, etc
Collin Funk [Fri, 16 May 2025 08:37:04 +0000 (10:37 +0200)] 
binutils/doc: Remove '.info' suffix in @ref, etc

Texinfo 7.2 began showing warnings like:

    binutils.texi:882: warning: do not set .info suffix in reference for manual `ld.info'
    binutils.texi:1365: warning: do not set .info suffix in reference for manual `ld.info'

The Texinfo developers plan to stop removing the '.info' suffix
internally in a future release so without this patch the references will
break in the future.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
6 weeks agox86: improve matching diagnostics when %st is involved
Jan Beulich [Fri, 16 May 2025 08:32:19 +0000 (10:32 +0200)] 
x86: improve matching diagnostics when %st is involved

Diagnosing operand size vs operand type mismatches doesn't work very
well when GPRs and FPRs are in the same register class, distinguished
just by size. Introduce a separate RegFP class.

6 weeks agox86: move Anysize check in operand_size_match()
Jan Beulich [Fri, 16 May 2025 08:31:35 +0000 (10:31 +0200)] 
x86: move Anysize check in operand_size_match()

Anysize is applicable to memory operands only. Move the check to where
memory operands are handled. (The RegSIMD part there was questionable
altogether.)

6 weeks agox86: improve matching diagnostics when "accumulator" registers are involved
Jan Beulich [Fri, 16 May 2025 08:27:55 +0000 (10:27 +0200)] 
x86: improve matching diagnostics when "accumulator" registers are involved

In templates, the expectation of an "accumulator" register to be used is
expressed solely by operand size; there's no "class" specifier there.
Hence operand_size_match() is too eager in invoking
match_{operand,simd}_size(), resulting in "operand size mismatch" errors
when it's the type (of register), not the size that's wrong.
Interestingly adjustments there alone lead to no error at all then: To
"compensate", operand_type_match() needs to disambiguate register types
when register instances are specified in the template (matching the
actual operand), by checking a match (overlap) in operand sizes.

6 weeks agox86: fold Accum checking in operand_size_match()
Jan Beulich [Fri, 16 May 2025 08:27:20 +0000 (10:27 +0200)] 
x86: fold Accum checking in operand_size_match()

There's little point invoking match_{operand,simd}_size() twice per
loop; in fact the SIMD case with D set simply doesn't exist. Amend the
checks by one looking at the given operand, just like we already have
been doing for memory ones.

6 weeks agox86: improve matching diagnostics
Jan Beulich [Fri, 16 May 2025 08:26:45 +0000 (10:26 +0200)] 
x86: improve matching diagnostics

Many times in the past I was puzzled by seeing "operand size mismatch"
when really "operand type mismatch" would be far more appropriate. As it
turns out, there were at least two flaws: In the single operand case we
didn't propagate i.error to match_template()'s local specific_error when
noticing a type mismatch. And then operand_size_match() was too eager in
invoking match_mem_size(): Especially the Unspecified attribute can get
in the way there when the expected operand isn't a memory one (and hence
Unspecified would not be set in the operand template, whereas it's
uniformly set for memory operands in AT&T syntax).

(In the x86-64-lkgs-inval testcase the particular error for the two
bogus Intel syntax forms doesn't really matter; all we ought to care
about there isthat there is _some_ error.)

6 weeks agox86: drop bogus accumulator check
Jan Beulich [Fri, 16 May 2025 08:25:38 +0000 (10:25 +0200)] 
x86: drop bogus accumulator check

Accum is an "instance", not a "class". With present enumerator values of
Reg and Accum, the 2nd check simply did the same as the first. In fact
checking for the accumulator (%rax) isn't necessary here at all, because
there's no case where an individual template would permit alternatively
a memory operand or the (qword) accumulator; only "any GPR" is ever
being paired with "memory".

6 weeks agoRISC-V: check offsets when linker relaxation is disabled
Tsukasa OI [Tue, 13 May 2025 08:14:01 +0000 (08:14 +0000)] 
RISC-V: check offsets when linker relaxation is disabled

The assembler partially relied on the linker to check whether the
offset is valid.  However, some optimization logic (added later)
removes relocations relative to local symbols without checking offsets.

For instance, it caused following code to silently emit wrong jumps
(to the jump instruction "." itself) without relocations:

> .option norelax
> j .+0x200000   # J (or JAL) instruction cannot encode this offset.
> j .+1          # Jump to odd address is not valid.

This commit adds offset checks where necessary.

gas/ChangeLog:

* config/tc-riscv.c (md_apply_fix): Check offsets when the
relocation relative to a local symbol is being optimized out.
* testsuite/gas/riscv/no-relax-branch-offset-fail.s: Failure
case where the branch offset is invalid.
* testsuite/gas/riscv/no-relax-branch-offset-fail.d: Ditto.
* testsuite/gas/riscv/no-relax-branch-offset-fail.l: Ditto.
* testsuite/gas/riscv/no-relax-branch-offset-ok.s: Border case.
* testsuite/gas/riscv/no-relax-branch-offset-ok.d: Ditto.
* testsuite/gas/riscv/no-relax-pcrel-offset-fail-64.s: Failure
case only on RV64 where the PC-relative offset exceed limits.
* testsuite/gas/riscv/no-relax-pcrel-offset-fail-64.d: Ditto.
* testsuite/gas/riscv/no-relax-pcrel-offset-fail-64.l: Ditto.
* testsuite/gas/riscv/no-relax-pcrel-offset-fail-not-32.d: Test
case for RV32 so that no errors occur.
* testsuite/gas/riscv/no-relax-pcrel-offset-ok.s: Border case.
* testsuite/gas/riscv/no-relax-pcrel-offset-ok.d: Ditto.

6 weeks agoRISC-V: Add zilsd & zclsd support
dysun [Fri, 9 May 2025 08:22:50 +0000 (16:22 +0800)] 
RISC-V: Add zilsd & zclsd support

Ref: https://github.com/riscv/riscv-zilsd/blob/main/zilsd.adoc

Signed-off-by: dysun <sundongya@nucleisys.com>
Co-developed-by: LIU Xu <liuxu@nucleisys.com>
Co-developed-by: ZHAO Fujin <zhaofujin@nucleisys.com>
6 weeks agoAutomatic date update in version.in
GDB Administrator [Fri, 16 May 2025 00:00:18 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 weeks agogas: sframe: avoid creating more symbols than necessary for FRE offset
Indu Bhagat [Thu, 15 May 2025 19:21:05 +0000 (12:21 -0700)] 
gas: sframe: avoid creating more symbols than necessary for FRE offset

Each SFrame FDE contains an offset to the start of its respective SFrame
FREs in the sfde_func_start_fre_off field.  To generate this offset,
fre_symbols[] array is being used.  The number of elements of this array
is currently set to the total number of SFrame FREs in the entire SFrame
section.  This is more than unnecessary.  We only need to track as many
points as the number of SFrame FDEs.

gas/
* gen-sframe.c (output_sframe_internal):  Size fde_fre_symbols
with the number of SFrame FDEs.

6 weeks agoFix regression with dynamic array bounds
Tom Tromey [Tue, 13 May 2025 19:41:26 +0000 (13:41 -0600)] 
Fix regression with dynamic array bounds

Kévin discovered that commit ba005d32b0f ("Handle dynamic field
properties") regressed a test in the internal AdaCore test suite.

The problem here is that, when writing that patch, I did not consider
the case where an array type's bounds might come from a member of a
structure -- but where the array is not defined in the structure's
scope.

In this scenario the field-resolution logic would trip this condition:

  /* Defensive programming in case we see unusual DWARF.  */
  if (fi == nullptr)
    return nullptr;

This patch reworks this area, partly backing out that commit, and
fixes the problem.

In the new code, I chose to simply duplicate the field's location
information.  This isn't totally ideal, in that it might result in
multiple copies of a baton.  However, this seemed nicer than tracking
the DIE/field correspondence for every field in every CU -- my
thinking here is that this particular dynamic scenario is relatively
rare overall.  Also, if the baton cost does prove onerous, we could
intern the batons somewhere.

Regression tested on x86-64 Fedora 41.  I also tested this using the
AdaCore internal test suite.

Tested-By: Simon Marchi <simon.marchi@efficios.com>
6 weeks agold: rename ldirname to stat_ldirname
Andreas Schwab [Wed, 14 May 2025 15:09:45 +0000 (17:09 +0200)] 
ld: rename ldirname to stat_ldirname

It conflicts with the ldirname function that will be added in the next
libiberty sync.

ld/:
* ldlang.c (stat_ldirname): Rename from ldirname, all uses
changed.

6 weeks agogdb: rename ldirname to gdb_ldirname
Andreas Schwab [Wed, 14 May 2025 15:08:52 +0000 (17:08 +0200)] 
gdb: rename ldirname to gdb_ldirname

It conflicts with the ldirname function that will be added in the next
libiberty sync.

6 weeks agobinutils: Don't complain plugin with all LTO sections removed
H.J. Lu [Wed, 14 May 2025 23:30:06 +0000 (07:30 +0800)] 
binutils: Don't complain plugin with all LTO sections removed

When all LTO sections have been removed, the BFD lto_type is set to
lto_non_ir_object by bfd_set_lto_type.  In this case, don't complain
needing a plugin when seeing a LTO slim symbol.

bfd/

PR binutils/32967
* archive.c (_bfd_compute_and_write_armap): Call
bfd_lto_slim_symbol_p to check LTO slim symbol.
* bfd-in2.h: Generated.
* bfd.c (bfd_lto_slim_symbol_p): New.

binutils/

PR binutils/32967
* nm.c (filter_symbols): Call bfd_lto_slim_symbol_p to check
LTO slim symbol.

ld/

PR binutils/32967
* testsuite/ld-plugin/lto-binutils.exp: Run PR binutils/32967
tests.
* testsuite/ld-plugin/strip-1a-s-all.nd: New file.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
6 weeks agoAutomatic date update in version.in
GDB Administrator [Thu, 15 May 2025 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 weeks agogas .file 0 vs. dwarf5
Alan Modra [Wed, 14 May 2025 22:59:37 +0000 (08:29 +0930)] 
gas .file 0 vs. dwarf5

Support added in commit 3417bfca676f for dwarf5 directory table 0
assumed that .file 0 was always the first debug .file directive.
That's not necessarily true.

* dwarf2dbg.c (get_directory_table_entry): Don't assume entry
        1 is available after putting DW_AT_comp_dir in entry 0.  Pass
pwd as file0_dirname to recursive call to avoid another
        getpwd in the case file0_dirname is NULL.

6 weeks agotestsuite: fix gdb_exit for MinGW target
Rohr, Stephan [Mon, 24 Mar 2025 13:05:33 +0000 (13:05 +0000)] 
testsuite: fix gdb_exit for MinGW target

GDB is not properly exited via 'remote_close host' when running the
testsuite in a MinGW environment.  Use the 'quit' command to properly
exit the GDB debugging session.

Approved-By: Tom Tromey <tom@tromey.com>
6 weeks agotestsuite: get windows PID on MinGW target
Rohr, Stephan [Thu, 20 Mar 2025 13:07:15 +0000 (14:07 +0100)] 
testsuite: get windows PID on MinGW target

Also translate the MinGW PID to the Windows PID when running on a MinGW
target.

Approved-By: Tom Tromey <tom@tromey.com>
6 weeks agoFix create_breakpoint_parse_arg_string self-test
Tom Tromey [Mon, 12 May 2025 17:30:33 +0000 (11:30 -0600)] 
Fix create_breakpoint_parse_arg_string self-test

The emoji patch broke the create_breakpoint_parse_arg_string self-test
when gdb is running on a suitable terminal.  The problem is that the
test case doesn't take the error prefix string into account.

This patch fixes the test by having it compare the exception message
directly, rather than relying on the result of exception_print.  I did
try a different approach, of having the test mimic exception_print,
but this one seemed cleaner to me.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
6 weeks agoAdd initializers to field_of_this_result
Tom Tromey [Wed, 14 May 2025 13:59:16 +0000 (07:59 -0600)] 
Add initializers to field_of_this_result

This adds initializers to field_of_this_result, so that certain spots
don't have to memset it.  This approach seems safer and cleaner.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
6 weeks agoFix some pre-commit nits in gdb/__init__.py
Tom Tromey [Tue, 13 May 2025 21:02:04 +0000 (15:02 -0600)] 
Fix some pre-commit nits in gdb/__init__.py

I noticed that pre-commit has some complaints (flake8 and codespell)
about gdb/__init__.py.  This patch fixes these.

Approved-By: Tom de Vries <tdevries@suse.de>
6 weeks agoresbin: don't pass NULL as printf %s arg
Alan Modra [Wed, 14 May 2025 08:07:42 +0000 (17:37 +0930)] 
resbin: don't pass NULL as printf %s arg

Fix three place where a NULL could be passed to "toosmall".

6 weeks agogas .file sanity check
Alan Modra [Wed, 14 May 2025 05:18:33 +0000 (14:48 +0930)] 
gas .file sanity check

Currently we allow insane file numbers that cause gas to allocate up
to 4G of memory for a file array.  Trim that a little to 1G (which
still allows insane file numbers up to 33554431), and tidy function
parameter types so that we only need one file number sanity check.

* dwarf2dbg.c (assign_file_to_slot): Take a valueT file number.
Reduce max files array size.
(allocate_filename_to_slot): Take a valueT file number.
(dwarf2_directive_filename): Don't duplicate file number
sanity check here.

6 weeks agoRemove Marcus Shawcroft from the MAINTAINERS file
Richard Earnshaw [Wed, 14 May 2025 10:45:25 +0000 (11:45 +0100)] 
Remove Marcus Shawcroft from the MAINTAINERS file

Marcus has resigned from the project.