[PATCH] D158911: [BOLT] Support input binaries that use R_X86_GOTPC64

Maksim Panchenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 15:30:33 PDT 2023


maksfb added a comment.

Thanks for adding one more test case.



================
Comment at: bolt/lib/Rewrite/JITLinkLinker.cpp:134
+        if (const BinaryData *I = Linker.BC.getGlobalOffsetTableSym()) {
+          uint64_t Address = I->isMoved() && !I->isJumpTable()
+                                 ? I->getOutputAddress()
----------------
When can `GOT` be a jump table?


================
Comment at: bolt/lib/Target/X86/X86MCSymbolizer.cpp:167
+    errs() << "BOLT-ERROR: R_X86_GOTPC64 relocation is present but we did "
+              "not detect a valid  _GLOBAL_OFFSET_TABLE_ in symbol table.\n";
+    exit(1);
----------------



================
Comment at: bolt/lib/Target/X86/X86MCSymbolizer.cpp:176
+  // GOT addr.
+  int64_t Addend = R.Value + InstrAddr - GOTSymBD->getAddress();
+  for (MCSymbol *GOTSym : GOTSymBD->symbols()) {
----------------



================
Comment at: bolt/lib/Target/X86/X86MCSymbolizer.cpp:183-184
+  // it is local/hidden. Just create our own to please the assembler.
+  return std::make_pair(BC.Ctx->getOrCreateSymbol("_GLOBAL_OFFSET_TABLE_"),
+                        Addend);
+}
----------------
Should we just always take this path instead of searching for the matching name?


================
Comment at: bolt/test/runtime/X86/gotoff-large-code-model-2.s:10
+
+# RUN: llvm-bolt %t.exe --funcs init_impls -lite \
+# RUN:   -o %t.bolted
----------------



================
Comment at: bolt/test/runtime/X86/gotoff-large-code-model.s:7
+
+# RUN: llvm-bolt %t.exe --funcs init_impls -lite \
+# RUN:   -o %t.bolted
----------------
nit:



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158911/new/

https://reviews.llvm.org/D158911



More information about the llvm-commits mailing list