[lld] 08d55c5 - [lld-macho] Refactor parseSections to avoid creating isec on LLVM segments

Vincent Lee via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 16 18:48:13 PDT 2021


Author: Vincent Lee
Date: 2021-08-16T18:47:50-07:00
New Revision: 08d55c5c0156a3759d375711771fccfa3e9a79a5

URL: https://github.com/llvm/llvm-project/commit/08d55c5c0156a3759d375711771fccfa3e9a79a5
DIFF: https://github.com/llvm/llvm-project/commit/08d55c5c0156a3759d375711771fccfa3e9a79a5.diff

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

Address post follow up comment in D108016. Avoid creating isec for
LLVM segments since we are skipping over it.

Reviewed By: #lld-macho, int3

Differential Revision: https://reviews.llvm.org/D108167

Added: 
    

Modified: 
    lld/MachO/InputFiles.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 32279da1cf62..8d64f2731d8d 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -279,6 +279,14 @@ void ObjFile::parseSections(ArrayRef<Section> sections) {
             {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 @@ void ObjFile::parseSections(ArrayRef<Section> sections) {
         // 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}});
       }


        


More information about the llvm-commits mailing list