Commit Graph

119303 Commits

Author SHA1 Message Date
Nick Clifton
cff16e125a Change version to 2.43.50 2024-07-20 13:16:33 +01:00
Nick Clifton
b33c4f8f82 Add markers for 2.43 branch/release 2024-07-20 12:43:19 +01:00
Alan Modra
237c05a65f Re: binutils: Add a test for strip with build notes
The new test wasn't being run, and failed due to relocations against
.gnu.build.attributes being stripped by default strip behaviour.
We probably should be keeping these relocations, but I haven't made
that change here.
BTW, the new test fails on ia64-hpux but that's just a repeat of the
existing note-5 fail.

	PR 31999
	* testsuite/binutils-all/strip-16.d: strip with --strip-unneeded
	and --merge-notes.
	* testsuite/binutils-all/objcopy.exp: Run the new test.  Sort
	other strip tests.
2024-07-20 13:54:00 +09:30
H.J. Lu
3f55acd0ec binutils: Add a test for strip with build notes
Add a test for strip with build notes.

	PR binutils/31999
	* testsuite/binutils-all/strip-16.d: New.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-07-19 18:59:53 -07:00
Alan Modra
964be70df7 PR31999 strip [.gnu.build.attributes]: failed
PR 31999
	* objcopy.c (merge_gnu_build_notes): Always set *new_size.
2024-07-20 10:11:25 +09:30
GDB Administrator
f5036a1861 Automatic date update in version.in 2024-07-20 00:00:17 +00:00
Simon Marchi
c5c3b90970 gdb-gdb.py: strip typedefs in intrusive_list printer assertion
When debugging gdb itself and trying to print a intrusive_list that has
more than one element, I get:

    File "/home/simark/build/binutils-gdb-all-targets/gdb/gdb-gdb.py", line 365, in _children_generator
      node_ptr = self._as_node_ptr(elem_ptr)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/simark/build/binutils-gdb-all-targets/gdb/gdb-gdb.py", line 345, in _as_node_ptr
      assert elem_ptr.type.code == gdb.TYPE_CODE_PTR
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AssertionError

This is because node_ptr is a typedef
(intrusive_list_base_iterator::pointer).  Add a call to strip_typedefs
to get to the real type.

Enhance gdb.gdb/python-helper.exp with a test that would have caught
this bug.

Change-Id: I3eaca8de5ed06d05756ed979332b6a431e15b700
Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-07-19 16:30:52 -04:00
Maciej W. Rozycki
b39807cc93 MIPS/opcodes: Replace "y" microMIPS operand code with "x"
Replace the "y" microMIPS operand code, used with ALNV.PS only, with "x"
so as to make "y" available for microMIPS MT use.
2024-07-19 19:01:53 +01:00
Maciej W. Rozycki
0ffc724699 MIPS/opcodes: Mark MT thread context move assembly idioms as aliases
A number of instructions in the regular MIPS opcode table are assembly
idioms for the MT thread context move MFTR and MTTR instructions, so
mark them as aliases accordingly.  Add suitable test cases, which also
cover the PAUSE assembly idiom.
2024-07-19 19:01:53 +01:00
Maciej W. Rozycki
d8b73b41a2 MIPS/opcodes: Mark PAUSE as an alias
PAUSE is an assembly idiom for 'sll $0,$0,5', so mark it as an alias in
the regular MIPS opcode table, matching the microMIPS opcode table.  A
test case will be supplied separately.
2024-07-19 19:01:53 +01:00
Maciej W. Rozycki
ad781af697 MIPS/GAS/testsuite: Run the MT ASE test across architectures
Verify that MT ASE instructions assemble and disassemble correctly
across the compatible architectures.
2024-07-19 19:01:53 +01:00
Maciej W. Rozycki
6b34e39c39 MIPS/opcodes: Reorder coprocessor moves alphabetically
A number of coprocessor move encodings have been randomly sprinkled over
the regular MIPS and microMIPS opcode tables rather than where they'd be
expected following the alphabetic order.  Fix the ordering, taking into
account precedence where it has to be observed for correct disassembly.
No functional change.
2024-07-19 19:01:53 +01:00
Maciej W. Rozycki
f7808b8601 MIPS/opcodes: Make AL a shorthand for INSN2_ALIAS
Make AL a shorthand for INSN2_ALIAS with the regular MIPS and microMIPS
opcode tables, just as with the MIPS16 opcode table, and use it
throughout.  No functional change.
2024-07-19 19:01:52 +01:00
Maciej W. Rozycki
ef5ddeb170 MIPS/opcodes: Rename the AL membership shorthand to ALX
Make room for AL as a shorthand for INSN2_ALIAS with the regular MIPS
opcode table, just as with the MIPS16 opcode table.  No functional
change.
2024-07-19 19:01:52 +01:00
YunQiang Su
73a833412e MIPS/opcodes: Remove the regular MIPS "+t" operand code
The semantics of the regular MIPS "+t" operand code is exactly the same
as that of the "E" operand code, so replace the former with the latter
in the single MFTC0 instruction with implicit 'sel' == 0 encoding where
it's used, matching the encoding with explicit 'sel' as well as other
instructions.
2024-07-19 19:01:52 +01:00
Maciej W. Rozycki
31bd9f4682 MIPS/opcodes: Output thread context registers numerically with MFTR/MTTR
We print MFTR and MTTR instructions' thread context register operand in
disassembly using the ABI name the register number would correspond to
should the targeted register be a general-purpose register.

However in most cases it is wrong, because general-purpose registers are
only referred when the 'u' and 'sel' operands are 1 and 0 respectively.
And even in these cases the MFGPR and MTGPR aliases take precedence over
the corresponding generic instruction encodings, so you won't see the
valid case to normally trigger.

Conversely decoding the thread context register operand numerically is
always valid, so switch to using it.  Adjust test coverage accordingly.
2024-07-19 19:01:52 +01:00
Maciej W. Rozycki
2a172ea63d MIPS/opcodes: Discard unused OP_SH, OP_MASK, and OP_OP macros
As from commit ab90248154 ("Add structures to describe MIPS
operands"), <https://sourceware.org/ml/binutils/2013-07/msg00135.html>,
the use of numerous regular MIPS and microMIPS OP_SH and OP_MASK macros
has been removed.

Similarly as from commit c3c0747817 ("Use operand structures for
MIPS16"), <https://sourceware.org/ml/binutils/2013-07/msg00136.html>,
the use of numerous MIPS16 OP_SH and OP_MASK macros has been removed.

And as from commit 9e12b7a2b0 ("Rewrite main mips_ip parsing loop"),
<https://sourceware.org/ml/binutils/2013-07/msg00139.html>, none of the
OP_OP macros are used anymore.

Discard all the unused macros then and only keep the small subset that
is still referred.  This simplifies maintenance and removes the need to
keep the artificial arrangement where some regular MIPS and microMIPS
macros expand to 0 and are kept for compatibility with the opposite ISA
mode only, as it used to be required before the commit referred.
2024-07-19 11:42:16 +01:00
Maciej W. Rozycki
0f3e1d2708 MIPS/opcodes: Correct documentation for R6 operand types
The "-t", "-u", "-v", and "-w" operand types refer 'rt' operand, which
is the target register rather than the source register.  Additionally
the "-x" and "-y" R6 operand types refer 'rs' rather than 'rt' operand
of the BOVC/BNVC and the BEQC/BNEC instructions respectively.  Also the
"-x" operand type does not permit 'rs' to be the same as 'rt'.

Correct inline documentation in opcode/mips.h accordingly.
2024-07-19 11:42:16 +01:00
Maciej W. Rozycki
e6f05f3659 MIPS/opcodes: Exclude $0 from "-x" R6 operand type
The "-x" operand type is used for the reverse encoding of the BOVC and
BNVC instructions, where 'rs' and 'rt' have been supplied as the second
and the first operand respectively rather than the order the instruction
expects.

In this case we require the register associated with the "-x" operand to
have a higher number than the register associated with the preceding "t"
operand, which precludes the use of $0.  The case where 'rs' and 'rt'
both refer to the same register is handled by the straight encoding of
the BOVC and BNVC instructions, which come in the opcode table ahead of
the corresponding reverse encoding.

Therefore clear the ZERO_OK flag for the "-x" operand.  No need for an
extra test case as the encodings involved are already covered by "r6"
and its associated GAS tests.
2024-07-19 11:42:16 +01:00
Jan Beulich
91a082c1ba Sparc: relax gas testsuite whitespace expectations
In a subsequent change the scrubber is going to be changed to retain
further whitespace. Test case expectations generally would better not
depend on the specific whitespace treatment by the scrubber, unless of
course a test is specifically about it. Adjust relevant test cases to
permit blanks where those will subsequently appear.
2024-07-19 11:58:58 +02:00
Jan Beulich
6e892703fe TilePro: correct macro use in gas testsuite
Whitespace in macro arguments either needs quoting / parenthesizing to
reliably not be mistaken for an argument separator, or respective macro
parameters need to be marked as covering all remaining arguments. The
latter appears more appropriate (and far less intrusive) here.
2024-07-19 11:58:26 +02:00
Jan Beulich
c0e9aca554 MIPS: correct macro use in gas and ld testsuites
Whitespace in macro arguments either needs quoting / parenthesizing to
reliably not be mistaken for an argument separator, or respective macro
parameters need to be marked as covering all remaining arguments. The
former appears more appropriate here, as the macro parameters already
have ":req".
2024-07-19 11:58:04 +02:00
Jan Beulich
2231ac9b9e ia64: correct macro use in gas testsuite
Whitespace in macro arguments either needs quoting / parenthesizing to
reliably not be mistaken for an argument separator, or respective macro
parameters need to be marked as covering all remaining arguments. The
latter appears more appropriate here.
2024-07-19 11:57:12 +02:00
Jan Beulich
1cc4b7d755 bfin: drop _ASSIGN_BANG
A few testcases demonstrate that "=!" isn't supposed to be an
individual token, since "= !" is used in a number of places. So far
lexing that to a single token worked because of the scrubber being
overly aggressive in removing whitespace. As that's going to change,
replace uses by separate ASSIGN and BANG.
2024-07-19 11:56:46 +02:00
Jan Beulich
a1b7023447 bfin: correct macro use in gas testsuite
Whitespace in macro arguments either needs quoting / parenthesizing to
reliably not be mistaken for an argument separator, or respective macro
parameters need to be marked as covering all remaining arguments. The
latter really isn't an option here.
2024-07-19 11:56:20 +02:00
Jan Beulich
cfa18744d4 Arm: correct macro use in gas testsuite
The way the inner macro invocations are written doesn't quite work as
expected (and would actually break subsequently): Due to overly
aggressive removal of whitespace by the scrubber, the incoming \sym and
\offset arguments actually get concatenated; an empty 3rd argument is
being passed to ldrtest2. That just so happened to work as intended; any
use of \offset alone would have exposed the problem. Quote the 3rd
argument, thus retaining enough whitespace to be independent of scrubber
internals.
2024-07-19 11:55:54 +02:00
Jan Beulich
fd05d6b739 gas: adjust impossible/bogus M68K/MRI special case when scrubbing
State 1 is uniformly handled further up. And it is highly questionable
that in state 10 (i.e. after having seen not only a possible label, but
also an opcode), which is about to go away anyway, a line comment char
could still be meant to take effect. With the state checking dropped,
the immediately preceding logic can then also be simplified.
2024-07-19 11:54:45 +02:00
Jan Beulich
0d96d156ac gas: consistently drop trailing whitespace when scrubbing
From especially the checks for the two separator forms it appears to
follow that the construct being touched is about trailing whitespace. In
such a case, considering that for many targets ordinary and line comment
chars overlap, take into account that line comment chars override
ordinary ones in lex[] (logic elsewhere in do_scrub_chars() actually
depends on that ordering, and also accounts for this overriding).

Plus of course IS_NEWLINE() would better also be consulted. Note also
that the DOUBLESLASH_LINE_COMMENTS change should generally have no
effect just yet; it's a prereq for a later change but better fits here.

Leave respective comments as well, and update documentation to correct
which comment form is actually replaced by a single blank (i.e. neither
the ones starting with what {,tc_}comment_chars[] has nor the ones
starting with what line_comment_chars[] has).
2024-07-19 11:54:09 +02:00
Jan Beulich
da0fa10a4e gas: drop tic6x scrubber special case
Two successive PUT() without a state change in between can't be right:
The first PUT() may take the "goto tofull" path, leading to the
subsequent character being processed later in the previously set state
(1 in this case), rather than the state we were in upon entry to the
switch() (13 in this case).

However, the original purpose of that logic appears to be to not mistake
"|| ^" for "||^". This effect, sadly, looks to not have been achieved.
Therefore drop the special case altogether; something that actually
achieves the (presumably) intended effect may then be introduced down
the road.
2024-07-19 11:53:24 +02:00
Jan Beulich
75d0166b71 gas: pre-init the scrubber's lex[]
While we can't - unlike an old comment suggests - do this fully, we can
certainly do part of this at compile time.

Since it's adjacent, also drop the unnecessary forward declaration of
process_escape().
2024-07-19 11:52:50 +02:00
Jan Beulich
3fea91b17d x86: accept whitespace inside curly braces
Other than documented /**/ comments currently aren't really converted to
a single space, at least not for x86 in its most common configurations.
That'll be fixed subsequently, at which point blanks may appear where so
far none were expected. Furthermore not permitting blanks immediately
inside curly braces wasn't quite logical anyway - such constructs are
composite ones, and hence components ought to have been permitted to be
separated by whitespace from the very beginning.

With this we also don't care anymore whether the scrubber would remove
whitespace around curly braces, so move them from extra_symbol_chars[]
to operand_special_chars[].

Note: The new testcase doesn't actually exercise much (if any) of the
added code. It is being put in place to ensure that subsequently, when
that code actually comes into play, behavior remains the same.
2024-07-19 11:52:21 +02:00
Jan Beulich
0ff4e567db x86: undo '{' being a symbol-start character
Having it that way has undue side effects, in permitting not only
pseudo-prefixes to be parsed correctly, but also permitting odd symbol
names which ought to be possible only when quoted.  Borrow what other
architectures do: Put in place an "unrecognized line" hook to parse off
any pseudo prefixes, while using the "start of line" hook to reject ones
not actually followed by an insn. For that parsing re-use parse_insn()
in yet a slightly different mode (dealing with only pseudo-prefixes).

With that, pp may no longer be cleared from init_globals(), but instead
needs clearing after a line was fully processed. Since md_assemble() has
pretty many return paths, convert that into a local helper, with a
trivial wrapper around it.

Similarly pp may no longer be updated (by check_register()) when
processing anything other than insn operands. To be able to (easily)
recognize the case, clear current_templates.start when done with an insn
(or with .insn).
2024-07-19 11:44:07 +02:00
Jan Beulich
e3bfcef3f2 x86: split pseudo-prefix state from i386_insn
Subsequently we will want to update that ahead of md_assemble(), with
that function needing to take into account such earlier updating.
Therefore it'll want resetting separately from i.
2024-07-19 11:43:37 +02:00
Jan Beulich
8ba953169c x86/APX: add CMPcc/CTESTcc cases to noreg64 tests
This was missed when support for the insns was added. Just like for
DATA16, in

	rex64 neg (%rax)
	rex64 neg (%r16)
	rex64 {nf} neg (%rax)

it is not logical why the last one shouldn't be permitted. Bypassing
that check requires other adjustments, though, to actually properly
consume (and then squash) the prefix.
2024-07-19 10:54:22 +02:00
zhangxianting
88e7d674ef bfin: free the allocated memory 2024-07-19 10:53:12 +02:00
Maciej W. Rozycki
6eac8a3064 MIPS/GAS/testsuite: Also verify trap expansions of multiplication macros
Provide 'mul' test variants for trap expansions as requested by the
'-trap' command-line option, and run them across all the compatible
architectures.
2024-07-19 09:42:56 +01:00
Maciej W. Rozycki
37b8310680 MIPS/GAS/testsuite: Split mul test into 32-bit and 64-bit parts
Enable full 32-bit and 64-bit multiplication macro verification, by
splitting the 'mul' test into two parts respectively, and run them
across all the compatible architectures.
2024-07-19 09:42:56 +01:00
Maciej W. Rozycki
37ed5bd27a MIPS/GAS/testsuite: Run the mul macro test across architectures
The multiplication macros expand differently based on the ISA chosen, so
run the 'mul' macro test across compatible architectures, adopting the
'mul-ilocks' test orphaned by commit 23fce1e311 ("MIPS16 intermix test
failure"), <https://sourceware.org/ml/binutils/2009-01/msg00335.html>,
and providing coverage for the expansion variants.

Only run from MIPS III up for now and remove the ISA override from the
source, so that the 64-bit instructions are covered for individual
64-bit architectures.
2024-07-19 09:42:56 +01:00
Maciej W. Rozycki
dec718565a MIPS/GAS/testsuite: Also verify trap expansions of division macros
Provide 'div' test variants for trap expansions as requested by the
'-trap' command-line option, and run them across all the compatible
architectures.
2024-07-19 09:42:56 +01:00
Maciej W. Rozycki
b734aebe68 MIPS/GAS/testsuite: Split div test into 32-bit and 64-bit parts
Enable full 32-bit and 64-bit division macro verification, by splitting
the 'div' test into two parts respectively, and run them across all the
compatible architectures.
2024-07-19 09:42:56 +01:00
Maciej W. Rozycki
a70e2bc4fc MIPS/GAS/testsuite: Run the div macro test across architectures
The division macros expand differently depending on the ISA selected, so
run the 'div' macro test across compatible architectures, adopting the
'div-ilocks' test orphaned by commit 23fce1e311 ("MIPS16 intermix test
failure"), <https://sourceware.org/ml/binutils/2009-01/msg00335.html>,
and providing coverage for the expansion variants.

Only run from MIPS III up for now and remove the ISA override from the
source, so that the 64-bit instructions are covered for individual
64-bit architectures.
2024-07-19 09:42:56 +01:00
Maciej W. Rozycki
875ac09b12 MIPS/GAS: Handle --trap command-line option dynamically
We have an ISA check for the '--trap' command-line option that reports
its incompatibility with the MIPS I architecture.  It doesn't prevent
trap instructions from being enabled though, so when attempt is made to
emit one in an expansion of one of the division or multiplication macros
an assertion failure triggers:

.../gas/testsuite/gas/mips/brtr-opt.s: Assembler messages:
.../gas/testsuite/gas/mips/brtr-opt.s:3: Error: trap exception not supported at ISA 1
.../gas/testsuite/gas/mips/brtr-opt.s:9: Warning: divide by zero
.../gas/testsuite/gas/mips/brtr-opt.s:9: Internal error in macro_build at .../gas/config/tc-mips.c:9064.
Please report this bug.

The same assertion failure triggers without an earlier error message
when the initial ISA is compatible with the '--trap', however at the
time an attempt is made to emit a trap instruction from a division or
multiplication macro the ISA has been changed by a '.set' pseudo-op to
an incompatible one.

With the way the situations are mishandled it seems unlikely that anyone
relies on the current semantics and a sane approach is to decide on the
fly according to the currently selected ISA as to whether to emit trap
or breakpoint instructions in the case where '--trap' has been used.

Change our code to do so then and clarify that in the manual, which is
not explicit about how '--trap' is handled with a changing ISA.  Mention
the change in NEWS too since it's a applies to a user option.
2024-07-19 09:42:56 +01:00
Maciej W. Rozycki
5dd9c473f6 MIPS/GAS/testsuite: Add R10000 CPU architecture
Add a fully interlocked MIPS IV CPU so that we can have coverage for
MIPS IV instruction sequences with and without instruction separation
required for a HI/LO data anti-dependency.
2024-07-19 09:42:56 +01:00
Maciej W. Rozycki
71ddc7006b MIPS/GAS/testsuite: Reorder R5900 CPU architecture definition
The R5900 CPU architecture is based on MIPS III, so move it ahead of
MIPS IV CPU architecture definitions.  No functional change.
2024-07-19 09:42:56 +01:00
Indu Bhagat
0331cd9c51 gas: aarch64: testsuite: add new tests for SCFI
Similar to the x86_64 testcases, some .s files contain the corresponding
CFI directives.  This helps in validating the synthesized CFI by running
those tests with and without the --scfi=experimental command line
option.

GAS issues some diagnostics, enabled by default, with
--scfi=experimental.  The diagnostics have been added with an intent to
help user correct inadvertent errors in their hand-written asm.  An
error is issued when GAS finds that input asm is not amenable to
accurate CFI synthesis.  The existing scfi-diag-*.s tests in the
gas/testsuite/gas/scfi/x86_64 directory test some SCFI diagnostics
already:

      - (#1) "Warning: SCFI: Asymetrical register restore"
      - (#2) "Error: SCFI: usage of REG_FP as scratch not supported"
      - (#3) "Error: SCFI: unsupported stack manipulation pattern"
      - (#4) "Error: untraceable control flow for func 'XXX'"

In the newly added aarch64 testsuite, further tests for additional
diagnostics have been added:
 - scfi-diag-1.s in this patch highlights an aarch64-specific diagnostic:
   (#5) "Warning: SCFI: ignored probable save/restore op with reg offset"

Additionally, some testcases are added to showcase the (currently)
unsupported patterns, e.g., scfi-unsupported-1.s
        mov     x16, 4384
        sub     sp, sp, x16

gas/testsuite/:
	* gas/scfi/README: Update comment to include aarch64.
	* gas/scfi/aarch64/scfi-aarch64.exp: New file.
	* gas/scfi/aarch64/ginsn-arith-1.l: New test.
	* gas/scfi/aarch64/ginsn-arith-1.s: New test.
	* gas/scfi/aarch64/ginsn-cofi-1.l: New test.
	* gas/scfi/aarch64/ginsn-cofi-1.s: New test.
	* gas/scfi/aarch64/ginsn-ldst-1.l: New test.
	* gas/scfi/aarch64/ginsn-ldst-1.s: New test.
	* gas/scfi/aarch64/scfi-callee-saved-fp-1.d: New test.
	* gas/scfi/aarch64/scfi-callee-saved-fp-1.l: New test.
	* gas/scfi/aarch64/scfi-callee-saved-fp-1.s: New test.
	* gas/scfi/aarch64/scfi-callee-saved-fp-2.d: New test.
	* gas/scfi/aarch64/scfi-callee-saved-fp-2.l: New test.
	* gas/scfi/aarch64/scfi-callee-saved-fp-2.s: New test.
	* gas/scfi/aarch64/scfi-cb-1.d: New test.
	* gas/scfi/aarch64/scfi-cb-1.l: New test.
	* gas/scfi/aarch64/scfi-cb-1.s: New test.
	* gas/scfi/aarch64/scfi-cfg-1.d: New test.
	* gas/scfi/aarch64/scfi-cfg-1.l: New test.
	* gas/scfi/aarch64/scfi-cfg-1.s: New test.
	* gas/scfi/aarch64/scfi-cfg-2.d: New test.
	* gas/scfi/aarch64/scfi-cfg-2.l: New test.
	* gas/scfi/aarch64/scfi-cfg-2.s: New test.
	* gas/scfi/aarch64/scfi-cfg-3.d: New test.
	* gas/scfi/aarch64/scfi-cfg-3.l: New test.
	* gas/scfi/aarch64/scfi-cfg-3.s: New test.
	* gas/scfi/aarch64/scfi-cfg-4.l: New test.
	* gas/scfi/aarch64/scfi-cfg-4.s: New test.
	* gas/scfi/aarch64/scfi-cond-br-1.d: New test.
	* gas/scfi/aarch64/scfi-cond-br-1.l: New test.
	* gas/scfi/aarch64/scfi-cond-br-1.s: New test.
	* gas/scfi/aarch64/scfi-diag-1.l: New test.
	* gas/scfi/aarch64/scfi-diag-1.s: New test.
	* gas/scfi/aarch64/scfi-diag-2.l: New test.
	* gas/scfi/aarch64/scfi-diag-2.s: New test.
	* gas/scfi/aarch64/scfi-diag-3.l: New test.
	* gas/scfi/aarch64/scfi-diag-3.s: New test.
	* gas/scfi/aarch64/scfi-ldrp-1.d: New test.
	* gas/scfi/aarch64/scfi-ldrp-1.l: New test.
	* gas/scfi/aarch64/scfi-ldrp-1.s: New test.
	* gas/scfi/aarch64/scfi-ldrp-2.d: New test.
	* gas/scfi/aarch64/scfi-ldrp-2.l: New test.
	* gas/scfi/aarch64/scfi-ldrp-2.s: New test.
	* gas/scfi/aarch64/scfi-ldstnap-1.d: New test.
	* gas/scfi/aarch64/scfi-ldstnap-1.l: New test.
	* gas/scfi/aarch64/scfi-ldstnap-1.s: New test.
	* gas/scfi/aarch64/scfi-strp-1.d: New test.
	* gas/scfi/aarch64/scfi-strp-1.l: New test.
	* gas/scfi/aarch64/scfi-strp-1.s: New test.
	* gas/scfi/aarch64/scfi-strp-2.d: New test.
	* gas/scfi/aarch64/scfi-strp-2.l: New test.
	* gas/scfi/aarch64/scfi-strp-2.s: New test.
	* gas/scfi/aarch64/scfi-unsupported-1.l: New test.
	* gas/scfi/aarch64/scfi-unsupported-1.s: New test.
	* gas/scfi/aarch64/scfi-unsupported-2.l: New test.
	* gas/scfi/aarch64/scfi-unsupported-2.s: New test.
2024-07-18 20:54:14 -07:00
Indu Bhagat
29085f7243 gas: aarch64: add experimental support for SCFI
For synthesizing CFI (SCFI) for hand-written asm, the SCFI machinery in
GAS works on the generic GAS insns (ginsns).  This patch adds support in
the aarch64 backend to create ginsns for a subset of the supported
machine instructions.  The subset includes the minimal necessary
instructions to ensure SCFI correctness:

- Any potential register saves and unsaves.  Hence, process instructions
  belonging to a variety of iclasses involving str, ldr, stp, ldp.
- Any change of flow instructions.  This includes all conditional and
  unconditional branches, call (bl, blr, etc.) and return.
- Most importantly, any instruction that could affect the two registers
  of interest: REG_SP, REG_FP.  This set includes all pre-indexed and
  post-indexed memory operations, with writeback, on the stack.  This
  set must also include other instructions (e.g., arithmetic insns)
  where the destination register is one of the afore-mentioned registers.

With respect to callee-saved registers in Aarch64, FP/Advanced SIMD
registers D8-D15 are included along with the relevant GPRs.  Calculating
offsets for loads and stores especially for Q registers needs special
attention here.

As an example,
   str q8, [sp, #16]
On big-endian:
   STR Qn stores as a 128-bit integer (MSB first), hence, should record
   D8 as being saved at sp+24 rather than sp+16.
On little-endian:
   should record D8 as being saved at sp+16

D8-D15 are the low 64 bits of Q8-Q15, and of Z8-Z15 if SVE is used;
hence, they remain "interesting" for SCFI purposes in such cases.  A CFI
save slot always represents the low 64 bits, regardless of whether a
save occurs on D, Q or Z registers.  Currently, the ginsn creation
machinery can handle D and Q registers on little-endian and big-endian.

Apart from creating ginsn, another key responsibility of the backend is
to make sure there are safeguards in place to detect and alert if an
instruction of interest may have been skipped.  This is done via
aarch64_ginsn_unhandled () (similar to the x86 backend).  This function
, hence, is also intended to alert when future ISA changes may otherwise
render SCFI results incorrect, because of missing ginsns for the newly
added machine instructions.

At this time, becuase of the complexities wrt endianness in handling Z
register usage, skip sve_misc opclass altogether for now.  The SCFI
machinery will error out (using the aarch64_ginsn_unhandled () code
path) though if Z register usage affects correctness.

The current SCFI machinery does not currently synthesize the
PAC-related, aarch64-specific CFI directives: .cfi_b_key_frame.  The
support for this is planned for near future.

SCFI is enabled for ELF targets only.

gas/
	* config/tc-aarch64-ginsn.c: New file.
	* config/tc-aarch64.c (md_assemble): Include tc-aarch64-ginsn.c
	file.  Invoke aarch64_ginsn_new.
	* config/tc-aarch64.h (TARGET_USE_GINSN): Define for SCFI
	enablement.
	(TARGET_USE_SCFI): Likewise.
	(SCFI_MAX_REG_ID): New definition.
	(REG_FP): Likewise.
	(REG_LR): Likewise.
	(REG_SP): Likewise.
	(SCFI_INIT_CFA_OFFSET): Likewise.
	(SCFI_CALLEE_SAVED_REG_P): Likewise.
	(aarch64_scfi_callee_saved_p): New declaration.
2024-07-18 20:54:14 -07:00
Indu Bhagat
002ac05902 opcodes: aarch64: enforce checks on subclass flags in aarch64-gen.c
Enforce some checks on the newly added subclass flags:
  - If a subclass is set of one insn of an iclass, every insn of that
    iclass must have non-zero subclass field.
  - For all other iclasses, the subclass bits are zero for all insns.

include/
        * opcode/aarch64.h (enum aarch64_insn_class): Identify the
	maximum iclass enum value.

opcodes/
        * aarch64-gen.c (iclass_has_subclasses_p): New array of bool.
        (read_table): Enforce checks on subclass flags.
2024-07-18 20:54:14 -07:00
Indu Bhagat
5a4546190c opcodes: aarch64: denote subclasses for insns of iclass dp_2src
For detecting irg, add a subclass to identify it in the set of
instructions of iclass dp_2src.

opcodes/
	* aarch64-tbl.h: Add subclass flag F_DP_TAG_ONLY for irg insn.
2024-07-18 20:54:14 -07:00
Indu Bhagat
61f82dcb03 opcodes: aarch64: add flags to denote subclasses of uncond branches
Use the two new subclass flags: F_BRANCH_CALL, F_BRANCH_RET, to indicate
call to and return from subroutine respectively.

opcodes/
	* aarch64-tbl.h: Use the new F_BRANCH_* flags.
2024-07-18 20:54:14 -07:00
Indu Bhagat
7ecbb85893 opcodes: aarch64: add flags to denote subclasses of arithmetic insns
Use the three new subclass flags: F_ARITH_ADD, F_ARITH_SUB,
F_ARITH_MOV, to indicate add, sub and mov ops respectively.

These flags for subclasses will later be used for SCFI purposes to
create appropriate ginsns.  At this time, only those iclasses relevant
to SCFI have the new subclass flags specified.

For addg and subg insns, F_SUBCLASS_OTHER is more suitable because these
operations do more than just simple add or sub.

opcodes/
    * aarch64-tbl.h: Use the new F_ARITH_* flags.
2024-07-18 20:54:14 -07:00