&& !add_dynamic_entry (DT_AARCH64_MEMTAG_MODE,
htab->memtag_opts.memtag_mode == AARCH64_MEMTAG_MODE_ASYNC))
return false;
+
+ if (is_aarch64_elf (output_bfd)
+ && htab->memtag_opts.memtag_stack == 1
+ && !add_dynamic_entry (DT_AARCH64_MEMTAG_STACK,
+ htab->memtag_opts.memtag_stack == 1))
+ return false;
}
#undef add_dynamic_entry
{
/* Mode of MTE operation. */
aarch64_memtag_mode_type memtag_mode;
+
+ /* Whether stack accesses use MTE insns. */
+ unsigned int memtag_stack;
};
typedef struct aarch64_memtag_opts aarch64_memtag_opts;
case DT_AARCH64_PAC_PLT: return "AARCH64_PAC_PLT";
case DT_AARCH64_VARIANT_PCS: return "AARCH64_VARIANT_PCS";
case DT_AARCH64_MEMTAG_MODE: return "AARCH64_MEMTAG_MODE";
+ case DT_AARCH64_MEMTAG_STACK: return "AARCH64_MEMTAG_STACK";
default:
return NULL;
#define DT_AARCH64_PAC_PLT (DT_LOPROC + 3)
#define DT_AARCH64_VARIANT_PCS (DT_LOPROC + 5)
#define DT_AARCH64_MEMTAG_MODE (DT_LOPROC + 9)
+#define DT_AARCH64_MEMTAG_STACK (DT_LOPROC + 12)
/* AArch64-specific values for st_other. */
#define STO_AARCH64_VARIANT_PCS 0x80 /* Symbol may follow different call
static aarch64_memtag_opts memtag_opts = {
.memtag_mode = AARCH64_MEMTAG_MODE_NONE,
+ .memtag_stack = 0,
};
#define COMPILE_TIME_STRLEN(s) \
sync: Enable precise exceptions when mismatched address and\n\
allocation tags detected on load/store operations.\n\
async: Enable imprecise exceptions.\n"));
+ fprintf (file, _("\
+ -z memtag-stack Mark program stack with MTE protection.\n"));
'
PARSE_AND_LIST_ARGS_CASE_Z_AARCH64='
{}
else if (aarch64_parse_memtag_mode_option (optarg))
{}
+ else if (strcmp (optarg, "memtag-stack") == 0)
+ memtag_opts.memtag_stack = 1;
'
PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_AARCH64"
instruction where the fault occurred, and the exact faulting address.
The @samp{async} mode implies imprecise exceptions.
+@kindex -z memtag-stack
+@cindex Mark program stack for MTE protection
+The @samp{-z memtag-stack} specifies that output object uses MTE
+instructions for stack memory usage.
+
@ifclear GENERIC
@lowersections
@end ifclear
run_dump_test_lp64 "mte-tagged-frame"
run_dump_test_lp64 "dt-memtag-mode"
+run_dump_test_lp64 "dt-memtag-stack"
set aarch64elflinktests {
{"ld-aarch64/so with global symbol" "-shared" "" "" {copy-reloc-so.s}
--- /dev/null
+#source: dt-memtag.s
+#ld: -shared -z memtag-stack
+#readelf: -d
+
+#...
+ 0x000000007000000c \(AARCH64_MEMTAG_STACK\) 0x1
+#...