[llvm] [BOLT] Support computed goto and allow map addrs inside functions (PR #120267)

Ash Dobrescu via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 04:47:08 PST 2025


================
@@ -2439,6 +2439,26 @@ void RewriteInstance::readDynamicRelocations(const SectionRef &Section,
     if (Symbol)
       SymbolIndex[Symbol] = getRelocationSymbol(InputFile, Rel);
 
+    const uint64_t ReferencedAddress = SymbolAddress + Addend;
+    BinaryFunction *Func =
+        BC->getBinaryFunctionContainingAddress(ReferencedAddress);
+
+    if (Func) {
+      if (!Func->isInConstantIsland(ReferencedAddress)) {
+        if (const uint64_t ReferenceOffset =
+                ReferencedAddress - Func->getAddress()) {
+          Func->addEntryPointAtOffset(ReferenceOffset);
+        } else if (ReferencedAddress < Func->getAddress()) {
+          BC->errs() << "BOLT-ERROR: Unable to compute symbol offset.\n";
+          exit(1);
+        }
+      } else {
+        BC->errs() << "BOLT-ERROR: Referenced address: " << ReferencedAddress
+                   << " is in constant island of function : " << Func << ".\n";
----------------
Rin18 wrote:

Done

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


More information about the llvm-commits mailing list