[PATCH] D108167: [lld-macho] Refactor parseSections to avoid creating isec on LLVM segments

Vincent Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 16 15:23:56 PDT 2021


thevinster created this revision.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
thevinster edited the summary of this revision.
thevinster published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Address post follow up comment in D108016 <https://reviews.llvm.org/D108016>. Avoid creating isec for 
LLVM segments since we are skipping over it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108167

Files:
  lld/MachO/InputFiles.cpp


Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -279,6 +279,14 @@
             {off, make<ConcatInputSection>(segname, name, this,
                                            data.slice(off, literalSize), align,
                                            flags)});
+    } else if (segname == segment_names::llvm) {
+        // ld64 does not appear to emit contents from sections within the __LLVM
+        // segment. Symbols within those sections point to bitcode metadata
+        // instead of actual symbols. Global symbols within those sections could
+        // have the same name without causing duplicate symbol errors. Push an
+        // empty map to ensure indices line up for the remaining sections.
+        // TODO: Evaluate whether the bitcode metadata is needed.
+        subsections.push_back({});
     } else {
       auto *isec =
           make<ConcatInputSection>(segname, name, this, data, align, flags);
@@ -290,14 +298,6 @@
         // empty map to ensure the indices line up for the remaining sections.
         subsections.push_back({});
         debugSections.push_back(isec);
-      } else if (isec->getSegName() == segment_names::llvm) {
-        // ld64 does not appear to emit contents from sections within the __LLVM
-        // segment. Symbols within those sections point to bitcode metadata
-        // instead of actual symbols. Global symbols within those sections could
-        // have the same name without causing duplicate symbol errors. Push an
-        // empty map to ensure indices line up for the remaining sections.
-        // TODO: Evaluate whether the bitcode metadata is needed.
-        subsections.push_back({});
       } else {
         subsections.push_back({{0, isec}});
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108167.366749.patch
Type: text/x-patch
Size: 1851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210816/947c7505/attachment.bin>


More information about the llvm-commits mailing list