]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
16 months agoPR31314, chew crashing on use of uninitialized value
Alan Modra [Mon, 29 Jan 2024 23:08:56 +0000 (09:38 +1030)] 
PR31314, chew crashing on use of uninitialized value

The "drop" call in wrap_comment already increments pc.  Defining DOCDD
in proto.str is a warning fix.

PR 31314
* chew.c (wrap_comment): Don't increment pc.
* proto.str (DOCDD): Define.

16 months agosim: bpf: remove support for ldinddw and ldabsdw instructions
Jose E. Marchesi [Mon, 29 Jan 2024 21:25:19 +0000 (22:25 +0100)] 
sim: bpf: remove support for ldinddw and ldabsdw instructions

This patch removes support for the two instructions above from the GNU
simulator, including the corresponding tests.  These instructions do
not really exist in BPF and are not recognized as such by the kernel
verifier.  This has now been pointed out during the standardization of
the BPF ISA.

Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
16 months agogdb: Use SYM_DOMAIN instead of DOMAIN when calling sym-domains.def
Lancelot SIX [Mon, 29 Jan 2024 18:28:52 +0000 (18:28 +0000)] 
gdb: Use SYM_DOMAIN instead of DOMAIN when calling sym-domains.def

Since commit 6771fc6f1d9 "Use a .def file for domain_enum", the
sym-domains.def file has been introduced, and requires the user to
define the DOMAIN(x) macro.

On older systems (centos-7 with glibc-2.17 for example), this DOMAIN
macro conflicts with another macro defined in /usr/include/math.h.

Fix this conflict by changing sym-domains.def to use a macro named
SYM_DOMAIN instead of DOMAIN.

Change-Id: I679df30e2bd2f4333343f16bbd2a3511a37550a3
Approved-By: Tom Tromey <tom@tromey.com>
16 months agobfd: restore Threading menu entry in bfd.texi
Jose E. Marchesi [Mon, 29 Jan 2024 18:47:28 +0000 (19:47 +0100)] 
bfd: restore Threading menu entry in bfd.texi

I mistakenly vandalized bfd.texi in the commit
0c45feb159a14ca4cb50cfbf45eacaf5a6cecf2b by removing an entry in the
manual menu.  This commit reverts that thunk.

16 months agobpf: there is no ldinddw nor ldabsdw instructions
Jose E. Marchesi [Mon, 29 Jan 2024 18:22:41 +0000 (19:22 +0100)] 
bpf: there is no ldinddw nor ldabsdw instructions

There are no legacy ldind nor ldabs BPF instructions with BPF_SIZE_DW.
For some reason we were (incorrectly) supporting these.  This patch
updates the opcodes so the instructions get removed and modifies the
GAS manual and testsuite accordingly.

See discussion at
https://lore.kernel.org/bpf/110aad7a-f8a3-46ed-9fda-2f8ee54dcb89@linux.dev

Tested in bpf-uknonwn-none target, x86-64-linux-gnu host.

include/ChangeLog:

2024-01-29  Jose E. Marchesi  <jose.marchesi@oracle.com>

* opcode/bpf.h (enum bpf_insn_id): Remove BPF_INSN_LDINDDW and
BPF_INSN_LDABSDW instructions.

opcodes/ChangeLog:

2024-01-29  Jose E. Marchesi  <jose.marchesi@oracle.com>

* bpf-opc.c (bpf_opcodes): Remove BPF_INSN_LDINDDW and
BPF_INSN_LDABSDW instructions.

gas/ChangeLog:

2024-01-29  Jose E. Marchesi  <jose.marchesi@oracle.com>

* doc/c-bpf.texi (BPF Instructions): There is no indirect 64-bit
load instruction.
(BPF Instructions): There is no absolute 64-bit load instruction.
* testsuite/gas/bpf/mem.s: Update test accordingly.
* testsuite/gas/bpf/mem-be-pseudoc.d: Likewise.
* testsuite/gas/bpf/mem-be.d: Likewise.
* testsuite/gas/bpf/mem-pseudoc.d: Likewise.
* testsuite/gas/bpf/mem-pseudoc.s: Likewise.
* testsuite/gas/bpf/mem.d: Likewise.
* testsuite/gas/bpf/mem.s: Likewise.

16 months agoUpdate release making documentation after 2.42 release
Nick Clifton [Mon, 29 Jan 2024 16:11:52 +0000 (16:11 +0000)] 
Update release making documentation after 2.42 release

16 months agoRemove support for the beos file format
Nick Clifton [Mon, 29 Jan 2024 16:07:45 +0000 (16:07 +0000)] 
Remove support for the beos file format

16 months agoFix backtrace limit stopping on inline frame
Hannes Domani [Mon, 29 Jan 2024 14:31:44 +0000 (15:31 +0100)] 
Fix backtrace limit stopping on inline frame

If you have set up a backtrace limit, and the backtrace stops
because of this in an inline frame with arguments, you get an
assertion failure:
```
(gdb) bt
(gdb) set backtrace limit 2
(gdb) bt
C:/src/repos/binutils-gdb.git/gdb/frame.c:3346: internal-error: reinflate: Assertion `m_cached_level >= -1' failed.
```

And if this one is fixed, there is another one as well:
```
(gdb) bt
C:/src/repos/binutils-gdb.git/gdb/dwarf2/loc.c:1160: internal-error: dwarf_expr_reg_to_entry_parameter: Assertion `frame != NULL' failed.
```

The reason for both of them is this kind of loop:
```
  while (get_frame_type (frame) == INLINE_FRAME)
    frame = get_prev_frame (frame);
```
Since get_prev_frame respects the backtrace limit, it will return
NULL, and from there on you can't continue.
This changes these loops to use get_prev_frame_always instead, so
you always get a non-inline frame in the end.

With this backtrace works:
```
(gdb) bt
(gdb)
```

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29865
Approved-By: Andrew Burgess <aburgess@redhat.com>
16 months agoUpdated French translations for GOLD and LD
Nick Clifton [Mon, 29 Jan 2024 11:32:15 +0000 (11:32 +0000)] 
Updated French translations for GOLD and LD

16 months agoAutomatic date update in version.in
GDB Administrator [Mon, 29 Jan 2024 00:00:28 +0000 (00:00 +0000)] 
Automatic date update in version.in

16 months agoDocument new Python and Guile constants
Tom Tromey [Sat, 18 Nov 2023 17:00:12 +0000 (10:00 -0700)] 
Document new Python and Guile constants

This documents the new Python and Guile constants introduced earlier
in this series.

Approved-By: Eli Zaretskii <eliz@gnu.org>
16 months agoRefine search in cp_search_static_and_baseclasses
Tom Tromey [Tue, 19 Sep 2023 23:51:36 +0000 (17:51 -0600)] 
Refine search in cp_search_static_and_baseclasses

This changes cp_search_static_and_baseclasses to only search for
types, functions, and modules.  The latter two cases were discovered
by regression testing.  I found it somewhat surprising the Fortran
name lookup ends up in this code, but did not attempt to change this.

16 months agoOnly search for functions in rust_structop::evaluate_funcall
Tom Tromey [Tue, 19 Sep 2023 23:50:17 +0000 (17:50 -0600)] 
Only search for functions in rust_structop::evaluate_funcall

This changes rust_structop::evaluate_funcall to only search for
functions.

16 months agoOnly search types in lookup_typename
Tom Tromey [Tue, 19 Sep 2023 23:46:38 +0000 (17:46 -0600)] 
Only search types in lookup_typename

This changes lookup_typename to only look for types.  The check for
LOC_TYPEDEF can now also be removed, because only types will appear in
TYPE_DOMAIN.

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

16 months agoOnly search types in cp_lookup_rtti_type
Tom Tromey [Tue, 19 Sep 2023 23:39:31 +0000 (17:39 -0600)] 
Only search types in cp_lookup_rtti_type

This changes cp_lookup_rtti_type to only search for types -- not
functions or variables.  Due to the symbol-matching hack, this could
just use SEARCH_TYPE_DOMAIN, but I think it's better to be clear; also
I hold on to some hope that perhaps the hack can someday be removed.

16 months agoUse a function-domain search in inside_main_func
Tom Tromey [Tue, 19 Sep 2023 23:35:08 +0000 (17:35 -0600)] 
Use a function-domain search in inside_main_func

This changes inside_main_func to search only for functions.

16 months agoOnly look for functions in expand_symtabs_for_function
Tom Tromey [Sat, 2 Sep 2023 15:42:44 +0000 (09:42 -0600)] 
Only look for functions in expand_symtabs_for_function

This changes expand_symtabs_for_function to only look in the function
domain.

16 months agoOnly search for "main" as a function
Tom Tromey [Sat, 2 Sep 2023 15:32:49 +0000 (09:32 -0600)] 
Only search for "main" as a function

This changes find_main_name to restrict its search to the function
domain.

16 months agoSimplify some symbol searches in linespec.c
Tom Tromey [Fri, 1 Sep 2023 20:05:04 +0000 (14:05 -0600)] 
Simplify some symbol searches in linespec.c

This simplifies some symbol searches in linespec.c.  In particular,
two separate searches here can now be combined into one, due to the
new use of flags.

Arguably the STRUCT_DOMAIN searches should perhaps not even be done.
Only C really has these, and C doesn't have member functions.
However, it seems relatively harmless -- and clearly compatible -- to
leave this in.

16 months agoSimplify some symbol searches in Ada code
Tom Tromey [Fri, 17 Nov 2023 01:02:14 +0000 (18:02 -0700)] 
Simplify some symbol searches in Ada code

This changes some of the Ada code to simplify symbol searches.  For
example, if a function is being looked for, the search is narrowed to
use SEARCH_FUNCTION_DOMAIN rather than SEARCH_VFT.  In one spot, a
search of the "struct" domain is removed, because Ada does not have a
tag domain.

16 months agoUse the new symbol domains
Tom Tromey [Thu, 2 Mar 2023 14:44:11 +0000 (07:44 -0700)] 
Use the new symbol domains

This patch changes the DWARF reader to use the new symbol domains.  It
also adjusts many bits of associated code to adapt to this change.

The non-DWARF readers are updated on a best-effort basis.  This is
somewhat simpler since most of them only support C and C++.  I have no
way to test a few of these.

I went back and forth a few times on how to handle the "tag"
situation.  The basic problem is that C has a special namespace for
tags, which is separate from the type namespace.  Other languages
don't do this.  So, the question is, should a DW_TAG_structure_type
end up in the tag domain, or the type domain, or should it be
language-dependent?

I settled on making it language-dependent using a thought experiment.
Suppose there was a Rust compiler that only emitted nameless
DW_TAG_structure_type objects, and specified all structure type names
using DW_TAG_typedef.  This DWARF would be correct, in that it
faithfully represents the source language -- but would not work with a
purely struct-domain implementation in gdb.  Therefore gdb would be
wrong.

Now, this approach is a little tricky for C++, which uses tags but
also enters a typedef for them.  I notice that some other readers --
like stabsread -- actually emit a typedef symbol as well.  And, I
think this is a reasonable approach.  It uses more memory, but it
makes the internals simpler.  However, DWARF never did this for
whatever reason, and so in the interest of keeping the series slightly
shorter, I've left some C++-specific hacks in place here.

Note that this patch includes language_minimal as a language that uses
tags.  I did this to avoid regressing gdb.dwarf2/debug-names-tu.exp,
which doesn't specify the language for a type unit.  Arguably this
test case is wrong.

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

16 months agoRemove old symbol_matches_domain
Tom Tromey [Fri, 1 Sep 2023 20:29:33 +0000 (14:29 -0600)] 
Remove old symbol_matches_domain

Nothing calls the variant of symbol_matches_domain that accepts a
domain_enum for searching, so this patch removes it and the
corresponding symbol::matches.

16 months agoRemove some obsolete Python constants
Tom Tromey [Sat, 9 Sep 2023 14:35:26 +0000 (08:35 -0600)] 
Remove some obsolete Python constants

The Python code has exported some constants, but they are no longer
documented, and were never useful.  This patch removes them.

16 months agoUse domain_search_flags in lookup_symbol et al
Tom Tromey [Fri, 31 Mar 2023 05:00:26 +0000 (23:00 -0600)] 
Use domain_search_flags in lookup_symbol et al

This changes lookup_symbol and associated APIs to accept
domain_search_flags rather than a domain_enum.

Note that this introduces some new constants to Python and Guile.  I
chose to break out the documentation patch for this, because the
internals here do not change until a later patch, and it seemed
simpler to patch the docs just once, rather than twice.

16 months agoUse domain_search_flags in lookup_global_symbol_language
Tom Tromey [Sat, 11 Mar 2023 14:55:42 +0000 (07:55 -0700)] 
Use domain_search_flags in lookup_global_symbol_language

This changes quick_symbol_functions::lookup_global_symbol_language to
accept domain_search_flags rather than just a domain_enum, and fixes
up the fallout.

To avoid introducing any regressions, any code passing VAR_DOMAIN now
uses SEARCH_VFT.

That is, no visible changes should result from this patch.  However,
it sets the stage to refine some searches later on.

16 months agoIntroduce "scripting" domains
Tom Tromey [Sat, 9 Sep 2023 23:41:30 +0000 (17:41 -0600)] 
Introduce "scripting" domains

The Python and Guile code exposed the internal domain constants both
as attributes of symbols and as values to pass to lookup functions.

Now, perfect backward compatibility here can't be achieved: some
symbols are going to have domain changes by the end of this series.
However, it seemed to me that we can preserve lookups using the basic
domain values.

This patch implements this by exporting the "or"-able search constants
with an extra bit set.  Then it introduces some functions to convert
such constants to domain_search_flags.  This will be used by the
Python and Guile code, so that both old- and new-style lookups will
work properly; and while preserving the idea that the domain constants
can be compared to a symbol's domain.

16 months agoRemove a check of VAR_DOMAIN
Tom Tromey [Sat, 11 Mar 2023 05:16:51 +0000 (22:16 -0700)] 
Remove a check of VAR_DOMAIN

completion_list_add_symbol checks that the returned symbol has
VAR_DOMAIN, but also checks that its address class is LOC_BLOCK.  The
domain check is redundant -- only functions can possibly be LOC_BLOCK
-- and leaving this in place will cause a regression when combined
with a later patch in this series.  This patch preemptively removes
the redundant check.

16 months agoReplace search_domain with domain_search_flags
Tom Tromey [Thu, 2 Mar 2023 22:05:17 +0000 (15:05 -0700)] 
Replace search_domain with domain_search_flags

This patch changes gdb to replace search_domain with
domain_search_flags everywhere.  search_domain is removed.

16 months agoAdd domain_search_flags
Tom Tromey [Thu, 2 Mar 2023 22:20:29 +0000 (15:20 -0700)] 
Add domain_search_flags

This adds a new flag enum type, domain_search_flags, which is the flag
version of domain_enum.  Nothing uses this yet, but the goal here is
to have all symbol searches and lookups use these flags.  The new
names are chosen to exactly parallel domain_enum.

16 months agoAdd two new symbol domains
Tom Tromey [Thu, 2 Mar 2023 22:07:47 +0000 (15:07 -0700)] 
Add two new symbol domains

This adds two new symbol domain constants, TYPE_DOMAIN and
FUNCTION_DOMAIN.

Historically, gdb was a C debugger, and the symbol tables continue to
reflect this.  In particular, symbol domains match the C language,
with VAR_DOMAIN including variables, functions, and types.

However, other languages have other approaches to namespacing.  And,
in any case, it is often useful for other parts of gdb to be able to
distinguish between some domains at lookup time, without resorting to
examining a symbol's location -- in some situations, this sort of
filtering happens too late.

Nothing uses these new domains yet, but the idea behind the patch is
to separate symbols into more domains and then let the
language-specific parts of gdb implement their semantics in terms of
these categories.

16 months agoUse a .def file for domain_enum
Tom Tromey [Sun, 3 Sep 2023 22:28:54 +0000 (16:28 -0600)] 
Use a .def file for domain_enum

Future patches will change and reuse the names from domain_enum.  This
patch makes this less error-prone by having a single point to define
these names, using the typical gdb ".def" file.

16 months agoSplit up a big 'if' in symtab.c
Tom Tromey [Fri, 10 Mar 2023 18:48:25 +0000 (11:48 -0700)] 
Split up a big 'if' in symtab.c

global_symbol_searcher::add_matching_symbols in symtab.c has a
gigantic 'if' statement -- 33 lines of conditional expression.  This
patch splits it up into a series of separate 'if's.

16 months agoSimplify symbol_to_info_string
Tom Tromey [Sun, 5 Mar 2023 17:23:04 +0000 (10:23 -0700)] 
Simplify symbol_to_info_string

Thi simplifies symbol_to_info_string, removing the 'kind' parameter
and instead having it use the symbol's domain.

16 months agoRemove NR_DOMAINS
Tom Tromey [Thu, 2 Mar 2023 22:08:42 +0000 (15:08 -0700)] 
Remove NR_DOMAINS

NR_DOMAINS is only used for a static assert, but we no longer need it
now.  If we add too many constants to this enum, GCC will warn about
the bitfield overflow:

    error: ‘symbol::m_domain’ is too small to hold all values of ‘enum domain_enum’

16 months agoGive names to unspecified types
Tom Tromey [Mon, 20 Nov 2023 04:09:57 +0000 (21:09 -0700)] 
Give names to unspecified types

A patch later in this series will change check_typedef to also look in
the type domain.  This change by itself caused a regression, but one
that revealed some peculiar behavior.

The regression is in nullptr_t.exp, where examining a std::nullptr_t
will change from the correct:

    typedef decltype(nullptr) std::nullptr_t;

to

    typedef void std::nullptr_t;

Right now, the DWARF reader marks all unspecified types as stub types.
However, this interacts weirdly with check_typedef, which currently
does not try to resolve types -- only struct-domain objects.

My first attempt here was to fix this by changing void types not to be
stub types, as I didn't see what value that provided.  However, this
caused another regression, because call_function_by_hand_dummy checks
for stub-ness:

  if (values_type == NULL || values_type->is_stub ())
    values_type = default_return_type;

I'm not really sure why it does this rather than check for
TYPE_CODE_VOID.

While looking into this, I found another oddity: the DWARF reader
correctly creates a type named 'decltype(nullptr)' when it seems a
DW_TAG_unspecified_type -- but it creates a symbol named "void"
instead.

This patch changes the DWARF reader to give the symbol the correct
name.  This avoids the regression.

16 months agoFix latent bug in mdebugread.c
Tom Tromey [Sun, 19 Nov 2023 01:51:34 +0000 (18:51 -0700)] 
Fix latent bug in mdebugread.c

mdebugread.c makes a label symbol but puts it into VAR_DOMAIN.  I
think LABEL_DOMAIN is more appropriate.

I don't have a way to test this.

16 months agoMake nsalias.exp more reliable
Tom Tromey [Fri, 10 Mar 2023 16:49:24 +0000 (09:49 -0700)] 
Make nsalias.exp more reliable

nsalias.exp tries to detect a complaint that is issued when expanding
a CU.  However, the test is a bit funny in that, while gdb does
currently expand the CU and issue the complaint, it also emits this
error:

    No symbol "N100" in current context.

This series will change gdb such that this CU is not expanded -- which
makes sense, the symbol in question doesn't actually match the lookups
that are done.

So, to make the test more robust, a direct request to expand symtabs
is done instead.

16 months agoFix latent bug in DW_TAG_entry_point handling
Tom Tromey [Thu, 18 Jan 2024 20:27:02 +0000 (13:27 -0700)] 
Fix latent bug in DW_TAG_entry_point handling

A DW_TAG_entry_point symbol inherits its extern/static property from
the enclosing subroutine.  This is encoded in new_symbol -- but the
cooked indexer does not agree.

16 months agoSmall cleanup in DWARF reader
Tom Tromey [Thu, 30 Mar 2023 16:25:40 +0000 (10:25 -0600)] 
Small cleanup in DWARF reader

I noticed a couple of spots in dwarf/read.c:new_symbol that call
add_symbol_to_list.  However, this function is generally written to
set list_to_add, and then have a single call to add_symbol_to_list at
the end.  This patch cleans up this discrepancy.

Note that new_symbol is overlong and should probably be split up.

16 months agoFix bug in cooked index scanner
Tom Tromey [Thu, 30 Mar 2023 16:21:59 +0000 (10:21 -0600)] 
Fix bug in cooked index scanner

Testing this entire series pointed out that the cooked index scanner
disagrees with new_symbol about certain symbols.  In particular,
new_symbol has this comment:

    Ada and Fortran subprograms, whether marked external or
    not, are always stored as a global symbol, because we want

This patch updates the scanner to match.

I don't know why the current code does not cause failures.

It's maybe worth noting that incremental CU expansion -- creating
symtabs directly from the index -- would eliminate this sort of bug.

16 months agoAutomatic date update in version.in
GDB Administrator [Sun, 28 Jan 2024 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

17 months agoAutomatic date update in version.in
GDB Administrator [Sat, 27 Jan 2024 00:00:30 +0000 (00:00 +0000)] 
Automatic date update in version.in

17 months agogas: scfi: untraceable control flow should be a hard error
Indu Bhagat [Fri, 26 Jan 2024 18:30:18 +0000 (10:30 -0800)] 
gas: scfi: untraceable control flow should be a hard error

PR gas/31284

Currently, if an indirect jump is seen, GCFG (a CFG of ginsns) cannot be
created, and the SCFI machinery bails out with a warning:
  "Warning: Untraceable control flow for func 'foo'; Skipping SCFI"

It is, however, better suited if this is a hard error.  Change it to a
hard error.  Also change the message to skip mentioning "SCFI", because
the error itself may also useful when ginsns are used for other passes
(distinct from SCFI) involving GCFG, like a pass to detect if there is
unreachable code.  Hence, simply say:
  "Error: untraceable control flow for func 'foo'"

gas/
PR gas/31284
* ginsn.c (ginsn_data_end): Use as_bad instead of as_warn.

gas/testsuite/
PR gas/31284
* gas/scfi/x86_64/ginsn-cofi-1.l: Adjust to the expected output
in case of errors.
* gas/scfi/x86_64/scfi-unsupported-cfg-1.l: Error not Warning.

17 months agox86: testsuite: scfi: adjust COFI testcase
Indu Bhagat [Fri, 26 Jan 2024 18:29:38 +0000 (10:29 -0800)] 
x86: testsuite: scfi: adjust COFI testcase

The testcase for change of flow instructions in its current shape is not
doing much: it checks that SCFI issues an appropriate warning.  The same
warning is covered by another testcase (scfi-unsupported-cfg-1); It is
better to test the ginsn translation instead, for these 'change of flow
instructions'.

gas/testsuite/
* gas/scfi/x86_64/scfi-cofi-1.s: Moved to...
* gas/scfi/x86_64/ginsn-cofi-1.s: ...here.
* gas/scfi/x86_64/scfi-x86-64.exp: Adjust tests.
* gas/scfi/x86_64/scfi-cofi-1.d: Removed.
* gas/scfi/x86_64/scfi-cofi-1.l: Removed.
* gas/scfi/x86_64/ginsn-cofi-1.l: New test.

17 months agoelf: Rename is_standard_elf to uses_elf_em
H.J. Lu [Fri, 26 Jan 2024 13:56:08 +0000 (05:56 -0800)] 
elf: Rename is_standard_elf to uses_elf_em

Rename is_standard_elf to uses_elf_em for targets which use elf.em.

binutils/

PR ld/31289
* testsuite/lib/binutils-common.exp (is_standard_elf): Renamed
to ...
(uses_elf_em): This.

ld/

PR ld/31289
* testsuite/ld-elf/fatal-warnings-2a.d: Replace is_standard_elf
with uses_elf_em.
* testsuite/ld-elf/fatal-warnings-2b.d: Likewise.
* testsuite/ld-elf/fatal-warnings-3a.d: Likewise.
* testsuite/ld-elf/fatal-warnings-3b.d: Likewise.
* testsuite/ld-elf/fatal-warnings-4a.d: Likewise.
* testsuite/ld-elf/fatal-warnings-4b.d: Likewise.

17 months agoaarch64: move SHA512 instructions to +sha3
Andrew Carlotti [Fri, 19 Jan 2024 13:01:40 +0000 (13:01 +0000)] 
aarch64: move SHA512 instructions to +sha3

SHA512 instructions were added to the architecture at the same time as SHA3
instructions, but later than the SHA1 and SHA256 instructions.  Furthermore,
implementations must support either both or neither of the SHA512 and SHA3
instruction sets.  However, SHA512 instructions were originally (and
incorrectly) added to Binutils under the +sha2 flag.

This patch moves SHA512 instructions under the +sha3 flag, which matches the
architecture constraints and existing GCC and LLVM behaviour.

17 months agoFix: Stripping Rust static libraries fails because of overly zealous illegal path...
Nick Clifton [Fri, 26 Jan 2024 11:54:08 +0000 (11:54 +0000)] 
Fix: Stripping Rust static libraries fails because of overly zealous illegal path check

  PR 31250
  * objcopy.c (copy_archive): Improve the handling of archives that contain elements with invalid pathnames.

17 months agoRemove -pie from command line of fatal-warnings 1a and 1b tests.
Nick Clifton [Fri, 26 Jan 2024 10:25:04 +0000 (10:25 +0000)] 
Remove -pie from command line of fatal-warnings 1a and 1b tests.

17 months agox86/APX: TILE{RELEASE,ZERO} have no EVEX encodings
Jan Beulich [Fri, 26 Jan 2024 09:34:48 +0000 (10:34 +0100)] 
x86/APX: TILE{RELEASE,ZERO} have no EVEX encodings

Re-using the entire VEX decode hierarchy for the respective major opcode
has led to those two also being decoded as-if valid. Follow the earlier
USE_X86_64_EVEX_{PFX,W}_TABLE approach to avoid this happening.

17 months agox86/APX: no need to have decode go through x86_64_table[]
Jan Beulich [Fri, 26 Jan 2024 09:34:24 +0000 (10:34 +0100)] 
x86/APX: no need to have decode go through x86_64_table[]

As suggested during review already, all such entries have their first
slot as Bad_Opcode, so by adding two more enumerators we can avoid doing
that decode step altogether.

17 months agox86: make "-msyntax=intel -mnaked-reg" match ".intel_syntax noprefix"
Jan Beulich [Fri, 26 Jan 2024 09:32:37 +0000 (10:32 +0100)] 
x86: make "-msyntax=intel -mnaked-reg" match ".intel_syntax noprefix"

Adjustments made for the directive (by set_intel_syntax()) need also
making for the command line option. Break out respective code into a new
helper function, to also be invoked during command line processing.
Further also set register_prefix when processing -mnaked-reg.

17 months agox86/APX: optimize MOVBE
Jan Beulich [Fri, 26 Jan 2024 09:31:38 +0000 (10:31 +0100)] 
x86/APX: optimize MOVBE

With identical source and destination it can be covered by the NDD-to-
legacy conversion logic as well, even if in this case the original insn
doesn't use an NDD encoding. The size savings are even better here, for
the replacement (BSWAP) not having a ModR/M byte.

17 months agoLoongArch: Fix a bug of getting relocation type
mengqinggang [Fri, 26 Jan 2024 03:16:49 +0000 (11:16 +0800)] 
LoongArch: Fix a bug of getting relocation type

The old code works because R_LARCH_RELAX has no symbol index. It causes
'(rel + 1)->r_info == R_LARCH_RELAX' is 1 and ELFNN_R_TYPE (1) is 1.

17 months agoLoongArch: gas: Add support for s9 register
mengqinggang [Thu, 25 Jan 2024 06:44:12 +0000 (14:44 +0800)] 
LoongArch: gas: Add support for s9 register

In LoongArch ABI, r22 register can be used as frame pointer or
static register(s9).

Link: https://github.com/loongson/la-abi-specs/blob/release/lapcs.adoc#general-purpose-registers
17 months agoLoongArch: ld: Add support for TLS LE symbol with addend
mengqinggang [Thu, 25 Jan 2024 01:32:14 +0000 (09:32 +0800)] 
LoongArch: ld: Add support for TLS LE symbol with addend

Add support for TLS LE symbol with addend, such as:
  lu12i.w $t0, %le_hi20(a + 0x8)
  ori   $t0, $t0, %le_lo12(a + 0x8)

17 months agoAssertion failure dumping .eh_frame_hdr
Alan Modra [Thu, 25 Jan 2024 22:44:13 +0000 (09:14 +1030)] 
Assertion failure dumping .eh_frame_hdr

dwarf.c can hit "Assertion '(start) <= (end)' failed" on truncated
sections, due to get_encoded_eh_value wrongly returning a full count
for truncated words.

* dwarf.c (get_encoded_eh_value): Return zero for truncated words.

17 months agoAutomatic date update in version.in
GDB Administrator [Fri, 26 Jan 2024 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

17 months agogdb: remove get_gdb_program_name
Simon Marchi [Thu, 25 Jan 2024 19:35:06 +0000 (14:35 -0500)] 
gdb: remove get_gdb_program_name

Nothing uses it.

Change-Id: I7a3fbf38e290a5147fbcbf175bc34f01dfb335c7

17 months agoelf: Add is_standard_elf
H.J. Lu [Thu, 25 Jan 2024 18:08:04 +0000 (10:08 -0800)] 
elf: Add is_standard_elf

PR ld/31289 tests failed for fr30-elf, frv-elf, ft32-elf, iq2000-elf,
mn10200-elf, ms1-elf and msp430-elf targets:

FAIL: ld-elf/fatal-warnings-2a
FAIL: ld-elf/fatal-warnings-2b
FAIL: ld-elf/fatal-warnings-3a
FAIL: ld-elf/fatal-warnings-3b
FAIL: ld-elf/fatal-warnings-4a
FAIL: ld-elf/fatal-warnings-4b

even though PR ld/31289 targets xfail for [is_generic] targets.  These
targets not only don't use the generic_link_hash_table linker, but also
don't use the standard ELF emulation.  Add is_standard_elf for ELF
targets which use the standard ELF emulation and replace [is_generic]
with ![is_standard_elf] in PR ld/31289 tests.

binutils/

PR ld/31289
* testsuite/lib/binutils-common.exp (is_standard_elf): New.

ld/

PR ld/31289
* testsuite/lib/binutils-common.exp (is_generic): Return 1 for
fr30-*-*, frv-*-elf, ft32-*-*, iq2000-*-*, mn10200-*-*,
moxie-*-moxiebox*, msp430-*-* and mt-*-*.
* testsuite/ld-elf/fatal-warnings-2a.d: Replace [is_generic]
with ![is_standard_elf].
* testsuite/ld-elf/fatal-warnings-2b.d: Likewise.
* testsuite/ld-elf/fatal-warnings-3a.d: Likewise.
* testsuite/ld-elf/fatal-warnings-3b.d: Likewise.
* testsuite/ld-elf/fatal-warnings-4a.d: Likewise.
* testsuite/ld-elf/fatal-warnings-4b.d: Likewise.

17 months agold: Always call output_unknown_cmdline_warning
H.J. Lu [Thu, 25 Jan 2024 15:39:05 +0000 (07:39 -0800)] 
ld: Always call output_unknown_cmdline_warning

Call output_unknown_cmdline_warning if there are no input files so that

$ ld -z bad-option

reports

ld: warning: -z bad-option ignored
ld: no input files

instead of

ld: no input files

PR ld/31289
* ldmain.c (main): Call output_unknown_cmdline_warning if there
are no input files.

17 months ago[gdb/testsuite] Fix regexp in vgdb_start
Tom de Vries [Thu, 25 Jan 2024 15:36:09 +0000 (16:36 +0100)] 
[gdb/testsuite] Fix regexp in vgdb_start

On Fedora 39 aarch64 I run into:
...
(gdb) target remote | vgdb --wait=2 --max-invoke-ms=2500 --pid=2114437^M
Remote debugging using | vgdb --wait=2 --max-invoke-ms=2500 --pid=2114437^M
relaying data between gdb and process 2114437^M
warning: remote target does not support file transfer, \
  attempting to access files from local filesystem.^M
Reading symbols from /lib/ld-linux-aarch64.so.1...^M
_start () at ../sysdeps/aarch64/dl-start.S:22^M
warning: 22     ../sysdeps/aarch64/dl-start.S: No such file or directory^M
(gdb) FAIL: gdb.base/valgrind-infcall.exp: target remote for vgdb
...

For contrast, on openSUSE Leap 15.4 x86_64 I have:
...
(gdb) target remote | vgdb --wait=2 --max-invoke-ms=2500 --pid=18797^M
Remote debugging using | vgdb --wait=2 --max-invoke-ms=2500 --pid=18797^M
relaying data between gdb and process 18797^M
warning: remote target does not support file transfer, \
  attempting to access files from local filesystem.^M
Reading symbols from /lib64/ld-linux-x86-64.so.2...^M
(No debugging symbols found in /lib64/ld-linux-x86-64.so.2)^M
0x0000000004002550 in _start () from /lib64/ld-linux-x86-64.so.2^M
(gdb) PASS: gdb.base/valgrind-infcall.exp: target remote for vgdb
...

The fail happens in vgdb_start because the regexp only matches the
"in _start ()" variant, not the "_start () at":
...
       gdb_test "$vgdbcmd" " in \\.?_start .*" "target remote for vgdb"
...
Which variant you get is determined by presence of debug info.

Fix this by also matching the "_start () at" variant.

Tested aarch64-linux and x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
17 months agogas: Update NEWS
Andrew Carlotti [Fri, 19 Jan 2024 17:15:04 +0000 (17:15 +0000)] 
gas: Update NEWS

Groups entries by architecture, and update AArch64 content.

17 months ago[gdb/build] Workaround gcc PR113599
Tom de Vries [Thu, 25 Jan 2024 15:31:47 +0000 (16:31 +0100)] 
[gdb/build] Workaround gcc PR113599

Since gcc commit d3f48f68227 ("c++: non-dependent .* operand folding
[PR112427]"), with gdb we run into PR gcc/113599 [1], a wrong-code bug, as
reported in PR build/31281.

Work around this by flipping inherit order:
...
-class thread_info : public refcounted_object,
-     public intrusive_list_node<thread_info>
+class thread_info : public intrusive_list_node<thread_info>,
+     public refcounted_object
...

An argument could be made that this isn't necessary, because this occurred in
an unreleased gcc version.

However, I think it could be useful when bisecting gcc for other problems in
building gdb.  Having this workaround means the bisect won't reintroduce the
problem.  Furthermore, the workaround is harmless.

Tested on Fedora rawhide x86_64.

Approved-By: Tom Tromey <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31281

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113599

17 months ago[gdb/testsuite] Fix gdb.base/eh_return.exp
Tom de Vries [Thu, 25 Jan 2024 15:25:07 +0000 (16:25 +0100)] 
[gdb/testsuite] Fix gdb.base/eh_return.exp

On Fedora rawhide aarch64, I run into:
...
(gdb) PASS: gdb.base/eh_return.exp: set breakpoint on address
run ^M
Starting program: eh_return ^M
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib64/libthread_db.so.1".^M
[Inferior 1 (process 1113051) exited normally]^M
(gdb) FAIL: gdb.base/eh_return.exp: hit breakpoint (the program exited)
...

This happens as follows: the test-case sets a breakpoint on the last
instruction of function eh2:
...
(gdb) break *0x00000000004103ec^M
...
and expects to hit the breakpoint, but instead the "br x6" is taken:
...
   0x00000000004103e0 <+176>:   cbz     x4, 0x4103ec <eh2+188>^M
   0x00000000004103e4 <+180>:   add     sp, sp, x5^M
   0x00000000004103e8 <+184>:   br      x6^M
   0x00000000004103ec <+188>:   ret^M
...

In contrast, with fedora f39 we have:
...
   0x00000000004103bc <+156>:   ldp     x2, x3, [sp, #48]^M
   0x00000000004103c0 <+160>:   ldp     x29, x30, [sp, #16]^M
   0x00000000004103c4 <+164>:   add     sp, sp, #0x50^M
   0x00000000004103c8 <+168>:   add     sp, sp, x4^M
   0x00000000004103cc <+172>:   ret^M

...
and the breakpoint is reached.

Fix this by detecting that the breakpoint is not hit, and declaring the test
unsupported.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR testsuite/31291
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31291

17 months agoFix attach-twice.c testcase for AIX.
Aditya Vidyadhar Kamath [Thu, 25 Jan 2024 12:28:29 +0000 (06:28 -0600)] 
Fix attach-twice.c testcase for AIX.

Currently, in AIX attach-twice.exp testcase is untested due to the below error.
gdb/testsuite/gdb.base/attach-twice.c:43:7: error: too few arguments to function 'ptrace'

This is because in AIX ptrace has five arguments. This patch is a fix for the same such that
this test case runs in AIX and other targets as well.

17 months agold: Improve --fatal-warnings for unknown command-line options
H.J. Lu [Wed, 24 Jan 2024 21:53:11 +0000 (13:53 -0800)] 
ld: Improve --fatal-warnings for unknown command-line options

There are 2 problems with --fatal-warnings for unknown command-line
options:

1. --fatal-warnings doesn't trigger an error for an unknown command-line
option when --fatal-warnings is the last command-line option.
2. When --fatal-warnings triggers an error for an unknown command-line
option, the message says that the unknown command-line option is ignored.

This patch queues unknown command-line option warnings and outputs queued
command-line option warnings after all command-line options have been
processed so that --fatal-warnings can work for unknown command-line
options regardless of the order of --fatal-warnings.

When --fatal-warnings is used, the linker message is changed from

ld: warning: -z bad-option ignored

to

ld: error: unsupported option: -z bad-option

The above also applies to "-z dynamic-undefined-weak" when the known
"-z dynamic-undefined-weak" option is ignored.

PR ld/31289
* ldelf.c (ldelf_after_parse): Use queue_unknown_cmdline_warning
to warn the ignored -z dynamic-undefined-weak option.
* ldmain.c (main): Call output_unknown_cmdline_warnings after
calling ldemul_after_parse.
* ldmisc.c (CMDLINE_WARNING_SIZE): New.
(cmdline_warning_list): Likewise.
(cmdline_warning_head): Likewise.
(cmdline_warning_tail): Likewise.
(queue_unknown_cmdline_warning): Likewise.
(output_unknown_cmdline_warnings): Likewise.
* ldmisc.h (queue_unknown_cmdline_warning): Likewise.
(output_unknown_cmdline_warnings): Likewise.
* emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Use
queue_unknown_cmdline_warning to warn unknown -z option.
* testsuite/ld-elf/fatal-warnings-1a.d: New file.
* testsuite/ld-elf/fatal-warnings-1b.d: Likewise.
* testsuite/ld-elf/fatal-warnings-2a.d: Likewise.
* testsuite/ld-elf/fatal-warnings-2b.d: Likewise.
* testsuite/ld-elf/fatal-warnings-3a.d: Likewise.
* testsuite/ld-elf/fatal-warnings-3b.d: Likewise.
* testsuite/ld-elf/fatal-warnings-4a.d: Likewise.
* testsuite/ld-elf/fatal-warnings-4b.d: Likewise.

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

17 months agoriscv64-pei uninitialised data writing relocs
Alan Modra [Wed, 24 Jan 2024 22:11:14 +0000 (08:41 +1030)] 
riscv64-pei uninitialised data writing relocs

Without this patch the r_offset field of struct external_reloc is
uninitialised when using objcopy.

* coff/riscv64.h (SWAP_IN_RELOC_OFFSET): Define.
(SWAP_OUT_RELOC_OFFSET): Define.

17 months agoEmit stopped event for DAP attach request
Tom Tromey [Thu, 11 Jan 2024 16:52:55 +0000 (09:52 -0700)] 
Emit stopped event for DAP attach request

In an earlier patch, I wrote:

    ...  It also adds some machinery so that attach stops can be
    suppressed, which I think is the right thing to do.

However, after some discussions here at AdaCore, I now believe this to
be incorrect -- while DAP says that expected "continue" events should
be suppressed, there is no corresponding language for expected "stop"
events, and indeed "stop" events explicitly mention cases like "step".

This patch arranges for the stop event to be emitted again.

17 months agoHandle DW_AT_endianity on enumeration types
Tom Tromey [Tue, 9 Jan 2024 18:47:17 +0000 (11:47 -0700)] 
Handle DW_AT_endianity on enumeration types

A user found that gdb would not correctly print a field from an Ada
record using the scalar storage order feature.  We tracked this down
to a combination of problems.

First, GCC did not emit DW_AT_endianity on the enumeration type.
DWARF does not specify this, but it is an obvious and harmless
extension.  This was fixed in GCC recently:

    https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642347.html
    https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5d8b60effc7268448a94fbbbad923ab6871252cd

Second, GDB did not handle this attribute on enumeration types.  This
patch makes this change and adds a test case that will pass with the
patched GCC.

So far, the GCC patch isn't on the gcc-13 branch; but if it ever goes
in, the test case in this patch can be updated to reflect that.

Reviewed-By: Keith Seitz <keiths@redhat.com>
17 months agogdb/arm: Fix epilogue frame id
Thiago Jung Bauermann [Tue, 23 Jan 2024 17:11:33 +0000 (14:11 -0300)] 
gdb/arm: Fix epilogue frame id

arm_epilogue_frame_this_id has a comment saying that it fall backs to using
the current PC if the function start address can't be identified, but it
actually uses only the PC to make the frame id.

This patch makes the code match the comment.  Another hint that it's what
is intended is that arm_prologue_this_id, a function almost identical to
it, does that.

The problem was found by code inspection.  It fixes the following testsuite
failures:

FAIL: gdb.base/unwind-on-each-insn.exp: foo: instruction 9: check frame-id matches
FAIL: gdb.reverse/solib-reverse.exp: reverse-next third shr1
FAIL: gdb.reverse/solib-reverse.exp: reverse-next second shr1
FAIL: gdb.reverse/solib-reverse.exp: reverse-next first shr1
FAIL: gdb.reverse/solib-reverse.exp: reverse-next generic
FAIL: gdb.reverse/solib-reverse.exp: reverse-step into solib function one
FAIL: gdb.reverse/solib-reverse.exp: reverse-step within solib function one
FAIL: gdb.reverse/solib-reverse.exp: reverse-step into solib function two
FAIL: gdb.reverse/solib-reverse.exp: reverse-step within solib function two

Tested on arm-linux-gnueabi-hf.

17 months agogdb/testsuite: add test for backtracing for threaded inferiors from a corefile
Guinevere Larsen [Thu, 24 Aug 2023 09:00:35 +0000 (11:00 +0200)] 
gdb/testsuite: add test for backtracing for threaded inferiors from a corefile

This patch is based on an out-of-tree patch that fedora has been
carrying for a while. It tests if GDB is able to properly unwind a
threaded program in the following situations:
* regular threads
* in a signal handler
* in a signal handler executing on an alternate stack

And the final frame can either be in a syscall or in an infinite loop.

The test works by running the inferior until a crash to generate a
corefile, or until right before the crash. Then applies a backtrace to
all threads to see if any frame can't be identified, and the order of
the threads in GDB. Finally, it goes thread by thread and tries to
collect a large part of the backtrace, to confirm that everything is
being unwound correctly.

Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Reviewed-By: Luis Machado <luis.machado@arm.com>
Approved-By: Luis Machado <luis.machado@arm.com>
17 months agoaarch64: Eliminate unused variable warnings with -DNDEBUG
Andrew Carlotti [Tue, 23 Jan 2024 18:22:12 +0000 (18:22 +0000)] 
aarch64: Eliminate unused variable warnings with -DNDEBUG

17 months agoLoongArch: gas: Start a new frag after instructions that can be relaxed
mengqinggang [Thu, 18 Jan 2024 11:03:11 +0000 (19:03 +0800)] 
LoongArch: gas: Start a new frag after instructions that can be relaxed

For R_LARCH_TLS_{LE_HI20_R,LE_ADD_R,LD_PC_HI20,GD_PC_HI20, DESC_PC_HI20}
relocations, start a new frag to get correct eh_frame Call Frame Information
FDE DW_CFA_advance_loc info.

17 months agoLoongArch: gas: Don't define LoongArch .align
mengqinggang [Sun, 1 Oct 2023 07:29:44 +0000 (15:29 +0800)] 
LoongArch: gas: Don't define LoongArch .align

Gcc may generate "\t.align\t%d,54525952,4\n" before commit
b20c7ee066cb7d952fa193972e8bc6362c6e4063. To write 54525952 (NOP) to object
file, we call s_align_ptwo (-4). It result in alignment padding must be a
multiple of 4 if .align has second parameter.

Use default s_align_ptwo for .align.

17 months agoAdd myself as the KVX port maintainer
Paul Iannetta [Tue, 23 Jan 2024 16:03:11 +0000 (17:03 +0100)] 
Add myself as the KVX port maintainer

binutils/ChangeLog:

* MAINTAINERS: Add myself as the KVX port maintainer.

17 months agoAutomatic date update in version.in
GDB Administrator [Wed, 24 Jan 2024 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

17 months agoaarch64: Update Architecture Extensions documentation
Andrew Carlotti [Mon, 15 Jan 2024 07:26:53 +0000 (07:26 +0000)] 
aarch64: Update Architecture Extensions documentation

Restructure the architecture extensions table, add a new table for architecture
version dependencies, add missing architecture extensions, and improve some
extension descriptions.

17 months agoaarch64: Include +predres2 in -march=armv8.9-a
Andrew Carlotti [Wed, 17 Jan 2024 12:37:15 +0000 (12:37 +0000)] 
aarch64: Include +predres2 in -march=armv8.9-a

This matches the dependencies in the architecture, in LLVM, and even in the
original Binutils commit message that mistakenly included it only in armv9.4-a.

17 months ago[PATCH v2] gas/NEWS, ld/NEWS: Announce LoongArch changes in 2.42
Xi Ruoyao [Tue, 23 Jan 2024 16:00:32 +0000 (16:00 +0000)] 
[PATCH v2] gas/NEWS, ld/NEWS: Announce LoongArch changes in 2.42

17 months agogdb: fix "list ." related crash
Guinevere Larsen [Mon, 22 Jan 2024 09:13:52 +0000 (10:13 +0100)] 
gdb: fix "list ." related crash

When a user attempts to use the "list ." command with an inferior that
doesn't have debug symbols, GDB would crash. This was reported as PR
gdb/31256.

The crash would happen when attempting to get the current symtab_and_line
for the stop location, because the symtab would return a null pointer
and we'd attempt to dereference it to print the line.

This commit fixes that by checking for an empty symtab and erroring out
of the function if it happens.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31256
Approved-By: Tom Tromey <tom@tromey.com>
17 months agosim: sh: fix nested braces in struct init
Mike Frysinger [Tue, 23 Jan 2024 08:09:43 +0000 (03:09 -0500)] 
sim: sh: fix nested braces in struct init

The op struct includes an array of strings, but doesn't use braces
around that array when initializing.  This causes a ton of warnings
when using -Wmissing-braces.  Add them to fix.

The code this tool generates is the same before & after.

17 months agosim: riscv: Fix crash during instruction decoding
Jaydeep Patil [Thu, 11 Jan 2024 05:28:21 +0000 (05:28 +0000)] 
sim: riscv: Fix crash during instruction decoding

The match_never() function has been removed and thus step_once() crashes
during instruction decoding. Fixed it by checking for null pointer before
invoking function attached to match_func member of riscv_opcode structure

17 months agosim: frv: fix -Wincompatible-function-pointer-types warnings [PR sim/29752]
Mike Frysinger [Sun, 24 Dec 2023 08:39:52 +0000 (03:39 -0500)] 
sim: frv: fix -Wincompatible-function-pointer-types warnings [PR sim/29752]

Some compilers warn in the frv code:
sem.c:24343:41: error: incompatible function pointer types passing
  'void (SIM_CPU *, UINT, UDI)' (aka 'void (struct _sim_cpu *, unsigned int, unsigned long)')
  to parameter of type
  'void (*)(SIM_CPU *, UINT, DI)' (aka 'void (*)(struct _sim_cpu *, unsigned int, long)') [-Wincompatible-function-pointer-types]

This is due to frvbf_h_acc40U_set using UDI for setting the new value,
but using the common sim_queue_fn_di_write API which uses DI.  The same
size, but different sign.  We could change frvbf_h_acc40U_set to take a
DI without changing behavior in practice: the UDI is already passed via
the queue function which accepts a DI, and frvbf_h_acc40U_set already
casts the input to UDI before running any operations on it.  However,
these files are all generated, so manual changes here would be reverted.

Seems like we can only change the register type for all APIs in the cpu
definition.  This builds cleanly, and passes sim unittests.  Not sure if
it's 100% the answer, but seems to be the best we have currently.

Bug: https://sourceware.org/PR29752

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

17 months agogdb/testsuite: avoid duplicate test names in gdb.dwarf2/dw2-zero-range.exp (and more)
Simon Marchi [Fri, 19 Jan 2024 21:15:41 +0000 (21:15 +0000)] 
gdb/testsuite: avoid duplicate test names in gdb.dwarf2/dw2-zero-range.exp (and more)

Tom Tromey noticed that dw2-zero-range.exp reported a duplicate test
name.  This happens because have_index calls get_index_type with the
default test name.  Refactor the test to avoid this, while cleaning a
few other things, the most important being:

 - factor out the relocated and unrelocated parts in their own procs
 - give different names to generated binaries in different variations,
   such that all binaries are left in the test output directory (this
   makes it easier to debug a specific variation)

Change-Id: I7cdf7a344834852fbb035d7e0434559eab6b1e94

17 months agoFix 31252 gprofng causes testsuite parallel jobs fail
Vladimir Mezentsev [Sat, 20 Jan 2024 02:40:21 +0000 (18:40 -0800)] 
Fix 31252 gprofng causes testsuite parallel jobs fail

Before running our tests, we made a fake installation into ./tmpdir.
This installation changes libopcodes.la in the build area.
Gas testing may fail if gas and gprofng tests are run in parallel.

I create a script to run gprofng. Inside this script, LD_LIBRARY_PATH,
GPROFNG_SYSCONFDIR are set.
putenv_libcollector_ld_misc() first uses $GPROFNG_PRELOAD_LIBDIRS to create
directories for SP_COLLECTOR_LIBRARY_PATH ($SP_COLLECTOR_LIBRARY_PATH is used
to set up LD_PRELOAD).

gprofng/ChangeLog
2024-01-19  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/31252
PR gprofng/30808
* src/envsets.cc (putenv_libcollector_ld_misc): Use
$GPROFNG_PRELOAD_LIBDIRS first to build SP_COLLECTOR_LIBRARY_PATH.
* testsuite/config/default.exp: Create a script to run gprofng.
* testsuite/lib/display-lib.exp: Fix typo.

17 months agoUpdated Serbian translations for th bfd, gold and opcodes directories
Nick Clifton [Mon, 22 Jan 2024 17:26:36 +0000 (17:26 +0000)] 
Updated Serbian translations for th bfd, gold and opcodes directories

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>