[llvm] [BOLT][runtime] Add start & fini symbols (PR #68505)

Vladislav Khmelevsky via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 9 02:51:06 PDT 2023


================
@@ -4568,6 +4568,26 @@ void RewriteInstance::updateELFSymbolTable(
     }
   }
 
+  // Add runtime library start and fini address symbols
+  if (RuntimeLibrary *RtLibrary = BC->getRuntimeLibrary()) {
+    auto AddSymbol = [&](StringRef Name, uint64_t Address) {
+      if (!Address)
+        return;
+
+      ELFSymTy NewSymbol;
+      NewSymbol.st_shndx = ELF::SHN_ABS;
+      NewSymbol.st_value = Address;
+      NewSymbol.st_name = AddToStrTab(Name);
+      NewSymbol.st_size = 0;
+      NewSymbol.st_other = 0;
+      NewSymbol.setBindingAndType(ELF::STB_LOCAL, ELF::STT_NOTYPE);
+      Symbols.emplace_back(NewSymbol);
+    };
+
+    AddSymbol("__bolt_runtime_start", RtLibrary->getRuntimeStartAddress());
+    AddSymbol("__bolt_runtime_fini", RtLibrary->getRuntimeFiniAddress());
----------------
yota9 wrote:

> Shouldn't we call these __bolt_instr_start/__bolt_instr_fini for consistency with instr.cpp?


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


More information about the llvm-commits mailing list