[lld] [lld] [MTE] Drop MTE globals for fully static executables, not ban (PR #68217)

Mitch Phillips via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 5 06:15:14 PDT 2023


hctim wrote:

> I forget whether LLD supports static PIE, but wouldn’t that allow MTE globals? And why can’t even static PDEs support them? We preserve and process relocations for IFUNCs today.

Looking at the ifunc resolver glue in bionic (Android's loader/libc), it maybe possible in future support MTE globals as part of fully static executables. MTE globals requires two parts:

 1. Applying random memory tags to each GV as described in `AARCH64_MEMTAG_GLOBALS_DYNAMIC`. Not too hard, just add weak symbols (to find the section) and some libc-static glue to initialize it.
 2. Materializing the address tags for each GV. Normally done during relocation time, for a static or static-pie binary this would only include `R_RELATIVE` and `RELR` relocations. But we'd basically be emitting the entire subset of relocations that touch global variables, and that'd need to be processed. Again, doable (using some weak symbols to find the reloc section), but requires a bit of work. We could, for static executables, just not do RELR compression but that'd probably result in a reasonable binary size bloat.

Either way, I'd consider MTE globals for static binaries as an extension for future work. For now, we just don't support it.

https://github.com/llvm/llvm-project/pull/68217


More information about the llvm-commits mailing list