[PATCH] D78168: [lld-macho][rfc] Have Symbol::getVA() return a non-relative virtual address

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 16:13:44 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf92377823d1: [lld-macho] Have Symbol::getVA() return a non-relative virtual address (authored by int3, committed by smeenai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78168

Files:
  lld/MachO/ExportTrie.cpp
  lld/MachO/InputSection.cpp
  lld/MachO/Symbols.h
  lld/MachO/Writer.cpp


Index: lld/MachO/Writer.cpp
===================================================================
--- lld/MachO/Writer.cpp
+++ lld/MachO/Writer.cpp
@@ -162,7 +162,7 @@
     auto *c = reinterpret_cast<entry_point_command *>(buf);
     c->cmd = LC_MAIN;
     c->cmdsize = getSize();
-    c->entryoff = config->entry->getVA();
+    c->entryoff = config->entry->getVA() - ImageBase;
     c->stacksize = 0;
   }
 };
Index: lld/MachO/Symbols.h
===================================================================
--- lld/MachO/Symbols.h
+++ lld/MachO/Symbols.h
@@ -81,7 +81,7 @@
 
 inline uint64_t Symbol::getVA() const {
   if (auto *d = dyn_cast<Defined>(this))
-    return d->isec->addr + d->value - ImageBase;
+    return d->isec->addr + d->value;
   return 0;
 }
 
Index: lld/MachO/InputSection.cpp
===================================================================
--- lld/MachO/InputSection.cpp
+++ lld/MachO/InputSection.cpp
@@ -33,7 +33,7 @@
     uint64_t va = 0;
     if (auto *s = r.target.dyn_cast<Symbol *>()) {
       if (auto *dylibSymbol = dyn_cast<DylibSymbol>(s)) {
-        va = in.got->addr - ImageBase + dylibSymbol->gotIndex * WordSize;
+        va = in.got->addr + dylibSymbol->gotIndex * WordSize;
       } else {
         va = s->getVA();
       }
@@ -45,7 +45,7 @@
 
     uint64_t val = va + r.addend;
     if (1) // TODO: handle non-pcrel relocations
-      val -= addr - ImageBase + r.offset;
+      val -= addr + r.offset;
     target->relocateOne(buf + r.offset, r.type, val);
   }
 }
Index: lld/MachO/ExportTrie.cpp
===================================================================
--- lld/MachO/ExportTrie.cpp
+++ lld/MachO/ExportTrie.cpp
@@ -196,7 +196,7 @@
 
   if (isTerminal) {
     assert(j - i == 1); // no duplicate symbols
-    node->info = {pivotSymbol->getVA() + ImageBase};
+    node->info = {pivotSymbol->getVA()};
   } else {
     // This is the tail-call-optimized version of the following:
     // sortAndBuild(vec.slice(i, j - i), node, lastPos, pos + 1);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78168.261084.patch
Type: text/x-patch
Size: 1998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200429/25c15236/attachment.bin>


More information about the llvm-commits mailing list