[PATCH] D128938: [lld-macho] Read in new addrsig format

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 30 12:49:28 PDT 2022


int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added projects: lld-macho, All.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The new format uses symbol relocations, as described in D127637: [MC][MachO] Change addrsig format + ensure its size is properly set <https://reviews.llvm.org/D127637>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128938

Files:
  lld/MachO/ICF.cpp


Index: lld/MachO/ICF.cpp
===================================================================
--- lld/MachO/ICF.cpp
+++ lld/MachO/ICF.cpp
@@ -384,18 +384,13 @@
       continue;
     assert(addrSigSection->subsections.size() == 1);
 
-    Subsection *subSection = &addrSigSection->subsections[0];
-    ArrayRef<unsigned char> &contents = subSection->isec->data;
-
-    const uint8_t *pData = contents.begin();
-    while (pData != contents.end()) {
-      unsigned size;
-      const char *err;
-      uint32_t symIndex = decodeULEB128(pData, &size, contents.end(), &err);
-      if (err)
-        fatal(toString(file) + ": could not decode addrsig section: " + err);
-      markSymAsAddrSig(obj->symbols[symIndex]);
-      pData += size;
+    const InputSection *isec = addrSigSection->subsections[0].isec;
+
+    for (const Reloc &r : isec->relocs) {
+      if (auto *sym = r.referent.dyn_cast<Symbol *>())
+        markSymAsAddrSig(sym);
+      else
+        error(toString(isec) + ": unexpected section relocation");
     }
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128938.441494.patch
Type: text/x-patch
Size: 1034 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220630/317e6fda/attachment.bin>


More information about the llvm-commits mailing list