Commit Graph

119098 Commits

Author SHA1 Message Date
Tom de Vries
b49c3a37b1 [gdb/symtab] Fix target type of complex long double on arm
When running test-case gdb.base/complex-parts.exp on arm-linux, I get:
...
(gdb) p $_cimag (z3)^M
$6 = 6.5^M
(gdb) PASS: gdb.base/complex-parts.exp: long double imaginary: p $_cimag (z3)
ptype $^M
type = double^M
(gdb) FAIL: gdb.base/complex-parts.exp: long double imaginary: ptype $
...

Given that z3 is a complex long double, the test-case expects the type of the
imaginary part of z3 to be long double, but it's double instead.

This is due to the fact that the dwarf info doesn't specify an explicit target
type:
...
    <5b>   DW_AT_name        : z3
    <60>   DW_AT_type        : <0xa4>
  ...
 <1><a4>: Abbrev Number: 2 (DW_TAG_base_type)
    <a5>   DW_AT_byte_size   : 16
    <a6>   DW_AT_encoding    : 3        (complex float)
    <a7>   DW_AT_name        : complex long double
...
and consequently we're guessing in dwarf2_init_complex_target_type based on
the size:
...
	case 64:
	  tt = builtin_type (gdbarch)->builtin_double;
	  break;
	case 96: /* The x86-32 ABI specifies 96-bit long double.  */
	case 128:
	  tt = builtin_type (gdbarch)->builtin_long_double;
	  break;
...

For arm-linux, complex long double is 16 bytes, so the target type is assumed
to be 8 bytes, which is handled by the "case 64", which gets us double
instead of long double.

Fix this by searching for "long" in the name_hint parameter, and using long
double instead.

Note that base types in dwarf are not allowed to contain references to other
types, and the complex types are base types, so the missing explicit target
type is standard-conformant.

A gcc PR was filed to add this as a dwarf extension (
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115272 ).

Tested on arm-linux.
2024-06-19 17:32:55 +02:00
Nick Alcock
b84ffc176d
libctf: fix testsuite bugs revealed by -Wall
Most of these are harmless, but some of the type confusions and especially
a missing ctf_strerror() on an error path were actual bugs that could
have resulted in test failures crashing rather than printing an error
message.

libctf/
	* testsuite/libctf-lookup/enumerator-iteration.c: Fix type
        confusion, signedness confusion and a missing ctf_errmsg().
	* testsuite/libctf-regression/libctf-repeat-cu-main.c: Return 0 from
        the test function.
	* testsuite/libctf-regression/open-error-free.c: Fix signedness
        confusion.
	* testsuite/libctf-regression/zrewrite.c: Remove unused label.
2024-06-19 15:51:24 +01:00
Lancelot SIX
ea4e03c0a9 gdb/python/python-internal.h: avoid uninitialized constexpr
The following recent change introduced a regression when building using
clang++:

    commit 764af87825
    Date:   Wed Jun 12 18:58:49 2024 +0200

        [gdb/python] Add typesafe wrapper around PyObject_CallMethod

The error message is:

    ../../gdb/python/python-internal.h:151:16: error: default initialization of an object of const type 'const char'
    constexpr char gdbpy_method_format;
                   ^
                                       = '\0'
      CXX    python/py-block.o
    1 error generated.
    make[2]: *** [Makefile:1959: python/py-arch.o] Error 1
    make[2]: *** Waiting for unfinished jobs....
    In file included from ../../gdb/python/py-auto-load.c:25:
    ../../gdb/python/python-internal.h:151:16: error: default initialization of an object of const type 'const char'
    constexpr char gdbpy_method_format;
                   ^
                                       = '\0'
    1 error generated.
    make[2]: *** [Makefile:1959: python/py-auto-load.o] Error 1
    In file included from ../../gdb/python/py-block.c:23:
    ../../gdb/python/python-internal.h:151:16: error: default initialization of an object of const type 'const char'
    constexpr char gdbpy_method_format;
                   ^
                                       = '\0'
    1 error generated.

This patch fixes this by changing gdbpy_method_format to be a templated
struct, and only have its specializations define the static constexpr
member "format".  This way, we avoid having an uninitialized constexpr
expression, regardless of it being instantiated or not.

Reviewed-By: Tom de Vries <tdevries@suse.de>
Change-Id: I5bec241144f13500ef78daea30f00d01e373692d
2024-06-19 15:09:04 +01:00
Cui, Lili
5445d7819b x86: Remove the secondary encoding for ctest.
There are two encodings for each opcode F6/F7 in ctest, but the second one
is never used, so remove it to reduce the size of opcode_tbl.h.

opcodes/ChangeLog:

        * i386-opc.tbl: Removed the secondary insn template for ctest.
        * i386-tbl.h: Regenerated.
2024-06-19 16:23:26 +08:00
Tom de Vries
81ad8a2444 [gdb/testsuite] Fix gdb.dwarf2/shortpiece.exp on s390x
On s390x-linux, I run into:
...
(gdb) p (short []) s1^M
$3 = {0, 1, 0, <optimized out>}^M
(gdb) FAIL: gdb.dwarf2/shortpiece.exp: p (short []) s1
...
while this is expected:
...
(gdb) p (short []) s1^M
$3 = {1, 0, 0, <optimized out>}^M
(gdb) PASS: gdb.dwarf2/shortpiece.exp: p (short []) s1
...

The type of s1 is:
...
(gdb) ptype s1
type = struct S {
    myint a;
    myushort b;
}
...
so the difference is due the fact that viewing an int as two shorts gives
different results depending on the endianness.

Fix this by allowing both results.

Tested on x86_64-linux and s390x-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-06-19 10:04:22 +02:00
Tom de Vries
78564d3f6c [gdb/testsuite] Add string cat for tcl version < 8.6.2
I noticed that we started using "string cat", which has been available since
tcl version 8.6.2.

Add a local implementation for use with older tcl versions.

Tested on x86_64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-06-19 09:56:44 +02:00
Tom de Vries
be23e44263 [gdb/tdep] Simplify ARM_LINUX_JB_PC_EABI
In commit 1a7d840a21 ("[gdb/tdep] Fix ARM_LINUX_JB_PC_EABI"), in absense of
osabi settings for newlib and uclibc for arm, I chose a best-effort approach
using ifdefs.

Post-commit review [1] pointed out that this may be causing more problems than
it's worth.

Fix this by removing the ifdefs and simply defining ARM_LINUX_JB_PC_EABI to 1.

Rebuild on x86_64-linux with --enable-targets=all.

Fixes: 1a7d840a21 ("[gdb/tdep] Fix ARM_LINUX_JB_PC_EABI")

[1] https://sourceware.org/pipermail/gdb-patches/2024-June/209779.html
2024-06-19 09:52:01 +02:00
GDB Administrator
9c39329d1c Automatic date update in version.in 2024-06-19 00:00:24 +00:00
Tom de Vries
3465822f14 [gdb/build] Add GPL header comment to gdb/features/feature_to_c.awk
Commit 97033da507 ("[gdb/build] Cleanup gdb/features/feature_to_c.sh")
factored out new file gdb/features/feature_to_c.awk out of
gdb/features/feature_to_c.sh, but failed to add the GPL header comment, so add
this now.

Tested on x86_64-linux.
2024-06-18 17:26:22 +02:00
Nick Alcock
2fa4b6e6df
libctf, include: new functions for looking up enumerators
Three new functions for looking up the enum type containing a given
enumeration constant, and optionally that constant's value.

The simplest, ctf_lookup_enumerator, looks up a root-visible enumerator by
name in one dict: if the dict contains multiple such constants (which is
possible for dicts created by older versions of the libctf deduplicator),
ECTF_DUPLICATE is returned.

The next simplest, ctf_lookup_enumerator_next, is an iterator which returns
all enumerators with a given name in a given dict, whether root-visible or
not.

The most elaborate, ctf_arc_lookup_enumerator_next, finds all
enumerators with a given name across all dicts in an entire CTF archive,
whether root-visible or not, starting looking in the shared parent dict;
opened dicts are cached (as with all other ctf_arc_*lookup functions) so
that repeated use does not incur repeated opening costs.

All three of these return enumerator values as int64_t: unfortunately, API
compatibility concerns prevent us from doing the same with the other older
enum-related functions, which all return enumerator constant values as ints.
We may be forced to add symbol-versioning compatibility aliases that fix the
other functions in due course, bumping the soname for platforms that do not
support such things.

ctf_arc_lookup_enumerator_next is implemented as a nested ctf_archive_next
iterator, and inside that, a nested ctf_lookup_enumerator_next iterator
within each dict.  To aid in this, add support to ctf_next_t iterators for
iterators that are implemented in terms of two simultaneous nested iterators
at once.  (It has always been possible for callers to use as many nested or
semi-overlapping ctf_next_t iterators as they need, which is one of the
advantages of this style over the _iter style that calls a function for each
thing iterated over: the iterator change here permits *ctf_next_t iterators
themselves* to be implemented by iterating using multiple other iterators as
part of their internal operation, transparently to the caller.)

Also add a testcase that tests all these functions (which is fairly easy
because ctf_arc_lookup_enumerator_next is implemented in terms of
ctf_lookup_enumerator_next) in addition to enumeration addition in
ctf_open()ed dicts, ctf_add_enumerator duplicate enumerator addition, and
conflicting enumerator constant deduplication.

include/
	* ctf-api.h (ctf_lookup_enumerator): New.
	(ctf_lookup_enumerator_next): Likewise.
	(ctf_arc_lookup_enumerator_next): Likewise.

libctf/
	* libctf.ver: Add them.
	* ctf-impl.h (ctf_next_t) <ctn_next_inner>: New.
	* ctf-util.c (ctf_next_copy): Copy it.
        (ctf_next_destroy): Destroy it.
	* ctf-lookup.c (ctf_lookup_enumerator): New.
	(ctf_lookup_enumerator_next): New.
	* ctf-archive.c (ctf_arc_lookup_enumerator_next): New.
	* testsuite/libctf-lookup/enumerator-iteration.*: New test.
	* testsuite/libctf-lookup/enum-ctf-2.c: New test CTF, used by the
	  above.
2024-06-18 13:20:32 +01:00
Nick Alcock
1f62f2a9b5
include: libctf: comment improvements
Describe a bit more clearly what effects a type being non-root-
visible has.  More consistently use the term non-root-visible
rather than hidden.  Document ctf_enum_iter.

include/
	* ctf-api.h (ctf_enum_iter): Document.
        (ctf_type_iter): Hidden, not non-root.  Mention that
        parent dictionaries are not traversed.
2024-06-18 13:20:32 +01:00
Nick Alcock
4bbc4b1f5c
libctf: make the ctf_next ctn_fp non-const
This was always an error, because the ctn_fp routinely has errors set on it,
which is not something you can (or should) do to a const object.

libctf/
	* ctf-impl.h (ctf_next_) <cu.ctn_fp>: Make non-const.
2024-06-18 13:20:32 +01:00
Nick Alcock
6e09d4a6e6
libctf: prohibit addition of enums with overlapping enumerator constants
libctf has long prohibited addition of enums with overlapping constants in a
single enum, but now that we are properly considering enums with overlapping
constants to be conflciting types, we can go further and prohibit addition
of enumeration constants to a dict if they already exist in any enum in that
dict: the same rules as C itself.

We do this in a fashion vaguely similar to what we just did in the
deduplicator, by considering enumeration constants as identifiers and adding
them to the core type/identifier namespace, ctf_dict_t.ctf_names.  This is a
little fiddly, because we do not want to prohibit opening of existing dicts
into which the deduplicator has stuffed enums with overlapping constants!
We just want to prohibit the addition of *new* enumerators that violate that
rule.  Even then, it's fine to add overlapping enumerator constants as long
as at least one of them is in a non-root type.  (This is essential for
proper deduplicator operation in cu-mapped mode, where multiple compilation
units can be smashed into one dict, with conflicting types marked as
hidden: these types may well contain overlapping enumerators.)

So, at open time, keep track of all enums observed, then do a third pass
through the enums alone, adding each enumerator either to the ctf_names
table as a mapping from the enumerator name to the enum it is part of (if
not already present), or to a new ctf_conflicting_enums hashtable that
tracks observed duplicates. (The latter is not used yet, but will be soon.)

(We need to do a third pass because it's quite possible to have an enum
containing an enumerator FOO followed by a type FOO: since they're processed
in order, the enumerator would be processed before the type, and at that
stage it seems nonconflicting.  The easiest fix is to run through the
enumerators after all type names are interned.)

At ctf_add_enumerator time, if the enumerator to which we are adding a type
is root-visible, check for an already-present name and error out if found,
then intern the new name in the ctf_names table as is done at open time.

(We retain the existing code which scans the enum itself for duplicates
because it is still an error to add an enumerator twice to a
non-root-visible enum type; but we only need to do this if the enum is
non-root-visible, so the cost of enum addition is reduced.)

Tested in an upcoming commit.

libctf/
	* ctf-impl.h (ctf_dict_t) <ctf_names>: Augment comment.
        <ctf_conflicting_enums>: New.
	(ctf_dynset_elements): New.
	* ctf-hash.c (ctf_dynset_elements): Implement it.
	* ctf-open.c (init_static_types): Split body into...
        (init_static_types_internal): ... here.  Count enumerators;
        keep track of observed enums in pass 2; populate ctf_names and
        ctf_conflicting_enums with enumerators in a third pass.
	(ctf_dict_close): Free ctf_conflicting_enums.
	* ctf-create.c (ctf_add_enumerator): Prohibit addition of duplicate
        enumerators in root-visible enum types.

include/
	* ctf-api.h (CTF_ADD_NONROOT): Describe what non-rootness
        means for enumeration constants.
	(ctf_add_enumerator):  The name is not a misnomer.
        We now require that enumerators have unique names.
        Document the non-rootness of enumerators.
2024-06-18 13:20:32 +01:00
Nick Alcock
9f0fb75b8e
libctf: suppress spurious failure of malloc-counting tests under valgrind
The libctf-regression/open-error-free.c test works by interposing malloc
and counting mallocs and frees across libctf operations.  This only
works under suitably-interposable mallocs on systems supporting
dlsym (RTLD_NEXT, ...), so its operation is restricted to glibc
systems for now, but also it interacts badly with valgrind, which
interposes malloc itself.  Detect a running valgrind and skip the test.

Add new facilities allowing libctf lookup tests to declare themselves
unsupported, by printing "UNSUPPORTED: " and then some meaningful
message instead of their normal output.

libctf/
	* configure.ac: Check for <valgrind/valgrind.h>.
	* config.h.in: Regenerate.
	* configure: Likewise.
	* testsuite/lib/ctf-lib.exp (run_lookup_test): Add support for
	UNSUPPORTED tests.
	* testsuite/libctf-regression/open-error-free.c: When running
	under valgrind, this test is unsupported.
2024-06-18 13:20:32 +01:00
Nick Alcock
e3cd566075
libctf: fix dict leak on archive-wide symbol lookup error path
If a lookup fails for a reason unrelated to a lack of type data for this
symbol, we return with an error; but we fail to close the dict we opened
most recently, which is leaked.

libctf/
	* ctf-archive.c (ctf_arc_lookup_sym_or_name): Close dict.
2024-06-18 13:20:32 +01:00
Nick Alcock
327356780a
libctf: don't leak enums if ctf_add_type fails
If ctf_add_type failed in the middle of enumerator addition, the
destination would end up containing the source enum type and some
but not all of its enumerator constants.

Use snapshots to roll back the enum addition as a whole if this happens.
Before now, it's been pretty unlikely, but in an upcoming commit we will ban
addition of enumerators that already exist in a given dict, making failure
of ctf_add_enumerator and thus of this part of ctf_add_type much more
likely.

libctf/
	* ctf-create.c (ctf_add_type_internal): Roll back if enum or
          enumerator addition fails.
2024-06-18 13:20:31 +01:00
Nick Alcock
f8da1a05db
libctf: dedup: enums with overlapping enumerators are conflicting
The CTF deduplicator was not considering enumerators inside enum types to be
things that caused type conflicts, so if the following two TUs were linked
together, you would end up with the following in the resulting dict:

1.c:
enum foo { A, B };

2.c:
enum bar { A, B };

linked:

enum foo { A, B };
enum bar { A, B };

This does work -- but it's not something that's valid C, and the general
point of the shared dict is that it is something that you could potentially
get from any valid C TU.

So consider such types to be conflicting, but obviously don't consider
actually identical enums to be conflicting, even though they too have (all)
their identifiers in common.  This involves surprisingly little code. The
deduplicator detects conflicting types by counting types in a hash table of
hash tables:

decorated identifier -> (type hash -> count)

where the COUNT is the number of times a given hash has been observed: any
name with more than one hash associated with it is considered conflicting
(the count is used to identify the most common such name for promotion to
the shared dict).

Before now, those identifiers were all the identifiers of types (possibly
decorated with their namespace on the front for enumerator identifiers), but
we can equally well put *enumeration constant names* in there, undecorated
like the identifiers of types in the global namespace, with the type hash
being the hash of each enum containing that enumerator.  The existing
conflicting-type-detection code will then accurately identify distinct enums
with enumeration constants in common.  The enum that contains the most
commonly-appearing enumerators will be promoted to the shared dict.

libctf/
	* ctf-impl.h (ctf_dedup_t) <cd_name_counts>: Extend comment.
	* ctf-dedup.c (ctf_dedup_count_name): New, split out of...
	(ctf_dedup_populate_mappings): ... here.  Call it for all
	* enumeration constants in an enum as well as types.

ld/
	* testsuite/ld-ctf/enum-3.c: New test CTF.
	* testsuite/ld-ctf/enum-4.c: Likewise.
	* testsuite/ld-ctf/overlapping-enums.d: New test.
	* testsuite/ld-ctf/overlapping-enums-2.d: Likewise.
2024-06-18 13:20:31 +01:00
Nick Alcock
0c5f03a9d5
libctf: doc: fix ctf_stype_t typedef string in spec 2024-06-18 13:20:31 +01:00
Nick Alcock
f7b02dc3e1
include: fix libctf ECTF_NOENUMNAM error message
ECTF_NOENUMNAM is emitted when enumerator constant names don't exist.
Call them that, not 'enum elements'.

include/
	* ctf-api.h (ECTF_NOENUMNAM): fix error message.
2024-06-18 13:20:31 +01:00
Nick Alcock
1cdcc97732
libctf: strtab corruption when strings are added to ctf_open()ed dicts
ctf_str_add_ref and ctf_str_add_movable_ref take a string and are supposed
to return a strtab offset.  These offsets are "provisional": the ref
mechanism records the address of the location in which the ref is stored and
modifies it when the strtab is finally written out.  Provisional refs in new
dicts start at 0 and go up via strlen() as new refs are added: this is fine,
because the strtab is empty and none of these values will overlap any
existing string offsets (since there are none).  Unfortunately, when a dict
is ctf_open()ed, we fail to set the initial provisional strtab offset to a
higher value than any existing string offset: it starts at zero again!
It's a shame that we already *have* strings at those offsets...

This is all fixed up once the string is reserialized, but if you look up
newly-added strings before serialization, you get corrupted partial string
results from the existing ctf_open()ed dict.

Observed (and thus regtested) by an upcoming test (in this patch series).

Exposed by the recently-introduced series that permits modification of
ctf_open()ed dicts, which has not been released anywhere.  Before that,
any attempt to do such things would fail with ECTF_RDONLY.

libctf/
	* ctf-string.c (ctf_str_create_atoms): Initialize
        ctf_str_prov_offset.
2024-06-18 13:20:31 +01:00
Jan Beulich
28c812b349 readelf: rename recently added testsuite files
Files named *.0 are somewhat odd for testsuite expectations. Rename the
one such file to *.r with a suitable base name suffix, and have its
sibling follow suit in this latter regard.
2024-06-18 13:23:36 +02:00
Nelson Chu
c2db2b8a37 RISC-V: Fixed typo from smscrind to smcsrind in riscv_implicit_subsets.
bfd/
	* elfxx-riscv.c (riscv_implicit_subsets): Fixed type from smscrind to
	smcsrind.
gas/
	* testsuite/gas/riscv/march-imply-smcsrind.d: New testcase.  It fails
	without applying this patch.
2024-06-18 16:22:30 +08:00
Nick Clifton
7b74583e2c Ensure that the text segment is aligned on disk when using --rosegment. 2024-06-18 09:15:04 +01:00
Felix Willgerodt
c7e4521c97 gdb: rename offset to high bits in ymm registers
The xsave_ymm_avx512_offset data structure contains the xsave
offset to the upper 128 bits of a ymm register.  Similarly, for zmm this
offset is described by xsave_avx512_zmm_h_offset, h indicating the
high bits.  This commit renames the xsave_ymm_avx512_offset to
xsave_ymm_h_avx512_offset - as well as the associated define from
XSAVE_YMM_AVX512_ADDR to XSAVE_YMM_H_AVX512_ADDR - to make this
more consistent.

Note, that the regnum defines already included the 'h' for ymm, like
I387_YMM16H_REGNUM and I387_YMMH_AVX512_END_REGNUM.

Co-authored-by:  Nils-Christian Kempke  <nils-christian.kempke@intel.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-06-18 09:26:56 +02:00
Nelson Chu
7aabe8edca RISC-V: Updated gas/NEWS and gas/doc/c-riscv.texi for vendor extensions.
gas/
	* NEWS: Updated for XCvMem, XCvBi, XCvElw, XSfCease.
	* doc/c-riscv.texi: Minor typo for XCv* extensions.
2024-06-18 15:15:14 +08:00
Hau Hsu
7003edc383 RISC-V: Add SiFive cease extension v1.0
Add SiFive cease extension,
https://sifive.cdn.prismic.io/sifive/767804da-53b2-4893-97d5-b7c030ae0a94_s76mc_core_complex_manual_21G3.pdf

This aligns LLVM:
* https://llvm.org/docs/RISCVUsage.html
* https://github.com/llvm/llvm-project/pull/83896

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_supported_vendor_x_ext): Add support for
	'xsfcease'.
	(riscv_multi_subset_supports): Handle INSN_CLASS_XSFCEASE.
	(riscv_multi_subset_supports_ext): Handle INSN_CLASS_XSFCEASE.

gas/ChangeLog:

	* doc/c-riscv.texi: Updated.
	* testsuite/gas/riscv/march-help.l: Updated.
	* testsuite/gas/riscv/sifive-insns.d: Add test case for 'sf.cease'.
	* testsuite/gas/riscv/sifive-insns.s: Likewise.

include/ChangeLog:

	* opcode/riscv-opc.h (MATCH_SF_CEASE, MASK_SF_CEASE): Define match and
	mask encoding for 'sf.cease'.
	* opcode/riscv.h (INSN_CLASS_XSFCEASE): Add new instruction class for
	'xsfcease'.

opcodes/ChangeLog:

    * riscv-opc.c (riscv_opcodes): Add opcode entry for 'sf.cease'.
2024-06-18 15:06:34 +08:00
Gianluca Guida
88729e9616 RISC-V: Support Zacas extension.
https://github.com/riscvarchive/riscv-zacas/releases/tag/v1.0

The Zacas extension introduce compare-and-swap instructions to operate
on 32-bit, 64-bit and 128-bit (RV64 only) data values.

It introduces three new instructions:
  - amocas.w (32-bit CAS)
  - amocas.d (64-bit CAS)
  - amocas.q (128-bit CAS, RV64 only)

Like other AMOs in the A extension, Zacas instructions have '.aq',
'.rl' and '.aqrl' variations.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_implicit_subsets): 'A' implied by 'Zacas'.
	(riscv_supported_std_z_ext): Add 'Zacas' extension.
	(riscv_multi_subset_supports, riscv_multi_subset_supports_ext):
	Handle INSN_CLASS_ZACAS case.

gas/ChangeLog:

	* NEWS: Updated.
	* testsuite/gas/riscv/march-help.l: Updated.
	* testsuite/gas/riscv/zacas-32.d: New test (RV32).
        * testsuite/gas/riscv/zacas-fail-32.d: Likewise.
	* testsuite/gas/riscv/zacas-64.d: New test (RV64).
        * testsuite/gas/riscv/zacas-fail-64.d: Likewise.
	* testsuite/gas/riscv/zacas.s: New test source.
	* testsuite/gas/riscv/zacas-fail.s: Likewise.
	* testsuite/gas/riscv/zacas-fail-32.l: New file.
	* testsuite/gas/riscv/zacas-fail-64.l: Likewise.

include/ChangeLog:

	* include/opcode/riscv.h (INSN_CLASS_ZACAS): New definition.
	* include/opcode/riscv-opc.h (MATCH_AMOCAS_W, MASK_AMOCAS_W)
	(MATCH_AMOCAS_D, MASK_AMOCAS_D, MATCH_AMOCAS_Q, MASK_AMOCAS_Q):
	Likewise.
	(amocas_w, amocas_d, amocas_q): Declare instructions.

opcodes/ChangeLog:

	* riscv-opc.c (match_rs2_rd_even): New function.
	(amocas_w, amocas_d, amocas_q, amocas_w.aq)
	(amocas_d.aq, amocas_q.aq, amocas_w.rl, amocas_d.rl, amocas_q.rl)
	(amocas_w.aqrl, amocas_d.aqrl, amocas_q.aqrl): Add instructions.
2024-06-18 14:35:50 +08:00
Cui, Lili
0915235d34 x86: Fix typo in i386-dis-evex-mod.h
opcodes/ChangeLog:

        * i386-dis-evex-mod.h: Used MOD_EVEX_MAP4_F8_P_1/MOD_EVEX_MAP4_F8_P_3
        instead of MOD_EVEX_MAP4_F8_P1/MOD_EVEX_MAP4_F8_P3.
2024-06-18 10:52:41 +08:00
Cui, Lili
f7b1fe8dc4 Remove %ME and used %NE for movbe.
%ME is added specifically for movbe. Now with %NE, we can use
MOD table + %NE to indicate whether a {evex} prefix is needed.

opcodes/ChangeLog:

        * i386-dis-evex-mod.h: Added movbe.
        * i386-dis-evex.h: Let movbe go through the mod table.
        * i386-dis.c (struct dis386): Removed %ME.
        (putop): Removed case ME.
2024-06-18 10:52:41 +08:00
Cui, Lili
d8ba1c4037 Support APX CCMP and CTEST
CCMP and CTEST are two new sets of instructions for conditional CMP
and TEST, SCC and OSZC flags are given as suffixes of CCMP or CTEST
in the instruction mnemonic, e.g.:

ccmp<cc> { dfv=sf , cf , of } %eax, %ecx

also add

{evex} cmp/test %eax, %ecx

as an alias for ccmpt.

For the encoder part, add function check_Scc_OszcOperation to parse
'{ dfv=of , sf, sf, cf}', store scc in the lower 4 bits of base_opcode,
and adjust base_opcode to its normal meaning in install_template.

For the decoder part, add 'SC' and 'DF' macros to add scc and oszc flags
suffixes.

gas/ChangeLog:

        * config/tc-i386.c (OSZC_CF): New.
        (OSZC_ZF): Ditto.
        (OSZC_SF): Ditto.
        (OSZC_OF): Ditto.
        (set_oszc_flags): Set oszc flags and report error for using the same oszc flags twice.
        (check_Scc_OszcOperations): Handle SCC OSZC flags.
        (install_template): Add scc and oszc_flags.
        (build_apx_evex_prefix): Encode SCC and oszc flags bits.
        (parse_insn): Handle check_Scc_OszcOperations.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d: Add ivalid test case.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s: Ditto.
        * testsuite/gas/i386/x86-64.exp: Add test for ccmp and ctest.
        * testsuite/gas/i386/x86-64-apx-ccmp-ctest-intel.d: New test.
        * testsuite/gas/i386/x86-64-apx-ccmp-ctest-inval.l: Ditto.
        * testsuite/gas/i386/x86-64-apx-ccmp-ctest-inval.s: Ditto.
        * testsuite/gas/i386/x86-64-apx-ccmp-ctest.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-ccmp-ctest.s: Ditto.

opcodes/ChangeLog:

        * i386-dis-evex-reg.h: Add ccmp and ctest.
        * i386-dis-evex.h: Ditto.
        * i386-dis.c (struct instr_info): add scc.
        (struct dis386): Add new micro 'NE','SC' and'DF'.
        (get_valid_dis386): Get scc value and move MAP4 invalid check to print_insn.
        (putop): Handle %NE, %SC and %DF.
        * i386-opc.h (SCC): New.
        * i386-opc.tbl: Add ccmp/ctest and evex format for cmp/test.
        * i386-mnem.h: Regenerated.
        * i386-tbl.h: Ditto.
2024-06-18 10:52:40 +08:00
Lulu Cai
8864c4afdf LoongArch: add .option directive
In some cases we may want to use different options only for certain
assembly, so the .option directive is added to control the assembler
options.

.option can accept 4 parameters:

push
pop
  Pushes or pops the current option stack. They limit the scope of
  option changes so that they do not affect other parts of the assembly
  file.

relax
norelax
  Enables or disables relaxation.
2024-06-18 10:40:23 +08:00
GDB Administrator
6a4f078b5b Automatic date update in version.in 2024-06-18 00:00:13 +00:00
Maciej W. Rozycki
7c900791f2 GAS/testsuite: Make a copy of none.s before operating on it as output
The "Output file must be distinct from input" test in gas/all/gas.exp
operates on none.s as output.  Should the test fail it may happen that
GAS will delete the output file requested in which case none.s will be
removed.  Since the test operates directly on the source tree it will be
clobbered as a result.  It has actually been observed in the field in
the form of intermittent:

FAIL: gas/all/none

regressions in a parallel run of many configurations.

Prevent this from happening by copying none.s first to the test object
directory and operating on it instead.  It does not prevent the file
from being removed should the test fail, but the source tree won't be
clobbered in that case.

A nice side effect is that syntactically different paths will now be
used in this test for the input and the output file each, so coverage
will extend to verifying that a file is checked against itself even if
referred to via different paths.  Previously "$srcdir/$subdir/none.s"
was used for both paths and now "tmpdir/none.s" is referred to directly
and via a relative path from "$srcdir/$subdir" respectively.

I note that we have no previous use of the UNRESOLVED test result in the
GAS testsuite, but it seems the correct one should copying none.s fail,
as this is an unexpected situation that requires a human intervention
and the test proper has not been evaluated.
2024-06-17 23:28:20 +01:00
Maciej W. Rozycki
4c817355a0 GAS/testsuite: Add a helper for paths outside the source dir
Implement a helper to construct a relative path from $srcdir/$subdir,
where `gas_run' operates, to an arbitrary place in the filesystem, for
example a file in the test object directory.
2024-06-17 23:28:20 +01:00
Maciej W. Rozycki
38362a0c63 binutils/testsuite: Add a helper for relative path construction
Implement a helper to construct a relative path between two locations in
the filesystem, for example to make a path from the source to the object
directory for the case where a tool has been set up to look at a given
path and there is a need to point it elsewhere, but an absolute path
will not work.  The helper works on normalized paths internally, so the
result is correct even in the presence of symlinks as intermediate path
components.

So given "/path/to/src/gas/testsuite/gas/all" as the FROM argument and
then "/path/to/obj/gas/testsuite/tmpdir/none.s" as the TO argument the
helper will return "../../../../../obj/gas/testsuite/tmpdir/none.s" in
the absence of symlinks.
2024-06-17 23:28:20 +01:00
Tom de Vries
a6760bd40b [gdb/testsuite] Fix duplicates in gdb.fortran/array-{indices,repeat}.exp
When running test-case gdb.fortran/array-indices.exp on a system without
fortran compiler, I run into a duplicate:
...
Running /home/vries/gdb/src/gdb/testsuite/gdb.fortran/array-indices.exp ...
gdb compile failed, default_target_compile: Can't find gfortran.
UNTESTED: gdb.fortran/array-indices.exp: array-indices.exp
gdb compile failed, default_target_compile: Can't find gfortran.
UNTESTED: gdb.fortran/array-indices.exp: array-indices.exp
DUPLICATE: gdb.fortran/array-indices.exp: array-indices.exp
...

Fix this by adding a with_test_prefix at the toplevel.

Likewise in gdb.fortran/array-repeat.exp.

Tested on x86_64-linux.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
2024-06-17 23:26:03 +02:00
Alan Modra
1b19566b18 PR31898 bug in processing DW_RLE_startx_endx
PR 31898
	* dwarf.c (display_debug_rnglists_list): Correct fetch of "end"
	indexed address.  Remove excess parens.
2024-06-17 15:57:50 +09:30
Alan Modra
2df6e96709 Error messages emitted during bfd_check_format_matches
Error/warning messages are only printed for the target that
successfully matched, which makes sense for warnings, but not so much
for errors where the errors cause no target to match.  I noticed this
when looking at the pr20520 testcase again with objdump, which just
reports "file format not recognized" omitting the five "SHT_GROUP
section [index n] has no SHF_GROUP sections" messages.  They are
omitted because multiple ELF targets match the object file.  This is
going to be true for all ELF objects due to at least the proper ELF
target and the generic ELF target matching.

	* format.c (print_and_clear_messages): Print messages if all
	targets with messages have exactly the same set of messages.
2024-06-17 15:57:50 +09:30
GDB Administrator
c3d23f753d Automatic date update in version.in 2024-06-17 00:00:33 +00:00
Tom Tromey
a6687ef35c Make tui_register_info::highlight private
This changes tui_register_info::highlight to be private, renaming it
to m_highlight.
2024-06-15 20:54:04 -06:00
GDB Administrator
28775f62b9 Automatic date update in version.in 2024-06-16 00:00:16 +00:00
Tom Tromey
855dc4f2ac Remove a call to fflush
This TUI code calls fflush on stdout, but I don't believe this is
useful in gdb.
2024-06-15 12:16:40 -06:00
Tom de Vries
97033da507 [gdb/build] Cleanup gdb/features/feature_to_c.sh
Clean up script gdb/features/feature_to_c.sh by:
- fixing shellcheck warnings,
- moving an embedded awk script out of the file, reducing the amount of
  escaping in the awk script, making it more readable and maintainable, and
- adding emacs / vi settings for local tab size 2 (copied from ./ltmain.sh).

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
2024-06-15 08:10:44 +02:00
Tom de Vries
750fc33e4e [gdb/testsuite] Clean up lib/dg-add-core-file-count.sh
Fix shellcheck warnings in script lib/dg-add-core-file-count.sh.

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
2024-06-15 08:10:44 +02:00
Tom de Vries
382cac8881 [gdb/testsuite] Clean up formatting in gdb/contrib/cc-with-tweaks.sh
In emacs, on gdb/contrib/cc-with-tweaks.sh, do:
- M-x whitespace-cleanup,
- M-x mark-whole-buffer and M-x indent-region, and
- and undo the unwanted changes in the header comment.

Only whitespace changes.

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
2024-06-15 08:10:44 +02:00
Tom de Vries
b790195962 [gdb/testsuite] Clean up gdb/contrib/cc-with-tweaks.sh
Fix shellcheck warnings in script gdb/contrib/cc-with-tweaks.sh.

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
2024-06-15 08:10:44 +02:00
Tom de Vries
486df2b7c8 [gdb/testsuite] Clean up gdb/contrib/expect-read1.sh
Clean up script gdb/contrib/expect-read1.sh by:
- fixing shellcheck warnings,
- using mktemp (which takes TMPDIR into account) instead of a hardcoded
  "/tmp/expect-read1.$$.so",
- adding comments, and
- adding emacs / vi settings for local tab size 2 (copied from ./ltmain.sh).

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
2024-06-15 08:10:44 +02:00
GDB Administrator
f2869f51b2 Automatic date update in version.in 2024-06-15 00:00:22 +00:00
H.J. Lu
93548ee191 x86: Add -z isa-level-report=[none|all|needed|used]
Add -z isa-level-report=[none|all|needed|used] to the x86 ELF linker to
report needed and used x86-64 ISA levels.

bfd/

	PR ld/31868
	* elf-linker-x86.h (elf_x86_isa_level_report): New.
	(elf_linker_x86_params): Add isa_level_report.
	* elfxx-x86.c (report_isa_level): New.
	(_bfd_x86_elf_link_setup_gnu_properties): Check
	-z isa-level-report=[none|all|needed|used] to report needed and
	used x86-64 ISA level.

ld/

	PR ld/31868
	* NEWS: Mention -z isa-level-report=[none|all|needed|used].
	* ld.texi: Document -z isa-level-report=[none|all|needed|used].
	* emulparams/elf32_x86_64.sh: Source x86-64-level-report.sh.
	* emulparams/elf_i386.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.
	* emulparams/x86-64-level-report.sh: New file.
	* testsuite/ld-i386/pr31868a.d: Likewise.
	* testsuite/ld-i386/pr31868b.d: Likewise.
	* testsuite/ld-i386/pr31868c.d: Likewise.
	* testsuite/ld-x86-64/pr31868a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr31868a.d: Likewise.
	* testsuite/ld-x86-64/pr31868a.l: Likewise.
	* testsuite/ld-x86-64/pr31868a.s: Likewise.
	* testsuite/ld-x86-64/pr31868b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr31868b.d: Likewise.
	* testsuite/ld-x86-64/pr31868b.l: Likewise.
	* testsuite/ld-x86-64/pr31868b.s: Likewise.
	* testsuite/ld-x86-64/pr31868c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr31868c.d: Likewise.
	* testsuite/ld-x86-64/pr31868c.l: Likewise.
	* testsuite/ld-i386/i386.exp: Run PR ld/31868 tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-06-14 13:38:19 -07:00
H.J. Lu
65e513dc95 ld: Align --no-error-execstack help output
* lexsup.c (elf_static_list_options): Align --no-error-execstack
	help output.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-06-14 13:29:04 -07:00