platform/upstream/binutils.git
9 months agox86: FMA insns aren't eligible to VEX2 encoding
Jan Beulich [Tue, 9 Jan 2024 12:49:48 +0000 (13:49 +0100)]
x86: FMA insns aren't eligible to VEX2 encoding

PR gas/31178

In da0784f961d8 ("x86: fold FMA VEX and EVEX templates") I overlooked
that C aliases StaticRounding, and hence build_vex_prefix() now needs to
be aware of that aliasing. Disambiguation is easy, as StaticRounding is
only ever used together with SAE (hence why the overlaying works in the
first place).

9 months agoPPC64/ELF: adjust comment wrt ABI versions
Jan Beulich [Tue, 9 Jan 2024 12:49:13 +0000 (13:49 +0100)]
PPC64/ELF: adjust comment wrt ABI versions

While having been moved a couple of times since its introduction in
f6c7c3e8b742 ("Referencing a function's address on PowerPC64 ELFv2"),
the wording has always remained the same. In particular ELFv1 and ELFv2
have always been the wrong way round.

9 months agoSynchronize sourceware version of the libiberty sources with the master gcc versions.
Nick Clifton [Tue, 9 Jan 2024 12:34:00 +0000 (12:34 +0000)]
Synchronize sourceware version of the libiberty sources with the master gcc versions.

This brings in the following commits:

commit c73cc6fe6207b2863afa31a3be8ad87b70d3df0a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Dec 5 23:32:19 2023 +0100

    libiberty: Fix build with GCC < 7

    Tobias reported on IRC that the linker fails to build with GCC 4.8.5.
    In configure I've tried to use everything actually used in the sha1.c
    x86 hw implementation, but unfortunately I forgot about implicit function
    declarations.  GCC before 7 did have <cpuid.h> header and bit_SHA define
    and __get_cpuid function defined inline, but it didn't define
    __get_cpuid_count, which compiled fine (and the configure test is
    intentionally compile time only) due to implicit function declaration,
    but then failed to link when linking the linker, because
    __get_cpuid_count wasn't defined anywhere.

    The following patch fixes that by using what autoconf uses in AC_CHECK_DECL
    to make sure the functions are declared.

commit 691858d279335eeeeed3afafdf872b1c5f8f4201
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Tue Dec 5 11:04:06 2023 +0100

    libiberty: Fix pex_unix_wait return type

    The recent warning patches broke Solaris bootstrap:

    /vol/gcc/src/hg/master/local/libiberty/pex-unix.c:326:3: error: initialization of 'pid_t (*)(struct pex_obj *, pid_t,  int *, struct pex_time *, int,  const char **, int *)' {aka 'long int (*)(struct pex_obj *, long int,  int *, struct pex_time *, int,  const char **, int *)'} from incompatible pointer type 'int (*)(struct pex_obj *, pid_t,  int *, struct pex_time *, int,  const char **, int *)' {aka 'int (*)(struct pex_obj *, long int,  int *, struct pex_time *, int,  const char **, int *)'} [-Wincompatible-pointer-types]
      326 |   pex_unix_wait,
          |   ^~~~~~~~~~~~~
    /vol/gcc/src/hg/master/local/libiberty/pex-unix.c:326:3: note: (near initialization for 'funcs.wait')

    While pex_funcs.wait expects a function returning pid_t, pex_unix_wait
    currently returns int.  However, on Solaris pid_t is long for 32-bit,
    but int for 64-bit.

    This patches fixes this by having pex_unix_wait return pid_t as
    expected, and like every other variant already does.

    Bootstrapped without regressions on i386-pc-solaris2.11,
    sparc-sun-solaris2.11, x86_64-pc-linux-gnu, and
    x86_64-apple-darwin23.1.0.

commit c3f281a0c1ca50e4df5049923aa2f5d1c3c39ff6
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Sep 25 10:15:02 2023 +0100

    c++: mangle function template constraints

    Per https://github.com/itanium-cxx-abi/cxx-abi/issues/24 and
    https://github.com/itanium-cxx-abi/cxx-abi/pull/166

    We need to mangle constraints to be able to distinguish between function
    templates that only differ in constraints.  From the latter link, we want to
    use the template parameter mangling previously specified for lambdas to also
    make explicit the form of a template parameter where the argument is not a
    "natural" fit for it, such as when the parameter is constrained or deduced.

    I'm concerned about how the latter link changes the mangling for some C++98
    and C++11 patterns, so I've limited template_parm_natural_p to avoid two
    cases found by running the testsuite with -Wabi forced on:

    template <class T, T V> T f() { return V; }
    int main() { return f<int,42>(); }

    template <int i> int max() { return i; }
    template <int i, int j, int... rest> int max()
    {
      int sub = max<j, rest...>();
      return i > sub ? i : sub;
    }
    int main() {  return max<1,2,3>(); }

    A third C++11 pattern is changed by this patch:

    template <template <typename...> class TT, typename... Ts> TT<Ts...> f();
    template <typename> struct A { };
    int main() { f<A,int>(); }

    I aim to resolve these with the ABI committee before GCC 14.1.

    We also need to resolve https://github.com/itanium-cxx-abi/cxx-abi/issues/38
    (mangling references to dependent template-ids where the name is fully
    resolved) as references to concepts in std:: will consistently run into this
    area.  This is why mangle-concepts1.C only refers to concepts in the global
    namespace so far.

    The library changes are to avoid trying to mangle builtins, which fails.

    Demangler support and test coverage is not complete yet.

commit f2c52c0dfde581461959b0e2b423ad106aadf179
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Thu Nov 30 10:06:23 2023 +0100

    libiberty: Disable hwcaps for sha1.o

    This patch

    commit bf4f40cc3195eb7b900bf5535cdba1ee51fdbb8e
    Author: Jakub Jelinek <jakub@redhat.com>
    Date:   Tue Nov 28 13:14:05 2023 +0100

        libiberty: Use x86 HW optimized sha1

    broke Solaris/x86 bootstrap with the native as:

    libtool: compile:  /var/gcc/regression/master/11.4-gcc/build/./gcc/gccgo -B/var/gcc/regression/master/11.4-gcc/build/./gcc/ -B/vol/gcc/i386-pc-solaris2.11/bin/ -B/vol/gcc/i386-pc-solaris2.11/lib/ -isystem /vol/gcc/i386-pc-solaris2.11/include -isystem /vol/gcc/i386-pc-solaris2.11/sys-include -fchecking=1 -minline-all-stringops -O2 -g -I . -c -fgo-pkgpath=internal/goarch /vol/gcc/src/hg/master/local/libgo/go/internal/goarch/goarch.go zgoarch.go
    ld.so.1: go1: fatal: /var/gcc/regression/master/11.4-gcc/build/gcc/go1: hardware capability (CA_SUNW_HW_2) unsupported: 0x4000000  [ SHA1 ]
    gccgo: fatal error: Killed signal terminated program go1

    As is already done in a couple of other similar cases, this patches
    disables hwcaps support for libiberty.

    Initially, this didn't work because config/hwcaps.m4 uses target_os, but
    didn't ensure it is defined.

    Tested on i386-pc-solaris2.11 with as and gas.

commit bf4f40cc3195eb7b900bf5535cdba1ee51fdbb8e
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Nov 28 13:14:05 2023 +0100

    libiberty: Use x86 HW optimized sha1

    Nick has approved this patch (+ small ld change to use it for --build-id=),
    so I'm commiting it to GCC as master as well.

    If anyone from ARM would be willing to implement it similarly with
    vsha1{cq,mq,pq,h,su0q,su1q}_u32 intrinsics, it could be a useful linker
    speedup on those hosts as well, the intent in sha1.c was that
    sha1_hw_process_bytes, sha1_hw_process_block functions
    would be defined whenever
    defined (HAVE_X86_SHA1_HW_SUPPORT) || defined (HAVE_WHATEVERELSE_SHA1_HW_SUPPORT)
    but the body of sha1_hw_process_block and sha1_choose_process_bytes
    would then have #elif defined (HAVE_WHATEVERELSE_SHA1_HW_SUPPORT) for
    the other arch support, similarly for any target attributes on
    sha1_hw_process_block if needed.

commit 01bc30b222a9d2ff0269325d9e367f8f1fcef942
Author: Mark Wielaard <mjw@redhat.com>
Date:   Wed Nov 15 20:27:08 2023 +0100

    Regenerate libiberty/aclocal.m4 with aclocal 1.15.1

    There is a new buildbot check that all autotool files are generated
    with the correct versions (automake 1.15.1 and autoconf 2.69).
    https://builder.sourceware.org/buildbot/#/builders/gcc-autoregen

    Correct one file that was generated with the wrong version.

commit 879cf9ff45d94065d89e24b71c6b27c7076ac518
Author: Brendan Shanks <bshanks@codeweavers.com>
Date:   Thu Nov 9 21:01:07 2023 -0700

    [PATCH v3] libiberty: Use posix_spawn in pex-unix when available.

    Hi,

    This patch implements pex_unix_exec_child using posix_spawn when
    available.

    This should especially benefit recent macOS (where vfork just calls
    fork), but should have equivalent or faster performance on all
    platforms.
    In addition, the implementation is substantially simpler than the
    vfork+exec code path.

    Tested on x86_64-linux.

    v2: Fix error handling (previously the function would be run twice in
    case of error), and don't use a macro that changes control flow.

    v3: Match file style for error-handling blocks, don't close
    in/out/errdes on error, and check close() for errors.

commit 810bcc00156cefce7ad40fc9d8de6e43c3a04450
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Aug 17 11:36:23 2023 -0400

    c++: constrained hidden friends [PR109751]

    r13-4035 avoided a problem with overloading of constrained hidden friends by
    checking satisfaction, but checking satisfaction early is inconsistent with
    the usual late checking and can lead to hard errors, so let's not do that
    after all.

    We were wrongly treating the different instantiations of the same friend
    template as the same function because maybe_substitute_reqs_for was failing
    to actually substitute in the case of a non-template friend.  But we don't
    actually need to do the substitution anyway, because [temp.friend] says that
    such a friend can't be the same as any other declaration.

    After fixing that, instead of a redefinition error we got an ambiguous
    overload error, fixed by allowing constrained hidden friends to coexist
    until overload resolution, at which point they probably won't be in the same
    ADL overload set anyway.

    And we avoid mangling collisions by following the proposed mangling for
    these friends as a member function with an extra 'F' before the name.  I
    demangle this by just adding [friend] to the name of the function because
    it's not feasible to reconstruct the actual scope of the function since the
    mangling ABI doesn't distinguish between class and namespace scopes.

            PR c++/109751

9 months agoaarch64: ADD FEAT_THE RCWCAS instructions.
Srinath Parvathaneni [Tue, 9 Jan 2024 10:30:20 +0000 (10:30 +0000)]
aarch64: ADD FEAT_THE RCWCAS instructions.

This patch adds support for FEAT_THE doubleword and quadword instructions.
doubleword insturctions are enabled by "+the" flag whereas quadword
instructions are enabled on passing both "+the and +d128" flags.

Support for following sets of instructions is added in this patch.
Read check write compare and swap doubleword:
(rcwcas, rcwcasa, rcwcasal, rcwcasl)
Read check write compare and swap quadword:
(rcwcasp,rcwcaspa, rcwcaspal, rcwcaspl)
Read check write software compare and swap doubleword:
(rcwscas, rcwscasa, rcwscasal, rcwscasl)
Read check write software compare and swap quadword:
(rcwscasp, rcwscaspa, rcwscaspal, rcwscaspl)
Read check write atomic bit clear on doubleword:
(rcwclr, rcwclra, rcwclral, rcwclrl)
Read check write atomic bit clear on quadword:
(rcwclrp, rcwclrpa, rcwclrpal, rcwclrpl)
Read check write software atomic bit clear on doubleword:
(rcwsclr, rcwsclra, rcwsclral, rcwsclrl)
Read check write software atomic bit clear on quadword:
(rcwsclrp,rcwsclrpa, rcwsclrpal,rcwsclrpl)
Read check write atomic bit set on doubleword:
(rcwset,rcwseta, rcwsetal,rcwsetl)
Read check write atomic bit set on quadword:
(rcwsetp,rcwsetpa,rcwsetpal,rcwsetpl)
Read check write software atomic bit set on doubleword:
(rcwsset,rcwsseta,rcwssetal,rcwssetl)
Read check write software atomic bit set on quadword:
(rcwssetp,rcwssetpa,rcwssetpal,rcwssetpl)
Read check write swap doubleword:
(rcwswp,rcwswpa,rcwswpal,rcwswpl)
Read check write swap quadword:
(rcwswpp,rcwswppa, rcwswppal,rcwswppl)
Read check write software swap doubleword:
(rcwsswp,rcwsswpa,rcwsswpal,rcwsswpl)
Read check write software swap quadword:
(rcwsswpp,rcwsswppa,rcwsswppal,rcwsswppl)

9 months agoaarch64: Regenerate aarch64-*-2.c files
Victor Do Nascimento [Tue, 9 Jan 2024 10:13:09 +0000 (10:13 +0000)]
aarch64: Regenerate aarch64-*-2.c files

9 months agoarch64: Add optional operand register pair support tests
Victor Do Nascimento [Wed, 13 Dec 2023 13:02:30 +0000 (13:02 +0000)]
arch64: Add optional operand register pair support tests

Add tests to cover the full range of behaviors observed around
optional register operands for the `tlbip' and `sysp' instructions,
namely:

  * Not all `tlbip' operations take GPR operands.  When this is the
  case, we should check that neither optional operand was supplied.
  * When a `tlbip' operation is labeled with the `F_HASXT' flag, xzr
  is not a valid optional operand.  In such case, at least the fist
  optional register needs to be specified with a non-xzr value.
  * The first operand for both insns should be either xzr or an
  even-numbered register (n % 2 == 0).  In the former scenario, the
  second operand should default to xzr too, while in the latter, it
  should default to n + 1.

9 months agoaarch64: Add support for 128-bit system register mrrs and msrr insns
Victor Do Nascimento [Mon, 20 Nov 2023 20:40:10 +0000 (20:40 +0000)]
aarch64: Add support for 128-bit system register mrrs and msrr insns

With the addition of 128-bit system registers to the Arm architecture
starting with Armv9.4-a, a mechanism for manipulating their contents
is introduced with the `msrr' and `mrrs' instruction pair.

These move values from one such 128-bit system register into a pair of
contiguous general-purpose registers and vice-versa, as for example:

   msrr ttlb0_el1, x0, x1
   mrrs x0, x1, ttlb0_el1

This patch adds the necessary support for these instructions, adding
checks for system-register width by defining a new operand type in the
form of `AARCH64_OPND_SYSREG128' and the `aarch64_sys_reg_128bit_p'
predicate, responsible for checking whether the requested system
register table entry is marked as implemented in the 128-bit mode via
the F_REG_128 flag.

9 months agoaarch64: Add TLBIP tests
Victor Do Nascimento [Fri, 1 Dec 2023 21:04:27 +0000 (21:04 +0000)]
aarch64: Add TLBIP tests

9 months agoaarch64: Add xs variants of tlbip operands
Victor Do Nascimento [Thu, 16 Nov 2023 17:01:50 +0000 (17:01 +0000)]
aarch64: Add xs variants of tlbip operands

The 2020 Architecture Extensions to the Arm A-profile architecture
added FEAT_XS, the XS attribute feature, giving cores the ability to
identify devices which can be subject to long response delays. TLB
invalidate (TLBI) operations and barriers can also be annotated with
this attribute[1].

With the introduction of the 128-bit translation tables with the
Armv8.9-a/Armv9.4-a Translation Hardening Extension, a series of new
TLB invalidate operations are introduced which make use of this
extension.  These are added to aarch64_sys_regs_tlbi[] for use
with the `tlbip' insn.

[1] https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-developments-2020

9 months agoaarch64: Implement TLBIP 128-bit instruction
Victor Do Nascimento [Wed, 15 Nov 2023 17:21:39 +0000 (17:21 +0000)]
aarch64: Implement TLBIP 128-bit instruction

The addition of 128-bit page table descriptors and, with it, the
addition of 128-bit system registers for these means that special
"invalidate translation table entry" instructions are needed to cope
with the new 128-bit model.  This is introduced with the `tlbpi'
instruction, implemented here.

9 months agoaarch64: Create QL_SRC_X2 and QL_DEST_X2 qualifier macros
Victor Do Nascimento [Wed, 13 Dec 2023 15:04:15 +0000 (15:04 +0000)]
aarch64: Create QL_SRC_X2 and QL_DEST_X2 qualifier macros

Some 128-bit system operations (mrrs, msrr, tlbip, and sysp) take two
qualified operands and one of unqualified type (e.g. system register
name, tlbip operation).  This creates the need for adequate qualifiers
to handle this.

This patch therefore introduces the `QL_SRC_X2' and `QL_DST_X2' qualifier
specifiers, which expand to `QLF3(NIL,X,X)' and `QLF3(X,X,NIL)',
respectively.

9 months agoaarch64: Apply narrowing of allowed immediate values for SYSP
Victor Do Nascimento [Mon, 20 Nov 2023 15:32:15 +0000 (15:32 +0000)]
aarch64: Apply narrowing of allowed immediate values for SYSP

While CRn and CRm fields in the SYSP instruction are 4-bit wide and
are thus able to accommodate values in the range 0-15, the
specifications for the SYSP instructions limit their ranges to 8-9 for
CRm and 0-7 in the case of CRn.

This led to the need to signal in some way to the operand parser that
a given operand is under special restrictions regarding its use.  This
is done via the new `F_OPD_NARROW' flag, indicating a narrowing in the
range of operand values for fields in the instruction tagged with the
flag.

The flag is then used in `parse_operands' when the instruction is
assembled, but needs not be taken into consideration during
disassembly.

9 months agoaarch64: Add support for the SYSP 128-bit system instruction
Victor Do Nascimento [Wed, 15 Nov 2023 14:29:31 +0000 (14:29 +0000)]
aarch64: Add support for the SYSP 128-bit system instruction

Mirroring the use of the `sys' - System Instruction assembly
instruction, this implements its 128-bit counterpart, `sysp'.

This optionally takes two contiguous general-purpose registers
starting at an even number or, when these are omitted, by default
sets both of these to xzr.

Syntax:

sysp #<op1>, <Cn>, <Cm>, #<op2>{, <Xt1>, <Xt2>}

9 months agoaarch64: Add support for optional operand pairs
Victor Do Nascimento [Wed, 13 Dec 2023 14:27:31 +0000 (14:27 +0000)]
aarch64: Add support for optional operand pairs

Two of the instructions added by the `+d128' architectural extension
add the flexibility to have two optional operands.  Prior to the
addition of the `tlbip' and `sysp' instructions, no mnemonic allowed
more than one such optional operand.

With `tlbip' as an example, some TLBIP instruction names do not allow
for any optional operands, while others allow for both to be optional.
In the latter case, it is possible that either the second operand
alone is omitted or both operands are omitted.
Therefore, a considerable degree of flexibility needed to be added to
the way operands were parsed.  It was, however, possible to achieve
this with relatively few changes to existing code.

it is noteworthy that opcode flags specifying the optional operand
number are non-orthogonal. For example, we have:

       #define F_OPD1_OPT (2 << 12) : 0b10 << 12
       #define F_OPD2_OPT (3 << 12) : 0b11 << 12

such that by virtue of the observation that

       (F_OPD1_OPT | F_OPD2_OPT) == F_OPD2_OPT

it is impossible to mark both operands 1 and 2 as optional for an
instruction and it is assumed that a maximum of 1 operand can ever be
optional.  This is not overly-problematic given that, for optional
pairs, the second optional operand is always found immediately after
the first.  Thus, it suffices for us to flag that there is a second
optional operand.  With this fact, we can infer its position in the
mnemonic from the position of the first (e.g. if the second operand in
the mnemonic is optional, we know the third is too).  We therefore
define the `F_OPD_PAIR_OPT' flag and calculate its position in the
mnemonic from the value encoded by the `F_OPD<n>_OPT' flag.

Another observation is that there is a tight coupling between default
values assigned to the two registers when one (or both) are omitted
from the mnemonic.  Namely, if Xt1 has a value of 0x1f (the zero
register is specified), Xt2 defaults to the same value, otherwise Xt2
will be assigned Xt + 1.  This meant that where you have default value
validation, in checking the second optional operand's value, it is
also necessary to look at the value assigned to the
previously-processed operand value before deciding its validity. Thus
`process_omitted_operand' needs not only access to its `operand'
argument, but also to the global `inst' struct.

9 months agoaarch64: Add support for xzr register in register pair operands
Victor Do Nascimento [Wed, 13 Dec 2023 14:09:08 +0000 (14:09 +0000)]
aarch64: Add support for xzr register in register pair operands

Analysis of the allowed operand values for `sysp' and `tlbip' reveals
a significant departure from the allowed behavior for operand register
pairs (hitherto labeled AARCH64_OPND_PAIRREG) observed for other
insns in this category.

For instructions `casp', `mrrs' and `msrr' the register pair must
always start at an even index and the second register in the pair is
the index + 1.  This precludes the use of xzr as the first register,
given it corresponds to register number 31.

This is different in the case of `sysp' and `tlbip', however.  These
allow the use of xzr and, where the first operand in the pair is
omitted, this is the default value assigned to it.  When this
operand is assigned xzr, it is expected that the second operand will
likewise take on a value of xzr.

These two instructions therefore "break" two rules of register pairs:

  * The first of the two registers is odd-numbered.
  * The index of the second register is equal to that of the first,
  and not n+1.

To allow for this departure from hitherto standard behavior, we
extend the functionality of the assembler by defining an extension of
the AARCH64_OPND_PAIRREG, called AARCH64_OPND_PAIRREG_OR_XZR.

It is used in defining `sysp' and `tlbip' and allows
`operand_general_constraint_met_p' to allow the pair to both take on
the value of xzr.

9 months agoaarch64: Expand maximum number of operands from 5 to 6
Victor Do Nascimento [Wed, 15 Nov 2023 13:48:59 +0000 (13:48 +0000)]
aarch64: Expand maximum number of operands from 5 to 6

Given the introduction of the new Armv9.4-a `sysp' insn using the
following syntax:

sysp #<op1>, <Cn>, <Cm>, #<op2>{, <Xt1>, <Xt2>}

and by extension the need to encode 6 assembly operands, extend
Binutils to handle instructions taking 6 operands, up from a previous
maximum of 5.

9 months agoaarch64: Add +d128 architectural feature support
Victor Do Nascimento [Wed, 15 Nov 2023 12:21:33 +0000 (12:21 +0000)]
aarch64: Add +d128 architectural feature support

Indicating the presence of the Armv9.4-a features concerning 128-bit
Page Table Descriptors, 128-bit System Registers and Instructions,
the "+d128" architectural extension flag is added to the list of
possible -march options in Binutils, together with the necessary macro
for encoding d128 instructions.

9 months agosim: warnings: compile build tools with -Werror too
Mike Frysinger [Wed, 30 Jun 2021 00:16:38 +0000 (20:16 -0400)]
sim: warnings: compile build tools with -Werror too

Add support for compiling build tools with various -Werror settings.
Since the tools don't compile cleanly with the same set of flags as
the rest of the sim code, we need to maintain & test a separate list.

Only bother when not cross-compiling so we don't have to test all the
flags against the build compiler.  This should be good enough for our
actual development flows.

9 months agosim: igen: fix format-zero-length warnings
Mike Frysinger [Tue, 9 Jan 2024 02:15:51 +0000 (21:15 -0500)]
sim: igen: fix format-zero-length warnings

Fix warnings from calling printf functions with "" which normally
is useless.

9 months agosim: m68hc11: gencode: add printf markings
Mike Frysinger [Tue, 9 Jan 2024 01:50:01 +0000 (20:50 -0500)]
sim: m68hc11: gencode: add printf markings

9 months agosim: m32c: fix declaration-after-statement warnings
Mike Frysinger [Tue, 9 Jan 2024 01:47:00 +0000 (20:47 -0500)]
sim: m32c: fix declaration-after-statement warnings

9 months agosim: warnings: fix unused variable warnings
Mike Frysinger [Tue, 9 Jan 2024 01:44:02 +0000 (20:44 -0500)]
sim: warnings: fix unused variable warnings

Leave the igen code in place as it's meant to be used with newer
(to-be-written) code ported from the ppc version.

The sh code isn't really necessary as the opcodes enums have been
maintained independently from here, and the lists are out-of-sync
already.

9 months agosim: warnings: mark local funcs/vars as static
Mike Frysinger [Tue, 9 Jan 2024 01:39:57 +0000 (20:39 -0500)]
sim: warnings: mark local funcs/vars as static

These are only used in the respective files, so mark them as static.
This fixes missing prototype warnings at build time.

9 months agoBack out some parallel_for_each features
Tom Tromey [Sun, 1 Jan 2023 19:31:24 +0000 (12:31 -0700)]
Back out some parallel_for_each features

Now that the DWARF reader does not use parallel_for_each, we can
remove some of the features that were added just for it: return values
and task sizing.

The thread_pool typed tasks feature could also be removed, but I
haven't done so here.  This one seemed less intrusive and perhaps more
likely to be needed at some point.

9 months agoAvoid language-based lookups in startup path
Tom Tromey [Sat, 21 Oct 2023 22:38:44 +0000 (16:38 -0600)]
Avoid language-based lookups in startup path

The previous patches are nearly enough to enable background DWARF
reading.  However, this hack in language_defn::get_symbol_name_matcher
causes an early computation of current_language:

  /* If currently in Ada mode, and the lookup name is wrapped in
     '<...>', hijack all symbol name comparisons using the Ada
     matcher, which handles the verbatim matching.  */
  if (current_language->la_language == language_ada
      && lookup_name.ada ().verbatim_p ())
    return current_language->get_symbol_name_matcher_inner (lookup_name);

I considered various options here -- reversing the order of the
checks, or promoting the verbatim mode to not be a purely Ada feature
-- but in the end found that the few calls to this during startup
could be handled more directly.

In the JIT code, and in create_exception_master_breakpoint_hook, gdb
is really looking for a certain kind of symbol (text or data) using a
linkage name.  Changing the lookup here is clearer and probably more
efficient as well.

In create_std_terminate_master_breakpoint, the lookup can't really be
done by linkage name (it would require relying on a certain mangling
scheme, and also may trip over versioned symbols) -- but we know that
this spot is C++-specific, and so the language ought to be temporarily
set to C++ here.

After this patch, the "file" case is much faster:

    (gdb) file /tmp/gdb
    2023-10-23 13:16:54.456 - command started
    Reading symbols from /tmp/gdb...
    2023-10-23 13:16:54.520 - command finished
    Command execution time: 0.225906 (cpu), 0.064313 (wall)

9 months agoOptimize lookup_minimal_symbol_text
Tom Tromey [Sat, 21 Oct 2023 22:38:23 +0000 (16:38 -0600)]
Optimize lookup_minimal_symbol_text

lookup_minimal_symbol_text always loops over all objfiles, even when
an objfile is passed in as an argument.  This patch changes the
function to loop over the minimal number of objfiles in the latter
situation.

9 months agoLazy language setting
Tom Tromey [Wed, 29 Mar 2023 16:55:13 +0000 (10:55 -0600)]
Lazy language setting

When gdb starts up with a symbol file, it uses the program's "main" to
decide the "static context" and the initial language.  With background
DWARF reading, this means that gdb has to wait for a significant
amount of DWARF to be read synchronously.

This patch introduces lazy language setting.  The idea here is that in
many cases, the prompt can show up early, making gdb feel more
responsive.

9 months agoChange current_language to be a macro
Tom Tromey [Wed, 29 Mar 2023 02:30:01 +0000 (20:30 -0600)]
Change current_language to be a macro

This changes the 'current_language' global to be a macro that wraps a
function call.  This change will let a subsequent patch introduce lazy
language setting.

9 months agoRemove two quick_symbol_functions methods
Tom Tromey [Sun, 1 Jan 2023 19:14:21 +0000 (12:14 -0700)]
Remove two quick_symbol_functions methods

quick_symbol_functions::read_partial_symbols is no longer implemented,
so both it and quick_symbol_functions::can_lazily_read_symbols can be
removed.  This allows for other functions to be removed as well.

Note that SYMFILE_NO_READ is now pretty much dead.  I haven't removed
it here -- but could if that's desirable.  I tend to think that this
functionality would be better implemented in the core; but whenever I
dive into the non-DWARF readers it is pretty depressing.

9 months agoSimplify the public DWARF API
Tom Tromey [Sun, 1 Jan 2023 16:51:04 +0000 (09:51 -0700)]
Simplify the public DWARF API

dwarf2_has_info and dwarf2_initialize_objfile are only separate
because the DWARF reader implemented lazy psymtab reading.  However,
now that this is gone, we can simplify the public DWARF API again.

9 months agoDo more DWARF reading in the background
Tom Tromey [Sat, 25 Mar 2023 05:35:02 +0000 (23:35 -0600)]
Do more DWARF reading in the background

This patch rearranges the DWARF reader so that more work is done in
the background.  This is PR symtab/29942.

The idea here is that there is only a small amount of work that must
be done on the main thread when scanning DWARF -- before the main
scan, the only part is mapping the section data.

Currently, the DWARF reader uses the quick_symbol_functions "lazy"
functionality to defer even starting to read.  This patch instead
changes the reader to start reading immediately, but doing more in
worker tasks.

Before this patch, "file" on my machine:

    (gdb) file /tmp/gdb
    2023-10-23 12:29:56.885 - command started
    Reading symbols from /tmp/gdb...
    2023-10-23 12:29:58.047 - command finished
    Command execution time: 5.867228 (cpu), 1.162444 (wall)

After the patch, more work is done in the background and so this takes
a bit less time:

    (gdb) file /tmp/gdb
    2023-10-23 13:25:51.391 - command started
    Reading symbols from /tmp/gdb...
    2023-10-23 13:25:51.712 - command finished
    Command execution time: 1.894500 (cpu), 0.320306 (wall)

I think this could be further sped up by using the shared library load
map to avoid objfile loops like the one in expand_symtab_containing_pc
-- it seems like the correct objfile could be chosen more directly.

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

9 months agoChange how cooked index waits for threads
Tom Tromey [Tue, 27 Dec 2022 15:58:38 +0000 (08:58 -0700)]
Change how cooked index waits for threads

This changes the cooked index code to wait for threads in its
public-facing API.  That is, the waits are done in cooked_index now,
and never in the cooked_index_shard.  Centralizing this decision makes
it easier to wait for other events here as well.

9 months agoAdd "maint set dwarf synchronous"
Tom Tromey [Sat, 21 Oct 2023 21:22:09 +0000 (15:22 -0600)]
Add "maint set dwarf synchronous"

For testing, it's sometimes convenient to be able to request that
DWARF reading be done synchronously.  This patch adds a new "maint"
setting for this purpose.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
9 months agoMove cooked_index_storage to cooked-index.h
Tom Tromey [Mon, 26 Dec 2022 17:23:32 +0000 (10:23 -0700)]
Move cooked_index_storage to cooked-index.h

This moves cooked_index_storage to cooked-index.h.  This is needed by
a subsequent patch.

9 months agoAdd gdb::task_group
Tom Tromey [Thu, 23 Mar 2023 22:53:01 +0000 (16:53 -0600)]
Add gdb::task_group

This adds gdb::task_group, a convenient way to group background tasks
and then call a function when all the tasks have completed.

9 months agoAdd quick_symbol_functions::compute_main_name
Tom Tromey [Fri, 30 Dec 2022 18:29:12 +0000 (11:29 -0700)]
Add quick_symbol_functions::compute_main_name

This adds a new compute_main_name method to quick_symbol_functions.
Currently there are no implementations of this, but a subsequent patch
will add one.

9 months agoAdd deferred_warnings parameter to read_addrmap_from_aranges
Tom Tromey [Sun, 10 Dec 2023 21:16:06 +0000 (14:16 -0700)]
Add deferred_warnings parameter to read_addrmap_from_aranges

When DWARF reading is done in the background,
read_addrmap_from_aranges will be called from a worker thread.
Because warnings can't be emitted from these threads, this patch adds
a new deferred_warnings parameter to the function, letting the caller
control exactly how the warnings are emitted.

9 months agoRefactor complaint thread-safety approach
Tom Tromey [Sat, 24 Dec 2022 15:40:48 +0000 (08:40 -0700)]
Refactor complaint thread-safety approach

This patch changes the way complaint works in a background thread.
The new approach requires installing a complaint interceptor in each
worker, and then the resulting complaints are treated as one of the
results of the computation.  This change is needed for a subsequent
patch, where installing a complaint interceptor around a parallel-for
is no longer a viable approach.

9 months agoAdd thread-safety to gdb's BFD wrappers
Tom Tromey [Sat, 18 Feb 2023 16:27:58 +0000 (09:27 -0700)]
Add thread-safety to gdb's BFD wrappers

This changes gdb to ensure that gdb's BFD cache is guarded by a lock.
This avoids any races when multiple threads might open a BFD (and thus
use the BFD cache) at the same time.

Currently, this change is not needed because the the main thread waits
for some DWARF scanning to be completed before returning.  The only
locking that's required is when opening DWO files, and there's a local
lock to this end in dwarf2/read.c.

However, in the coming patches, the DWARF reader will begin its work
earlier, in the background.  This means there is the potential for the
DWARF reader and other code on the main thread to both attempt to open
BFDs at the same time.

9 months agoAdd a couple of bfd_cache_close calls
Tom Tromey [Sat, 11 Nov 2023 16:46:44 +0000 (09:46 -0700)]
Add a couple of bfd_cache_close calls

This adds a couple of calls to bfd_cache_close at points where a BFD
isn't actively needed by gdb.  Normally at these points, all the
needed section data is already mapped, so we can simply close the file
descriptor.  This is harmless at worst, because if this is needed
after all, the BFD file descriptor cache will reopen it.

9 months agoPre-read DWZ section data
Tom Tromey [Fri, 10 Nov 2023 22:52:19 +0000 (15:52 -0700)]
Pre-read DWZ section data

This changes the DWZ code to pre-read the section data and somewhat
simplify the DWZ API.  This makes it easier to add the bfd_cache_close
call to the new dwarf2_read_dwz_file function -- after this is done,
there shouldn't be a reason to keep the BFD's file descriptor open.

9 months agoDon't use objfile::intern in DWO code
Tom Tromey [Sun, 12 Nov 2023 16:23:49 +0000 (09:23 -0700)]
Don't use objfile::intern in DWO code

The DWO code in the DWARF reader currently uses objfile::intern.  This
accesses a shared data structure and so would be racy when used from
multiple threads.  I don't believe this can happen right now, but
background reading could provoke this, and in any case it's better to
avoid this, just to be sure.

This patch changes this code to just use a std::string.  A new type is
introduced to do hash table lookups, to avoid unnecessary copies.

9 months agosim: build: clean more generated outputs
Mike Frysinger [Tue, 9 Jan 2024 01:27:23 +0000 (20:27 -0500)]
sim: build: clean more generated outputs

9 months agosim: mips: drop old clean workaround
Mike Frysinger [Tue, 9 Jan 2024 01:15:50 +0000 (20:15 -0500)]
sim: mips: drop old clean workaround

This logic dates back to the original import, and seems to be for
handling systems where `rm -f` (i.e. no files) would error out.
None of that is relevant for us with current automake, so drop it.

9 months agosim: ppc: workaround uninitialized variable compiler warnings
Mike Frysinger [Wed, 3 Jan 2024 08:38:35 +0000 (03:38 -0500)]
sim: ppc: workaround uninitialized variable compiler warnings

Some compilers don't understand the semctl API and think it's an input
argument even when it's used as an output, and then complains that it
is being used uninitialized.  Zero it out explicitly to workaround it.
This adds some runtime overhead, but should be fairly minor as it's a
small stack buffer, and shouldn't be that relevant relative to all the
other logic in these functions.

9 months agosim: warnings: enable -Wshift-negative-value
Mike Frysinger [Sun, 7 Jan 2024 04:36:13 +0000 (23:36 -0500)]
sim: warnings: enable -Wshift-negative-value

Now that all the relevant sources are fixed, enable the warning.

9 months agosim: sh: avoid left shifting negative values
Mike Frysinger [Sun, 7 Jan 2024 05:23:41 +0000 (00:23 -0500)]
sim: sh: avoid left shifting negative values

We just want to create a bitmask here, so cast the mask to unsigned
to avoid left shifting a negative value which is undefined behavior.

9 months agosim: bfin: avoid left shifting negative values
Mike Frysinger [Sun, 7 Jan 2024 05:22:55 +0000 (00:22 -0500)]
sim: bfin: avoid left shifting negative values

We just want to create a bitmask here, so cast the mask to unsigned
to avoid left shifting a negative value which is undefined behavior.

9 months agosim: cgen: rework DI macros to avoid signed left shifts
Mike Frysinger [Sun, 7 Jan 2024 04:16:41 +0000 (23:16 -0500)]
sim: cgen: rework DI macros to avoid signed left shifts

The cgen code uses DI as int64_t and UDI as uint64_t.  The DI macros
are used to construct 64-bit values from 32-bit values (for the low
and high parts).  The MAKEDI macro casts the high 32-bit value to a
signed 32-bit value before shifting.  If this created a negative
value, this would be undefined behavior according to the C standard.
All we care about is shifting the 32-bits as they are to the high
32-bits, not caring about sign extension (since there's nothing left
to shift into), and the low 32-bits being empty.  This is what we
get from shifting an unsigned value, so cast it to unsigned 32-bit
to avoid undefined behavior.

While we're here, change the SETLODI macro to truncate the lower
value to 32-bits before we set it.  If it was passing in a 64-bit
value, those high bits would get included too, and that's not what
we want.

Similarly, tweak the SETHIDI macro to cast the value to an unsigned
64-bit instead of a signed 64-bit.  If the value was only 32-bits,
the behavior would be the same.  If it happened to be signed 64-bit,
it would trigger the undefined behavior too.

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

9 months agobpf: Added linker support for R_BPF_64_NODYLD32.
Cupertino Miranda [Wed, 20 Dec 2023 12:24:03 +0000 (12:24 +0000)]
bpf: Added linker support for R_BPF_64_NODYLD32.

This patch adds linker support to patch R_BPF_64_NODYLD32 relocations.
The implementation was based on comments and code in LLVM, as the GNU
toolchain does not uses this relocation type.

9 months agoMAINTAINERS: Update my email address
Joseph Myers [Mon, 8 Jan 2024 18:55:03 +0000 (18:55 +0000)]
MAINTAINERS: Update my email address

9 months agoMIPS/GAS: mips.exp, mark all mipsisa32*-linux as addr32
YunQiang Su [Fri, 24 Nov 2023 08:55:12 +0000 (16:55 +0800)]
MIPS/GAS: mips.exp, mark all mipsisa32*-linux as addr32

Currently, only mipsisa32-linux and mipsisa32el-linux is marked
as addr32, which make mipsisa32rN(el) not marked.

This change can fix 2 test failures on mipsisa32rN(el)-linux:
FAIL: MIPS MIPS64 MIPS-3D ASE instructions (-mips3d flag)
FAIL: MIPS MIPS64 MDMX ASE instructions (-mdmx flag)

These failures don't happen for mipsisa32rN-mti-elf etc,
due to that, the output is set as NO_ABI instead of O32, then
gas won't warn:
`fp=64' used with a 32-bit ABI
Maybe, we should change this behaivour in future.

9 months agoarm: Add support for Armv8.9-A and Armv9.4-A
srinath [Mon, 8 Jan 2024 14:13:28 +0000 (14:13 +0000)]
arm: Add support for Armv8.9-A and Armv9.4-A

This patch adds AArch32 support for -march=armv8.9-a and
-march=armv9.4-a. The behaviour of the new options can be
expressed using a combination of existing feature flags
and tables.

The cpu_arch_ver entries for ARM_ARCH_V9_4A and ARM_ARCH_V8_9A
are technically redundant but it including them for macro code
consistency across architectures.

9 months agoaarch64: Add ite feature system registers.
srinath [Mon, 8 Jan 2024 14:08:58 +0000 (14:08 +0000)]
aarch64: Add ite feature system registers.

This patch adds ite feature (FEAT_ITE) system registers,
trcitecr_el1, trcitecr_el12, trcitecr_el2 and trciteedcr.

9 months agogas/doc: fix several typos
Samuel Tardieu [Thu, 4 Jan 2024 16:44:16 +0000 (17:44 +0100)]
gas/doc: fix several typos

Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
9 months ago[gdb/testsuite] Add missing -no-prompt-anchor in gdb.base/vfork-follow-parent.exp
Tom de Vries [Mon, 8 Jan 2024 12:01:50 +0000 (13:01 +0100)]
[gdb/testsuite] Add missing -no-prompt-anchor in gdb.base/vfork-follow-parent.exp

When running test-case gdb.base/vfork-follow-parent.exp it passes fine, but
when running it with "taskset -c 0" I run into:
...
(gdb) inferior 1^M
[Switching to inferior 1 [process 26606] (vfork-follow-parent-exit)]^M
[Switching to thread 1.1 (process 26606)]^M
(gdb) Reading symbols from vfork-follow-parent-exit...^M
FAIL: $exp: exec_file=vfork-follow-parent-exit: target-non-stop=on: \
  non-stop=off: resolution_method=schedule-multiple: inferior 1 (timeout)
...

Fix this by using -no-prompt-anchor.

Tested on x86_64-linux.

PR testsuite/31166
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31166

9 months agoAdd support for the aarch64-gnu target (GNU/Hurd on AArch64)
Sergey Bugaev [Mon, 1 Jan 2024 11:53:09 +0000 (14:53 +0300)]
Add support for the aarch64-gnu target (GNU/Hurd on AArch64)

Also recognized are aarch64-*-gnu tagrets, e.g. aarch64-pc-gnu or
aarch64-unknown-gnu.

The ld/emulparams/aarch64gnu.sh file is (for now) identical to aarch64fbsd.sh,
or to aarch64linux.sh with Linux-specific logic removed; and mainly different
from the generic aarch64elf.sh in that it does not set EMBEDDED=yes.

Coupled with a corresponding GCC patch, this produces a toolchain that can
sucessfully build working binaries targeting aarch64-gnu.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
9 months ago[gdb/testsuite] Make gdb.base/solib-search.exp more robust
Tom de Vries [Mon, 8 Jan 2024 09:37:44 +0000 (10:37 +0100)]
[gdb/testsuite] Make gdb.base/solib-search.exp more robust

On aarch64-linux, with gcc 13.2.1, I run into:
...
 (gdb) backtrace^M
 #0  break_here () at solib-search.c:30^M
 #1  0x0000fffff7f20194 in lib2_func4 () at solib-search-lib2.c:50^M
 #2  0x0000fffff7f70194 in lib1_func3 () at solib-search-lib1.c:50^M
 #3  0x0000fffff7f20174 in lib2_func2 () at solib-search-lib2.c:30^M
 #4  0x0000fffff7f70174 in lib1_func1 () at solib-search-lib1.c:30^M
 #5  0x00000000004101b4 in main () at solib-search.c:23^M
 (gdb) PASS: gdb.base/solib-search.exp: \
   backtrace (with wrong libs) (data collection)
 FAIL: gdb.base/solib-search.exp: backtrace (with wrong libs)
...

The FAIL is generated by this code in the test-case:
...
    if { $expect_fail } {
# If the backtrace output is correct the test isn't sufficiently
# testing what it should.
if { $count == $total_expected } {
    set fail 1
}
...

The test-case:
- builds two versions of two shared libs, a "right" and "wrong" version, the
  difference being an additional dummy function (called spacer function),
- uses the "right" version to generate a core file,
- uses the "wrong" version to interpret the core file, and
- generates a backtrace.

The intent is that the backtrace is incorrect due to using the "wrong"
version, but actually it's correct.  This is because the spacer functions
aren't large enough.

Fix this by increasing the size of the spacer functions by adding a dummy
loop, after which we have, as expected, an incorrect backtrace:
...
 (gdb) backtrace^M
 #0  break_here () at solib-search.c:30^M
 #1  0x0000fffff7f201c0 in ?? ()^M
 #2  0x0000fffff7f20174 in lib2_func2 () at solib-search-lib2.c:30^M
 #3  0x0000fffff7f20174 in lib2_func2 () at solib-search-lib2.c:30^M
 #4  0x0000fffff7f70174 in lib1_func1 () at solib-search-lib1.c:30^M
 #5  0x00000000004101b4 in main () at solib-search.c:23^M
 (gdb) PASS: gdb.base/solib-search.exp: \
   backtrace (with wrong libs) (data collection)
 PASS: gdb.base/solib-search.exp: backtrace (with wrong libs)
...

Tested on aarch64-linux.

9 months agoi386: Use .insn describe jmpabs's testcases.
Hu, Lin1 [Mon, 8 Jan 2024 07:47:30 +0000 (15:47 +0800)]
i386: Use .insn describe jmpabs's testcases.

gas/ChangeLog:

* testsuite/gas/i386/x86-64-apx-jmpabs-inval.s: Use .insn instead
of .byte to describe test cases.

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

9 months agoi386: Correct adcx suffix in disassembler
H.J. Lu [Sun, 7 Jan 2024 19:58:53 +0000 (11:58 -0800)]
i386: Correct adcx suffix in disassembler

Since 0x66 is the opcode prefix for adcx, it is wrong to use the 'S'
prefix:

  'S' => print 'w', 'l' or 'q' if suffix_always is true

on adcx.  Add

  'L' => print 'l' or 'q' if suffix_always is true

replace S with L on adcx and adox.

gas/

PR binutils/31219
* testsuite/gas/i386/suffix.d: Updated.
* testsuite/gas/i386/x86-64-suffix.d: Likewise.
* testsuite/gas/i386/suffix.s: Add tests for adcx and adox.
* testsuite/gas/i386/x86-64-suffix.s: Likewise.

opcodes/

PR binutils/31219
* i386-dis.c: Add the 'L' suffix.
(prefix_table): Replace S with L on adcx and adox.
(putop): Handle the 'L' suffix.

9 months agosim: warnings: enable -Wshadow=local
Mike Frysinger [Fri, 22 Dec 2023 01:14:49 +0000 (20:14 -0500)]
sim: warnings: enable -Wshadow=local

This brings us in sync with current set of gdb warnings (for C).

9 months agosim: cris: change temp var name slightly to avoid shadowing
Mike Frysinger [Fri, 22 Dec 2023 00:41:17 +0000 (19:41 -0500)]
sim: cris: change temp var name slightly to avoid shadowing

Rename the temp var to avoid shadowing another one:

.../sim/cris/semcrisv10f-switch.c:11032:22: error: declaration of ‘tmp_tmpb’ shadows a previous local [-Werror=shadow=compatible-local]
11032 |   tmp_tmpb = ({   SI tmp_tmpb;
      |                      ^~~~~~~~
.../sim/cris/semcrisv10f-switch.c:11031:24: note: shadowed declaration is here
11031 |   tmp_tmpres = ({   SI tmp_tmpb;
      |                        ^~~~~~~~

9 months agosim: cris: add error fallbacks when decoding condition & swap codes
Mike Frysinger [Sun, 24 Dec 2023 10:13:42 +0000 (05:13 -0500)]
sim: cris: add error fallbacks when decoding condition & swap codes

The condition & swap code decoder only checks known bits and sets
based on that.  If the variable is out of range, it ends up returning
uninitialized data.  Turn that case into a hard error.

This fixes build warnings like:
sim/cris/semcrisv10f-switch.c:13115:11: error:
variable 'tmp_condres' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

9 months agoAutomatic date update in version.in
GDB Administrator [Sun, 7 Jan 2024 00:01:58 +0000 (00:01 +0000)]
Automatic date update in version.in

9 months agold: Adjust x86 and x86-64 tests for -z mark-plt
H.J. Lu [Sat, 6 Jan 2024 14:43:04 +0000 (06:43 -0800)]
ld: Adjust x86 and x86-64 tests for -z mark-plt

To support -z mark-plt enabled by default, adjust x86 tests to accept
non-zero r_addend for JUMP_SLOT relocation and pass -z nomark-plt to
x86-64 tests if -z mark-plt changes the expected outputs.

* testsuite/ld-elf/indirect-extern-access-2.rd: Allow non-zero
r_addend for JUMP_SLOT relocation.
* testsuite/ld-elf/pr23161d.rd: Likewise.
* testsuite/ld-ifunc/ifunc-25c-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-16-x86-64-now.d: Pass -z nomark-plt
to linker.
* testsuite/ld-ifunc/ifunc-16-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-local-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-20-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-5b-x86-64.d: Likewise.
* testsuite/ld-ifunc/pr17154-x86-64-now.d: Likewise.
* testsuite/ld-ifunc/pr17154-x86-64.d: Likewise.
* testsuite/ld-x86-64/dt-relr-1a-x32.d: Likewise.
* testsuite/ld-x86-64/dt-relr-1a.d: Likewise.
* testsuite/ld-x86-64/dt-relr-1b-x32.d: Likewise.
* testsuite/ld-x86-64/dt-relr-1b.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2a.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3a.d: Likewise.
* testsuite/ld-x86-64/pr19636-2d.d: Likewise.
* testsuite/ld-x86-64/pr19636-2e.d: Likewise.
* testsuite/ld-x86-64/pr19636-2f.d: Likewise.
* testsuite/ld-x86-64/pr19636-2l.d: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Pass -z nomark-plt to linker
in 6 tests.

9 months agogas: sframe: fix some typos in code comments
Indu Bhagat [Sat, 6 Jan 2024 11:05:44 +0000 (03:05 -0800)]
gas: sframe: fix some typos in code comments

9 months agoAutomatic date update in version.in
GDB Administrator [Sat, 6 Jan 2024 00:01:23 +0000 (00:01 +0000)]
Automatic date update in version.in

9 months agox86: relax AMD Zen5 testcase expectations
Jan Beulich [Fri, 5 Jan 2024 11:08:23 +0000 (12:08 +0100)]
x86: relax AMD Zen5 testcase expectations

One item was too strict for PE/COFF, and there's really no need to check
for specific comment contents here.

9 months agoAdd AMD znver5 processor support
Tejas Joshi [Wed, 20 Dec 2023 05:10:21 +0000 (10:40 +0530)]
Add AMD znver5 processor support

gas/

* config/tc-i386.c (cpu_arch): Add znver5 ARCH.
* doc/c-i386.texi: Add znver5.
* testsuite/gas/i386/arch-15.d: New.
* testsuite/gas/i386/arch-15.s: Likewise.
* testsuite/gas/i386/arch-15-znver5.d: Likewise.
* testsuite/gas/i386/i386.exp: Add new znver5 test cases.
* testsuite/gas/i386/x86-64.exp: Likewise.
* testsuite/gas/i386/x86-64-arch-5.d: Likewise.
* testsuite/gas/i386/x86-64-arch-5.s: Likewise.
* testsuite/gas/i386/x86-64-arch-5-znver5.d: Likewise.

opcodes/

* i386-gen.c (isa_dependencies): Add ZNVER5 dependencies.
* i386-init.h: Re-generated.

9 months agoArm/doc: separate @code from @item for older makeinfo
Jan Beulich [Fri, 5 Jan 2024 08:28:43 +0000 (09:28 +0100)]
Arm/doc: separate @code from @item for older makeinfo

At least 4.12 doesn't like the constructs without a separator.

9 months agox86: corrections to CPU attribute/flags splitting
Jan Beulich [Fri, 5 Jan 2024 07:20:23 +0000 (08:20 +0100)]
x86: corrections to CPU attribute/flags splitting

There are a number of issues with 734dfd1cc966 ("x86: pack CPU flags in
opcode table"):
- the condition when two array slots need writing wasn't correct (with
  enough new Cpu* added an out of bounds array access would validly have
  been complained about by the compiler),
- table generation didn't take into account CpuAttrUnused and CpuUnused
  being independent, and hence there not always (not) being an "unused"
  bitfield member in both structures,
- cpu_flags_from_attr() wasn't ready for use on big-endian hosts,
- there were two style violations.

9 months agoELF: test certain .text/.data usages
Jan Beulich [Fri, 5 Jan 2024 07:17:34 +0000 (08:17 +0100)]
ELF: test certain .text/.data usages

Various targets have / had overrides for .text and/or .data. Make sure
that in such cases sub-section specifiers are accepted, as mandated by
the doc.

9 months agoELF: test certain .bss usages
Jan Beulich [Fri, 5 Jan 2024 07:16:30 +0000 (08:16 +0100)]
ELF: test certain .bss usages

Various targets have / had overrides for .bss. Make sure that in such
cases
- .previous still works correctly (requiring such targets to invoke
  obj_elf_section_change_hook() from their overriding handlers),
- sub-section specifiers are accepted as far as feasible (mandated by
  the doc).

9 months agogas: correct .bss documentation for non-ELF
Jan Beulich [Fri, 5 Jan 2024 07:13:09 +0000 (08:13 +0100)]
gas: correct .bss documentation for non-ELF

Only ELF permits the specification of a subsection, and even there not
consistently: csky, mcore, and spu handle .bss similar to .lcomm.

9 months agoz80: drop .bss override
Jan Beulich [Fri, 5 Jan 2024 07:12:11 +0000 (08:12 +0100)]
z80: drop .bss override

It doesn't look to be a good idea to override the custom handlers that
ELF and COFF have; afaict doing so broke .previous on ELF, and a sub-
section specifier wasn't accepted either.

9 months agovisium: drop .bss and .skip overrides
Jan Beulich [Fri, 5 Jan 2024 07:11:43 +0000 (08:11 +0100)]
visium: drop .bss and .skip overrides

The comment in s_bss() looks bogus (perhaps simply stale, or wrongly
copied from another target). It also doesn't look to be a good idea to
override the custom handler that ELF has (afaict doing so broke
.previous as well as sub-section specification).

The override for .skip is simply pointless, for read.c having exactly
the same.

While there also drop two adjacent redundant (with read.h) declarations
(which would be outright dangerous if read.h wasn't included anyway).

9 months agov850: drop .bss override
Jan Beulich [Fri, 5 Jan 2024 07:11:18 +0000 (08:11 +0100)]
v850: drop .bss override

While there doesn't look to be anything wrong with this override,
there's also no apparent reason why this override would be needed. Drop
it, reducing overall size a tiny bit.

9 months agoscore: drop .bss override
Jan Beulich [Fri, 5 Jan 2024 07:10:21 +0000 (08:10 +0100)]
score: drop .bss override

The comment looks bogus (perhaps simply stale, or wrongly copied from
another target). It also doesn't look to be a good idea to override the
custom handler that ELF has (afaict doing so broke .previous as well as
sub-section specification).

While there also fold the identical handlers for .text (there likely is
more room for such folding).

9 months agos390: drop .bss override
Jan Beulich [Fri, 5 Jan 2024 07:10:01 +0000 (08:10 +0100)]
s390: drop .bss override

The comment looks bogus (perhaps simply stale), and there are also no
other precautions against subsections being used on ELF with .bss. It
also doesn't look to be a good idea to override the custom handler that
ELF has (afaict doing so further broke .previous).

9 months agorx: drop .bss override
Jan Beulich [Fri, 5 Jan 2024 07:09:40 +0000 (08:09 +0100)]
rx: drop .bss override

It doesn't look to be a good idea to override the custom handler that
ELF has; afaict doing so broke .previous.

9 months agorl78: drop .bss override
Jan Beulich [Fri, 5 Jan 2024 07:09:18 +0000 (08:09 +0100)]
rl78: drop .bss override

It doesn't look to be a good idea to override the custom handler that
ELF has; afaict doing so broke .previous.

9 months agopru: fix .text/.data interaction with .previous
Jan Beulich [Fri, 5 Jan 2024 07:08:52 +0000 (08:08 +0100)]
pru: fix .text/.data interaction with .previous

Just like obj_elf_section() is called for .section, obj_elf_{text,data}()
need calling for .text/.data.

9 months agomicroblaze: drop/restrict override of .text, .data, and .bss
Jan Beulich [Fri, 5 Jan 2024 07:07:58 +0000 (08:07 +0100)]
microblaze: drop/restrict override of .text, .data, and .bss

While only ELF is supported right now, (stub) code generally is in place
for the non-ELF case as well. Don't override .bss for ELF - that's
unlikely to be a good idea anyway and prevented the sub-section
specifier from being usable. Don't override .text and .data at all - for
.data and ELF for the same reason, while for .text and ELF obj-elf.c's is
all we need, and for (hypothetical) non-ELF read.c's identical handling
would have been invoked anyway.

9 months agom68k: drop .bss override
Jan Beulich [Fri, 5 Jan 2024 07:06:54 +0000 (08:06 +0100)]
m68k: drop .bss override

The comment looks bogus (perhaps simply stale), and there are also no
other precautions against subsections being used on ELF with .bss. It
also doesn't look to be a good idea to override the custom handler that
ELF has (afaict doing so further broke .previous).

9 months agom32c: drop .bss override
Jan Beulich [Fri, 5 Jan 2024 07:06:35 +0000 (08:06 +0100)]
m32c: drop .bss override

It doesn't look to be a good idea to override the custom handler that
ELF has; afaict doing so broke .previous.

9 months agoIA64: drop .bss override
Jan Beulich [Fri, 5 Jan 2024 07:06:08 +0000 (08:06 +0100)]
IA64: drop .bss override

It doesn't look to be a good idea to override the custom handlers that
ELF and COFF have. While in this case interaction with ELF's .previous
wasn't screwed, the sub-section specifier wasn't permitted.

9 months agod30v: fix .text/.data interaction with .previous
Jan Beulich [Fri, 5 Jan 2024 07:05:33 +0000 (08:05 +0100)]
d30v: fix .text/.data interaction with .previous

Just like obj_elf_section() is called for .section, obj_elf_{text,data}()
need calling for .text/.data.

9 months agobfin: drop .bss override
Jan Beulich [Fri, 5 Jan 2024 07:05:10 +0000 (08:05 +0100)]
bfin: drop .bss override

It doesn't look to be a good idea to override the custom handler that
ELF has; afaict doing so broke .previous.

9 months agoArm64: drop .bss override
Jan Beulich [Fri, 5 Jan 2024 07:04:42 +0000 (08:04 +0100)]
Arm64: drop .bss override

The comment looks bogus (perhaps simply stale, perhaps wrongly copied
from Arm in the first place), and there are also no other precautions
against subsections being used on ELF with .bss. It also doesn't look
to be a good idea to override the custom handlers that ELF and COFF
have (afaict doing so further broke .previous on ELF).

As to the mapping state update - such also doesn't appear to be done
for other section switching, so its original purpose was at best
questionable as well.

9 months agoArm: drop .bss override
Jan Beulich [Fri, 5 Jan 2024 07:04:18 +0000 (08:04 +0100)]
Arm: drop .bss override

The comment looks bogus (perhaps simply stale), and there are also no
other precautions against subsections being used on ELF with .bss. It
also doesn't look to be a good idea to override the custom handlers that
ELF and COFF have (afaict doing so further broke .previous on ELF).

9 months agoEnforce C++11 as a minimum for building gold [PR30867]
Tamar Christina [Thu, 4 Jan 2024 15:20:14 +0000 (15:20 +0000)]
Enforce C++11 as a minimum for building gold [PR30867]

The attempt in 5e9091dab885 to correct gold for modern LLVM has broken
gold for older compilers.  This commit introduced C++11 types without
changing the build system to require a C++ compiler.  More importantly
it depends on the compiler having at least C++11 as the default
language.  Older compilers which support C++11 but not as the default
language needlessly break.  Fix that.

PR gold/30867
* configure.ac (AX_CXX_COMPILE_STDCXX): Require C++11.
* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* config.in: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

9 months agoloongarch: 'index' shadows global
Alan Modra [Wed, 3 Jan 2024 05:33:48 +0000 (16:03 +1030)]
loongarch: 'index' shadows global

Avoid an error when compiling with older versions of gcc.

* elfnn-loongarch.c (loongarch_relax_align): Rename "index" to
"sym_index".

9 months agoTidy bfd_scan_vma
Alan Modra [Sun, 31 Dec 2023 09:09:18 +0000 (19:39 +1030)]
Tidy bfd_scan_vma

In commit 83c79df86bf4 I removed configure tests for strtoull among
other library functions part of C99, but didn't remove what is now
dead code.

* bfd.c (bfd_scan_vma): Delete fall-back for strtoull.

9 months agoPR31120, ld-scripts/fill2 fails when bfd_vma is 32 bits
Alan Modra [Sun, 31 Dec 2023 03:39:10 +0000 (14:09 +1030)]
PR31120, ld-scripts/fill2 fails when bfd_vma is 32 bits

The ld lexer converts strings to integers without overflow checking,
so I don't think there is any problem in truncating an integer that
exceeds the size of a bfd_vma rather than using (bfd_vma) -1.

PR 31120
* ldlex.l: Don't use bfd_scan_vma for integer conversion, use
strtoull.

9 months agoRISC-V: T-HEAD: Fix wrong instruction encoding for th.vsetvli
Jin Ma [Thu, 4 Jan 2024 02:17:40 +0000 (10:17 +0800)]
RISC-V: T-HEAD: Fix wrong instruction encoding for th.vsetvli

Since the particularity of "th.vsetvli" was not taken into account in the
initial support patches for XTheadVector, the program operation failed
due to instruction coding errors. According to T-Head SPEC ([1]), the
"vsetvl" in the XTheadVector extension consists of SEW, LMUL and EDIV,
which is quite different from the "V" extension. Therefore, we cannot
simply reuse the processing of vsetvl in V extension.

We have set up tens of thousands of test cases to ensure that no
further encoding issues are there, and and execute all compiled test
files on real HW and make sure they don't trigger SIGILL.

Ref:
[1] https://github.com/T-head-Semi/thead-extension-spec/releases/download/2.3.0/xthead-2023-11-10-2.3.0.pdf

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
gas/ChangeLog:

* config/tc-riscv.c (validate_riscv_insn): Add handling for
th.vsetvli.
(my_getThVsetvliExpression): New function.
(riscv_ip): Likewise.
* testsuite/gas/riscv/x-thead-vector.d: Likewise.
* testsuite/gas/riscv/x-thead-vector.s: Likewise.

include/ChangeLog:

* opcode/riscv.h (OP_MASK_XTHEADVLMUL): New macro.
(OP_SH_XTHEADVLMUL): Likewise.
(OP_MASK_XTHEADVSEW): Likewise.
(OP_SH_XTHEADVSEW): Likewise.
(OP_MASK_XTHEADVEDIV): Likewise.
(OP_SH_XTHEADVEDIV): Likewise.
(OP_MASK_XTHEADVTYPE_RES): Likewise.
(OP_SH_XTHEADVTYPE_RES): Likewise.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_args): Likewise.
* riscv-opc.c: Likewise.

9 months agoAutomatic date update in version.in
GDB Administrator [Fri, 5 Jan 2024 00:02:14 +0000 (00:02 +0000)]
Automatic date update in version.in

9 months ago[gdb/testsuite] Handle PAC marker
Tom de Vries [Thu, 4 Jan 2024 12:42:45 +0000 (13:42 +0100)]
[gdb/testsuite] Handle PAC marker

On aarch64-linux, I run into:
...
FAIL: gdb.base/annota1.exp: backtrace from shlibrary (timeout)
...
due to the PAC marker showing up:
...
^Z^Zframe-address^M
0x000000000041025c [PAC]^M
^Z^Zframe-address-end^M
...

In the docs the marker is documented as follows:
...
When GDB is debugging the AArch64 architecture, and the program is using the
v8.3-A feature Pointer Authentication (PAC), then whenever the link register
$lr is pointing to an PAC function its value will be masked.  When GDB prints
a backtrace, any addresses that required unmasking will be postfixed with the
marker [PAC].  When using the MI, this is printed as part of the addr_flags
field.
...

Update the test-case to allow the PAC marker.

Likewise in a few other test-cases.

While we're at it, rewrite the affected pattern pat_begin in annota1.exp into
a more readable form.  Likewise for the corresponding pat_end.

Tested on aarch64-linux.

Approved-By: Luis Machado <luis.machado@arm.com>
PR testsuite/31202
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31202

9 months agoUpdate year range in copyright notice of binutils files
Alan Modra [Thu, 4 Jan 2024 11:52:08 +0000 (22:22 +1030)]
Update year range in copyright notice of binutils files

Adds two new external authors to etc/update-copyright.py to cover
bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then
updates copyright messages as follows:

1) Update cgen/utils.scm emitted copyrights.
2) Run "etc/update-copyright.py --this-year" with an extra external
   author I haven't committed, 'Kalray SA.', to cover gas testsuite
   files (which should have their copyright message removed).
3) Build with --enable-maintainer-mode --enable-cgen-maint=yes.
4) Check out */po/*.pot which we don't update frequently.