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

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 6 05:43:51 PDT 2023


================
@@ -3029,10 +3029,20 @@ void LinkerDriver::link(opt::InputArgList &args) {
   // partition.
   copySectionsIntoPartitions();
 
-  if (config->emachine == EM_AARCH64 &&
-      config->androidMemtagMode != ELF::NT_MEMTAG_LEVEL_NONE) {
+  if (canHaveMemtagGlobals()) {
     llvm::TimeTraceScope timeScope("Process memory tagged symbols");
     createTaggedSymbols(ctx.objectFiles);
+  } else if (config->emachine == EM_AARCH64) {
+    // For fully static executables, make sure we prune any potential
+    // SHT_AARCH64_MEMTAG_GLOBALS_STATIC sections.
+    for (InputFile* file : ctx.objectFiles) {
----------------
smithp35 wrote:

At line 2938 there is some code that loops through all the Files adding all the InputSections to ctx.inputSections() 

It should be simpler to iterate through these as these sections will presumably have been added previously.

The current implementation will force an iteration through all sections, for quite a minority use case. Some possible alternatives to consider:
* In InputFiles.cpp mark the sections as discarded so they don't get loaded.
* Alter the code around line 2938 which is already filtering sections.

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


More information about the llvm-commits mailing list