]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
aarch64: Add support for new BTI <target> "r"
authorSrinath Parvathaneni <srinath.parvathaneni@arm.com>
Mon, 15 Dec 2025 11:01:49 +0000 (11:01 +0000)
committerSrinath Parvathaneni <srinath.parvathaneni@arm.com>
Mon, 15 Dec 2025 11:01:49 +0000 (11:01 +0000)
This patch adds support for new BTI <target> "r" (instruction: bti r),
which is an alias to "bti" (with no target), for both "bti" and "bti r"
the preferred disassembly is "bti r". This "bti r" instruction is by
default available from Armv8-A architecture.

The HINT_OPD_F_NOPRINT macro has become redundant with these changes
and has been removed.

gas/config/tc-aarch64.c
gas/testsuite/gas/aarch64/bti.d
gas/testsuite/gas/aarch64/bti.s
gas/testsuite/gas/aarch64/hint-bad.l
gas/testsuite/gas/aarch64/system.d
include/opcode/aarch64.h
ld/testsuite/ld-aarch64/protections/bti-far-opt.d
opcodes/aarch64-opc-2.c
opcodes/aarch64-opc.c
opcodes/aarch64-opc.h
opcodes/aarch64-tbl.h

index 29de5ee99945421f2cfcbaa4d69f049c5a5becfb..6243ea240ad6d709cf8699cd225e6b7a0d4408ee 100644 (file)
@@ -4615,7 +4615,7 @@ parse_hint_opt (const char *name, char **str,
          && o->value != HINT_OPD_CSYNC)
       || ((strcmp ("bti", name) == 0)
          && (o->value != HINT_OPD_C && o->value != HINT_OPD_J
-             && o->value != HINT_OPD_JC))
+             && o->value != HINT_OPD_JC && o->value != HINT_OPD_R))
       || ((strcmp ("stshh", name) == 0)
          && (o->value != HINT_OPD_KEEP && o->value != HINT_OPD_STRM)))
       return false;
index 434efa32cde1ea814838d6876cd54af6dd579e9f..4312cfab62eb0b48c8fa45c65e387b647f61a5e8 100644 (file)
@@ -6,10 +6,12 @@
 Disassembly of section \.text:
 
 0+ <.*>:
-.*:    d503241f        bti
+.*:    d503241f        bti     r
+.*:    d503241f        bti     r
 .*:    d503245f        bti     c
 .*:    d503249f        bti     j
 .*:    d50324df        bti     jc
+.*:    d503241f        bti     r
 .*:    d503245f        bti     c
 .*:    d503249f        bti     j
 .*:    d50324df        bti     jc
index 528447b4623be5b5d86caea3c7fa8a2d5728bc69..70d68c93fe252ce2f9497f4c2138261a0f8fc017 100644 (file)
@@ -3,10 +3,12 @@
        .text
 
        bti
+       bti r
        bti c
        bti j
        bti jc
 
+       bti R
        bti C
        bti J
        bti JC
index 57caed10e9a16de8415bc1a19bf9799898b5755e..7017c68d29d5f1b235fbda978de42c8404121964 100644 (file)
@@ -5,4 +5,4 @@
 [^ :]+:[0-9]+: Error: operand 1 must be the PSB/TSB option name CSYNC -- `psb dsync'
 [^ :]+:[0-9]+: Error: operand 1 must be the PSB/TSB option name CSYNC -- `tsb'
 [^ :]+:[0-9]+: Error: operand 1 must be the PSB/TSB option name CSYNC -- `tsb dsync'
-[^ :]+:[0-9]+: Error: operand 1 must be BTI targets j/c/jc -- `bti jj'
+[^ :]+:[0-9]+: Error: operand 1 must be BTI targets r/j/c/jc -- `bti jj'
index ee84793d7614f46b2cdc1ded78bbfe088c87b360..6d90420d539a6eceff838405c2dc4f956590c123 100644 (file)
@@ -50,7 +50,7 @@ Disassembly of section \.text:
 .*:    d50323bf        (hint   #0x1d|autiasp)
 .*:    d50323df        (hint   #0x1e|autibz)
 .*:    d50323ff        (hint   #0x1f|autibsp)
-.*:    d503241f        (hint   #0x20|bti)
+.*:    d503241f        (hint   #0x20|bti       r)
 .*:    d503243f        hint    #0x21
 .*:    d503245f        (hint   #0x22|bti       c)
 .*:    d503247f        hint    #0x23
index 5db5932b3bdc9448a1b157e15ae2ce2ff309a246..3754f7082a51827a544572869973b37a41cfcc8c 100644 (file)
@@ -1858,6 +1858,7 @@ struct aarch64_inst
 /* Defining the HINT #imm values for the aarch64_hint_options.  */
 #define HINT_OPD_CSYNC 0x11
 #define HINT_OPD_DSYNC 0x13
+#define HINT_OPD_R     0x20
 #define HINT_OPD_C     0x22
 #define HINT_OPD_J     0x24
 #define HINT_OPD_JC    0x26
index f5038c0cb7256669506997bc11862d9f4ab2ef94..ce202815c9a794108dd26d1b6a848ff696823cd0 100644 (file)
@@ -43,7 +43,7 @@ Disassembly of section \.text:
    2000c:      d503201f        nop
 
 0000000000020010 <baz_bti_>:
-   20010:      d503241f        bti
+   20010:      d503241f        bti     r
 
 0000000000020014 <baz_bti_c>:
    20014:      d503245f        bti     c
index 7f3b25eae384c21ae65fc4fa42e36417e7cef26d..f88bc2d9a0341c2fcefe606bff5e6a8e811b4535 100644 (file)
@@ -149,7 +149,7 @@ const struct aarch64_operand aarch64_operands[] =
   {AARCH64_OPND_CLASS_SYSTEM, "RPRFMOP", OPD_F_HAS_INSERTER | OPD_F_HAS_EXTRACTOR, {FLD_imm1_15, FLD_imm2_12, FLD_imm3_0}, "a range prefetch operation specifier"},
   {AARCH64_OPND_CLASS_SYSTEM, "BARRIER_PSB", OPD_F_HAS_INSERTER | OPD_F_HAS_EXTRACTOR, {}, "the PSB/TSB option name CSYNC"},
   {AARCH64_OPND_CLASS_SYSTEM, "BARRIER_GCSB", OPD_F_HAS_INSERTER | OPD_F_HAS_EXTRACTOR, {}, "the GCSB option name DSYNC"},
-  {AARCH64_OPND_CLASS_SYSTEM, "BTI_TARGET", OPD_F_HAS_INSERTER | OPD_F_HAS_EXTRACTOR, {}, "BTI targets j/c/jc"},
+  {AARCH64_OPND_CLASS_SYSTEM, "BTI_TARGET", OPD_F_HAS_INSERTER | OPD_F_HAS_EXTRACTOR, {}, "BTI targets r/j/c/jc"},
   {AARCH64_OPND_CLASS_SYSTEM, "STSHH_POLICY", OPD_F_HAS_INSERTER | OPD_F_HAS_EXTRACTOR, {}, "an STSHH policy (keep/strm)"},
   {AARCH64_OPND_CLASS_SYSTEM, "BRBOP", OPD_F_HAS_INSERTER | OPD_F_HAS_EXTRACTOR, {FLD_brbop}, "Branch Record Buffer operation operand"},
   {AARCH64_OPND_CLASS_INT_REG, "Rt_IN_SYS_ALIASES", OPD_F_HAS_INSERTER | OPD_F_HAS_EXTRACTOR, {FLD_Rt}, "Rt register with defaults for SYS aliases"},
index 97852a0132da9b539cf396b07ae02c0cc6030ec4..b697d7725562fe0f997558afac9ecc7f94bcf698 100644 (file)
@@ -597,7 +597,7 @@ const struct aarch64_name_value_pair aarch64_barrier_dsb_nxs_options[4] =
 const struct aarch64_name_value_pair aarch64_hint_options[] =
 {
   /* BTI.  This is also the F_DEFAULT entry for AARCH64_OPND_BTI_TARGET.  */
-  { " ",       HINT_ENCODE (HINT_OPD_F_NOPRINT, 0x20) },
+  { "r",       HINT_OPD_R },           /* BTI R.  */
   { "csync",   HINT_OPD_CSYNC },       /* PSB CSYNC.  */
   { "dsync",   HINT_OPD_DSYNC },       /* GCSB DSYNC.  */
   { "c",       HINT_OPD_C },           /* BTI C.  */
@@ -5154,9 +5154,8 @@ aarch64_print_operand (char *buf, size_t size, bfd_vma pc,
       break;
 
     case AARCH64_OPND_BTI_TARGET:
-      if ((HINT_FLAG (opnd->hint_option->value) & HINT_OPD_F_NOPRINT) == 0)
-       snprintf (buf, size, "%s",
-                 style_sub_mnem (styler, opnd->hint_option->name));
+      snprintf (buf, size, "%s",
+               style_sub_mnem (styler, opnd->hint_option->name));
       break;
 
     case AARCH64_OPND_STSHH_POLICY:
index 5d544d53baf052a5f580adbc277e52bfade303c0..544cbe5d5699f75c01ae0c8e328ed7b7898e56e5 100644 (file)
@@ -391,9 +391,6 @@ verify_constraints (const struct aarch64_inst *, const aarch64_insn, bfd_vma,
 #define F_REG_MAX_VALUE(X) ((X) << 15)
 #define F_GET_REG_MAX_VALUE(X) (((X) >> 15) & 0x0f)
 
-/* HINT operand flags.  */
-#define HINT_OPD_F_NOPRINT     (1 << 0)  /* Should not be printed.  */
-
 /* Encode 7-bit HINT #imm in the lower 8 bits.  Use higher bits for flags.  */
 #define HINT_ENCODE(flag, val) ((flag << 8) | val)
 #define HINT_FLAG(val) (val >> 8)
index 3b14b6863c657cd8c055a8aa6a9457ba40807cf4..935a335b416fc93cf4490fc78e18930500257bd2 100644 (file)
@@ -7987,7 +7987,7 @@ const struct aarch64_opcode aarch64_opcode_table[] =
     Y(SYSTEM, none, "BARRIER_GCSB", 0, F (),                           \
       "the GCSB option name DSYNC")                                    \
     Y(SYSTEM, hint, "BTI_TARGET", 0, F (),                             \
-      "BTI targets j/c/jc")                                            \
+      "BTI targets r/j/c/jc")                                          \
     Y(SYSTEM, hint, "STSHH_POLICY", 0, F(),                            \
       "an STSHH policy (keep/strm)")                                   \
     Y(SYSTEM, imm, "BRBOP", 0, F(FLD_brbop),                           \