[lld-macho][nfc] rename parsed-section types & variables

This is an NFC diff that prepares for pruning & relocating `__eh_frame`.

Along the way, I made the following changes to ...
* clarify usage of `section` vs. `subsection`
* remove `map` & `vec` from type names
* disambiguate class `Section` from template parameter `SectionHeader`.

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

GitOrigin-RevId: 3a1b3c9afe74ef09a16b2ceefeaad854acf3fe7d
diff --git a/MachO/Driver.cpp b/MachO/Driver.cpp
index ddd84bc..37955c9 100644
--- a/MachO/Driver.cpp
+++ b/MachO/Driver.cpp
@@ -1021,10 +1021,10 @@
   TimeTraceScope timeScope("Gathering input sections");
   int inputOrder = 0;
   for (const InputFile *file : inputFiles) {
-    for (const SubsectionMap &map : file->subsections) {
+    for (const Section &section : file->sections) {
       ConcatOutputSection *osec = nullptr;
-      for (const SubsectionEntry &entry : map) {
-        if (auto *isec = dyn_cast<ConcatInputSection>(entry.isec)) {
+      for (const Subsection &subsection : section.subsections) {
+        if (auto *isec = dyn_cast<ConcatInputSection>(subsection.isec)) {
           if (isec->isCoalescedWeak())
             continue;
           if (isec->getSegName() == segment_names::ld) {
@@ -1036,11 +1036,13 @@
             osec = ConcatOutputSection::getOrCreateForInput(isec);
           isec->parent = osec;
           inputSections.push_back(isec);
-        } else if (auto *isec = dyn_cast<CStringInputSection>(entry.isec)) {
+        } else if (auto *isec =
+                       dyn_cast<CStringInputSection>(subsection.isec)) {
           if (in.cStringSection->inputOrder == UnspecifiedInputOrder)
             in.cStringSection->inputOrder = inputOrder++;
           in.cStringSection->addInput(isec);
-        } else if (auto *isec = dyn_cast<WordLiteralInputSection>(entry.isec)) {
+        } else if (auto *isec =
+                       dyn_cast<WordLiteralInputSection>(subsection.isec)) {
           if (in.wordLiteralSection->inputOrder == UnspecifiedInputOrder)
             in.wordLiteralSection->inputOrder = inputOrder++;
           in.wordLiteralSection->addInput(isec);
diff --git a/MachO/InputFiles.cpp b/MachO/InputFiles.cpp
index 769fddd..893bf26 100644
--- a/MachO/InputFiles.cpp
+++ b/MachO/InputFiles.cpp
@@ -257,12 +257,14 @@
   return {};
 }
 
-template <class Section>
-void ObjFile::parseSections(ArrayRef<Section> sections) {
-  subsections.reserve(sections.size());
+// Parse the sequence of sections within a single LC_SEGMENT(_64).
+// Split each section into subsections.
+template <class SectionHeader>
+void ObjFile::parseSections(ArrayRef<SectionHeader> sectionHeaders) {
+  sections.reserve(sectionHeaders.size());
   auto *buf = reinterpret_cast<const uint8_t *>(mb.getBufferStart());
 
-  for (const Section &sec : sections) {
+  for (const SectionHeader &sec : sectionHeaders) {
     StringRef name =
         StringRef(sec.sectname, strnlen(sec.sectname, sizeof(sec.sectname)));
     StringRef segname =
@@ -273,27 +275,27 @@
     if (sec.align >= 32) {
       error("alignment " + std::to_string(sec.align) + " of section " + name +
             " is too large");
-      subsections.push_back({});
+      sections.push_back({});
       continue;
     }
     uint32_t align = 1 << sec.align;
     uint32_t flags = sec.flags;
 
     auto splitRecords = [&](int recordSize) -> void {
-      subsections.push_back({});
+      sections.push_back({});
       if (data.empty())
         return;
 
-      SubsectionMap &subsecMap = subsections.back();
-      subsecMap.reserve(data.size() / recordSize);
+      Subsections &subsections = sections.back().subsections;
+      subsections.reserve(data.size() / recordSize);
       auto *isec = make<ConcatInputSection>(
           segname, name, this, data.slice(0, recordSize), align, flags);
-      subsecMap.push_back({0, isec});
+      subsections.push_back({0, isec});
       for (uint64_t off = recordSize; off < data.size(); off += recordSize) {
         // Copying requires less memory than constructing a fresh InputSection.
         auto *copy = make<ConcatInputSection>(*isec);
         copy->data = data.slice(off, recordSize);
-        subsecMap.push_back({off, copy});
+        subsections.push_back({off, copy});
       }
     };
 
@@ -315,7 +317,8 @@
         isec = make<WordLiteralInputSection>(segname, name, this, data, align,
                                              flags);
       }
-      subsections.push_back({{0, isec}});
+      sections.push_back({});
+      sections.back().subsections.push_back({0, isec});
     } else if (auto recordSize = getRecordSize(segname, name)) {
       splitRecords(*recordSize);
     } else if (segname == segment_names::llvm) {
@@ -323,9 +326,9 @@
       // 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.
+      // empty entry to ensure indices line up for the remaining sections.
       // TODO: Evaluate whether the bitcode metadata is needed.
-      subsections.push_back({});
+      sections.push_back({});
     } else {
       auto *isec =
           make<ConcatInputSection>(segname, name, this, data, align, flags);
@@ -334,11 +337,12 @@
         // Instead of emitting DWARF sections, we emit STABS symbols to the
         // object files that contain them. We filter them out early to avoid
         // parsing their relocations unnecessarily. But we must still push an
-        // empty map to ensure the indices line up for the remaining sections.
-        subsections.push_back({});
+        // empty entry to ensure the indices line up for the remaining sections.
+        sections.push_back({});
         debugSections.push_back(isec);
       } else {
-        subsections.push_back({{0, isec}});
+        sections.push_back({});
+        sections.back().subsections.push_back({0, isec});
       }
     }
   }
@@ -351,18 +355,17 @@
 // any subsection splitting has occurred). It will be updated to represent the
 // same location as an offset relative to the start of the containing
 // subsection.
-static InputSection *findContainingSubsection(SubsectionMap &map,
+static InputSection *findContainingSubsection(Subsections &subsections,
                                               uint64_t *offset) {
   auto it = std::prev(llvm::upper_bound(
-      map, *offset, [](uint64_t value, SubsectionEntry subsecEntry) {
-        return value < subsecEntry.offset;
-      }));
+      subsections, *offset,
+      [](uint64_t value, Subsection subsec) { return value < subsec.offset; }));
   *offset -= it->offset;
   return it->isec;
 }
 
-template <class Section>
-static bool validateRelocationInfo(InputFile *file, const Section &sec,
+template <class SectionHeader>
+static bool validateRelocationInfo(InputFile *file, const SectionHeader &sec,
                                    relocation_info rel) {
   const RelocAttrs &relocAttrs = target->getRelocAttrs(rel.r_type);
   bool valid = true;
@@ -393,14 +396,15 @@
   return valid;
 }
 
-template <class Section>
-void ObjFile::parseRelocations(ArrayRef<Section> sectionHeaders,
-                               const Section &sec, SubsectionMap &subsecMap) {
+template <class SectionHeader>
+void ObjFile::parseRelocations(ArrayRef<SectionHeader> sectionHeaders,
+                               const SectionHeader &sec,
+                               Subsections &subsections) {
   auto *buf = reinterpret_cast<const uint8_t *>(mb.getBufferStart());
   ArrayRef<relocation_info> relInfos(
       reinterpret_cast<const relocation_info *>(buf + sec.reloff), sec.nreloc);
 
-  auto subsecIt = subsecMap.rbegin();
+  auto subsecIt = subsections.rbegin();
   for (size_t i = 0; i < relInfos.size(); i++) {
     // Paired relocations serve as Mach-O's method for attaching a
     // supplemental datum to a primary relocation record. ELF does not
@@ -454,7 +458,8 @@
       r.addend = isSubtrahend ? 0 : totalAddend;
     } else {
       assert(!isSubtrahend);
-      const Section &referentSec = sectionHeaders[relInfo.r_symbolnum - 1];
+      const SectionHeader &referentSecHead =
+          sectionHeaders[relInfo.r_symbolnum - 1];
       uint64_t referentOffset;
       if (relInfo.r_pcrel) {
         // The implicit addend for pcrel section relocations is the pcrel offset
@@ -464,14 +469,16 @@
         // have pcrel section relocations. We may want to factor this out into
         // the arch-specific .cpp file.
         assert(target->hasAttr(r.type, RelocAttrBits::BYTE4));
-        referentOffset =
-            sec.addr + relInfo.r_address + 4 + totalAddend - referentSec.addr;
+        referentOffset = sec.addr + relInfo.r_address + 4 + totalAddend -
+                         referentSecHead.addr;
       } else {
         // The addend for a non-pcrel relocation is its absolute address.
-        referentOffset = totalAddend - referentSec.addr;
+        referentOffset = totalAddend - referentSecHead.addr;
       }
-      SubsectionMap &referentSubsecMap = subsections[relInfo.r_symbolnum - 1];
-      r.referent = findContainingSubsection(referentSubsecMap, &referentOffset);
+      Subsections &referentSubsections =
+          sections[relInfo.r_symbolnum - 1].subsections;
+      r.referent =
+          findContainingSubsection(referentSubsections, &referentOffset);
       r.addend = referentOffset;
     }
 
@@ -481,14 +488,14 @@
     // unsorted relocations (in `-r` mode), so we have a fallback for that
     // uncommon case.
     InputSection *subsec;
-    while (subsecIt != subsecMap.rend() && subsecIt->offset > r.offset)
+    while (subsecIt != subsections.rend() && subsecIt->offset > r.offset)
       ++subsecIt;
-    if (subsecIt == subsecMap.rend() ||
+    if (subsecIt == subsections.rend() ||
         subsecIt->offset + subsecIt->isec->getSize() <= r.offset) {
-      subsec = findContainingSubsection(subsecMap, &r.offset);
+      subsec = findContainingSubsection(subsections, &r.offset);
       // Now that we know the relocs are unsorted, avoid trying the 'fast path'
       // for the other relocations.
-      subsecIt = subsecMap.rend();
+      subsecIt = subsections.rend();
     } else {
       subsec = subsecIt->isec;
       r.offset -= subsecIt->offset;
@@ -509,10 +516,10 @@
       } else {
         uint64_t referentOffset =
             totalAddend - sectionHeaders[minuendInfo.r_symbolnum - 1].addr;
-        SubsectionMap &referentSubsecMap =
-            subsections[minuendInfo.r_symbolnum - 1];
+        Subsections &referentSubsectVec =
+            sections[minuendInfo.r_symbolnum - 1].subsections;
         p.referent =
-            findContainingSubsection(referentSubsecMap, &referentOffset);
+            findContainingSubsection(referentSubsectVec, &referentOffset);
         p.addend = referentOffset;
       }
       subsec->relocs.push_back(p);
@@ -649,7 +656,7 @@
   using NList = typename LP::nlist;
 
   // Groups indices of the symbols by the sections that contain them.
-  std::vector<std::vector<uint32_t>> symbolsBySection(subsections.size());
+  std::vector<std::vector<uint32_t>> symbolsBySection(sections.size());
   symbols.resize(nList.size());
   SmallVector<unsigned, 32> undefineds;
   for (uint32_t i = 0; i < nList.size(); ++i) {
@@ -662,9 +669,9 @@
 
     StringRef name = strtab + sym.n_strx;
     if ((sym.n_type & N_TYPE) == N_SECT) {
-      SubsectionMap &subsecMap = subsections[sym.n_sect - 1];
+      Subsections &subsections = sections[sym.n_sect - 1].subsections;
       // parseSections() may have chosen not to parse this section.
-      if (subsecMap.empty())
+      if (subsections.empty())
         continue;
       symbolsBySection[sym.n_sect - 1].push_back(i);
     } else if (isUndef(sym)) {
@@ -674,16 +681,16 @@
     }
   }
 
-  for (size_t i = 0; i < subsections.size(); ++i) {
-    SubsectionMap &subsecMap = subsections[i];
-    if (subsecMap.empty())
+  for (size_t i = 0; i < sections.size(); ++i) {
+    Subsections &subsections = sections[i].subsections;
+    if (subsections.empty())
       continue;
 
     std::vector<uint32_t> &symbolIndices = symbolsBySection[i];
     uint64_t sectionAddr = sectionHeaders[i].addr;
     uint32_t sectionAlign = 1u << sectionHeaders[i].align;
 
-    InputSection *lastIsec = subsecMap.back().isec;
+    InputSection *lastIsec = subsections.back().isec;
     // Record-based sections have already been split into subsections during
     // parseSections(), so we simply need to match Symbols to the corresponding
     // subsection here.
@@ -693,7 +700,8 @@
         const NList &sym = nList[symIndex];
         StringRef name = strtab + sym.n_strx;
         uint64_t symbolOffset = sym.n_value - sectionAddr;
-        InputSection *isec = findContainingSubsection(subsecMap, &symbolOffset);
+        InputSection *isec =
+            findContainingSubsection(subsections, &symbolOffset);
         if (symbolOffset != 0) {
           error(toString(lastIsec) + ":  symbol " + name +
                 " at misaligned offset");
@@ -706,19 +714,19 @@
 
     // Calculate symbol sizes and create subsections by splitting the sections
     // along symbol boundaries.
-    // We populate subsecMap by repeatedly splitting the last (highest address)
-    // subsection.
+    // We populate subsections by repeatedly splitting the last (highest
+    // address) subsection.
     llvm::stable_sort(symbolIndices, [&](uint32_t lhs, uint32_t rhs) {
       return nList[lhs].n_value < nList[rhs].n_value;
     });
-    SubsectionEntry subsecEntry = subsecMap.back();
+    Subsection subsec = subsections.back();
     for (size_t j = 0; j < symbolIndices.size(); ++j) {
       uint32_t symIndex = symbolIndices[j];
       const NList &sym = nList[symIndex];
       StringRef name = strtab + sym.n_strx;
-      InputSection *isec = subsecEntry.isec;
+      InputSection *isec = subsec.isec;
 
-      uint64_t subsecAddr = sectionAddr + subsecEntry.offset;
+      uint64_t subsecAddr = sectionAddr + subsec.offset;
       size_t symbolOffset = sym.n_value - subsecAddr;
       uint64_t symbolSize =
           j + 1 < symbolIndices.size()
@@ -758,8 +766,8 @@
       // subsection's offset from the last aligned address. We should consider
       // emulating that behavior.
       nextIsec->align = MinAlign(sectionAlign, sym.n_value);
-      subsecMap.push_back({sym.n_value - sectionAddr, nextIsec});
-      subsecEntry = subsecMap.back();
+      subsections.push_back({sym.n_value - sectionAddr, nextIsec});
+      subsec = subsections.back();
     }
   }
 
@@ -785,7 +793,8 @@
       make<ConcatInputSection>(segName.take_front(16), sectName.take_front(16),
                                /*file=*/this, data);
   isec->live = true;
-  subsections.push_back({{0, isec}});
+  sections.push_back({});
+  sections.back().subsections.push_back({0, isec});
 }
 
 ObjFile::ObjFile(MemoryBufferRef mb, uint32_t modTime, StringRef archiveName)
@@ -800,7 +809,7 @@
 template <class LP> void ObjFile::parse() {
   using Header = typename LP::mach_header;
   using SegmentCommand = typename LP::segment_command;
-  using Section = typename LP::section;
+  using SectionHeader = typename LP::section;
   using NList = typename LP::nlist;
 
   auto *buf = reinterpret_cast<const uint8_t *>(mb.getBufferStart());
@@ -826,11 +835,11 @@
     parseLCLinkerOption(this, cmd->count, data);
   }
 
-  ArrayRef<Section> sectionHeaders;
+  ArrayRef<SectionHeader> sectionHeaders;
   if (const load_command *cmd = findCommand(hdr, LP::segmentLCType)) {
     auto *c = reinterpret_cast<const SegmentCommand *>(cmd);
-    sectionHeaders =
-        ArrayRef<Section>{reinterpret_cast<const Section *>(c + 1), c->nsects};
+    sectionHeaders = ArrayRef<SectionHeader>{
+        reinterpret_cast<const SectionHeader *>(c + 1), c->nsects};
     parseSections(sectionHeaders);
   }
 
@@ -846,9 +855,10 @@
 
   // The relocations may refer to the symbols, so we parse them after we have
   // parsed all the symbols.
-  for (size_t i = 0, n = subsections.size(); i < n; ++i)
-    if (!subsections[i].empty())
-      parseRelocations(sectionHeaders, sectionHeaders[i], subsections[i]);
+  for (size_t i = 0, n = sections.size(); i < n; ++i)
+    if (!sections[i].subsections.empty())
+      parseRelocations(sectionHeaders, sectionHeaders[i],
+                       sections[i].subsections);
 
   parseDebugInfo();
   if (config->emitDataInCodeInfo)
@@ -897,20 +907,20 @@
 // Create pointers from symbols to their associated compact unwind entries.
 void ObjFile::registerCompactUnwind() {
   // First, locate the __compact_unwind section.
-  SubsectionMap *cuSubsecMap = nullptr;
-  for (SubsectionMap &map : subsections) {
-    if (map.empty())
+  Section *cuSection = nullptr;
+  for (Section &section : sections) {
+    if (section.subsections.empty())
       continue;
-    if (map[0].isec->getSegName() != segment_names::ld)
+    if (section.subsections[0].isec->getSegName() != segment_names::ld)
       continue;
-    cuSubsecMap = &map;
+    cuSection = &section;
     break;
   }
-  if (!cuSubsecMap)
+  if (!cuSection)
     return;
 
-  for (SubsectionEntry &entry : *cuSubsecMap) {
-    ConcatInputSection *isec = cast<ConcatInputSection>(entry.isec);
+  for (Subsection &subsection : cuSection->subsections) {
+    ConcatInputSection *isec = cast<ConcatInputSection>(subsection.isec);
     // Hack!! Since each CUE contains a different function address, if ICF
     // operated naively and compared the entire contents of each CUE, entries
     // with identical unwind info but belonging to different functions would
diff --git a/MachO/InputFiles.h b/MachO/InputFiles.h
index e5f12ad..2c870b7 100644
--- a/MachO/InputFiles.h
+++ b/MachO/InputFiles.h
@@ -51,11 +51,17 @@
 // If .subsections_via_symbols is set, each InputSection will be split along
 // symbol boundaries. The field offset represents the offset of the subsection
 // from the start of the original pre-split InputSection.
-struct SubsectionEntry {
-  uint64_t offset;
-  InputSection *isec;
+struct Subsection {
+  uint64_t offset = 0;
+  InputSection *isec = nullptr;
 };
-using SubsectionMap = std::vector<SubsectionEntry>;
+
+using Subsections = std::vector<Subsection>;
+
+struct Section {
+  // uint64_t address = 0; // TODO(gkm): this will debut with __eh_frame handler
+  Subsections subsections;
+};
 
 class InputFile {
 public:
@@ -75,7 +81,7 @@
   MemoryBufferRef mb;
 
   std::vector<Symbol *> symbols;
-  std::vector<SubsectionMap> subsections;
+  std::vector<Section> sections;
   // Provides an easy way to sort InputFiles deterministically.
   const int id;
 
@@ -109,16 +115,16 @@
 
 private:
   template <class LP> void parse();
-  template <class Section> void parseSections(ArrayRef<Section>);
+  template <class SectionHeader> void parseSections(ArrayRef<SectionHeader>);
   template <class LP>
   void parseSymbols(ArrayRef<typename LP::section> sectionHeaders,
                     ArrayRef<typename LP::nlist> nList, const char *strtab,
                     bool subsectionsViaSymbols);
   template <class NList>
   Symbol *parseNonSectionSymbol(const NList &sym, StringRef name);
-  template <class Section>
-  void parseRelocations(ArrayRef<Section> sectionHeaders, const Section &,
-                        SubsectionMap &);
+  template <class SectionHeader>
+  void parseRelocations(ArrayRef<SectionHeader> sectionHeaders,
+                        const SectionHeader &, Subsections &);
   void parseDebugInfo();
   void parseDataInCode();
   void registerCompactUnwind();
diff --git a/MachO/ObjC.cpp b/MachO/ObjC.cpp
index ab9aaec..3c40c5d 100644
--- a/MachO/ObjC.cpp
+++ b/MachO/ObjC.cpp
@@ -21,7 +21,7 @@
 using namespace lld::macho;
 
 template <class LP> static bool objectHasObjCSection(MemoryBufferRef mb) {
-  using Section = typename LP::section;
+  using SectionHeader = typename LP::section;
 
   auto *hdr =
       reinterpret_cast<const typename LP::mach_header *>(mb.getBufferStart());
@@ -30,12 +30,13 @@
 
   if (const auto *c =
           findCommand<typename LP::segment_command>(hdr, LP::segmentLCType)) {
-    auto sectionHeaders =
-        ArrayRef<Section>{reinterpret_cast<const Section *>(c + 1), c->nsects};
-    for (const Section &sec : sectionHeaders) {
-      StringRef sectname(sec.sectname,
-                         strnlen(sec.sectname, sizeof(sec.sectname)));
-      StringRef segname(sec.segname, strnlen(sec.segname, sizeof(sec.segname)));
+    auto sectionHeaders = ArrayRef<SectionHeader>{
+        reinterpret_cast<const SectionHeader *>(c + 1), c->nsects};
+    for (const SectionHeader &secHead : sectionHeaders) {
+      StringRef sectname(secHead.sectname,
+                         strnlen(secHead.sectname, sizeof(secHead.sectname)));
+      StringRef segname(secHead.segname,
+                        strnlen(secHead.segname, sizeof(secHead.segname)));
       if ((segname == segment_names::data &&
            sectname == section_names::objcCatList) ||
           (segname == segment_names::text &&
diff --git a/MachO/SyntheticSections.cpp b/MachO/SyntheticSections.cpp
index 8a3a4aa..2527389 100644
--- a/MachO/SyntheticSections.cpp
+++ b/MachO/SyntheticSections.cpp
@@ -734,7 +734,7 @@
 template <class LP>
 static std::vector<MachO::data_in_code_entry> collectDataInCodeEntries() {
   using SegmentCommand = typename LP::segment_command;
-  using Section = typename LP::section;
+  using SectionHeader = typename LP::section;
 
   std::vector<MachO::data_in_code_entry> dataInCodeEntries;
   for (const InputFile *inputFile : inputFiles) {
@@ -745,8 +745,8 @@
         findCommand(objFile->mb.getBufferStart(), LP::segmentLCType));
     if (!c)
       continue;
-    ArrayRef<Section> sections{reinterpret_cast<const Section *>(c + 1),
-                               c->nsects};
+    ArrayRef<SectionHeader> sectionHeaders{
+        reinterpret_cast<const SectionHeader *>(c + 1), c->nsects};
 
     ArrayRef<MachO::data_in_code_entry> entries = objFile->dataInCodeEntries;
     if (entries.empty())
@@ -754,15 +754,14 @@
     // For each code subsection find 'data in code' entries residing in it.
     // Compute the new offset values as
     // <offset within subsection> + <subsection address> - <__TEXT address>.
-    for (size_t i = 0, n = sections.size(); i < n; ++i) {
-      const SubsectionMap &subsecMap = objFile->subsections[i];
-      for (const SubsectionEntry &subsecEntry : subsecMap) {
-        const InputSection *isec = subsecEntry.isec;
+    for (size_t i = 0, n = sectionHeaders.size(); i < n; ++i) {
+      for (const Subsection &subsec : objFile->sections[i].subsections) {
+        const InputSection *isec = subsec.isec;
         if (!isCodeSection(isec))
           continue;
         if (cast<ConcatInputSection>(isec)->shouldOmitFromOutput())
           continue;
-        const uint64_t beginAddr = sections[i].addr + subsecEntry.offset;
+        const uint64_t beginAddr = sectionHeaders[i].addr + subsec.offset;
         auto it = llvm::lower_bound(
             entries, beginAddr,
             [](const MachO::data_in_code_entry &entry, uint64_t addr) {
diff --git a/MachO/Writer.cpp b/MachO/Writer.cpp
index 203a04f..093a380 100644
--- a/MachO/Writer.cpp
+++ b/MachO/Writer.cpp
@@ -227,7 +227,7 @@
 
   void writeTo(uint8_t *buf) const override {
     using SegmentCommand = typename LP::segment_command;
-    using Section = typename LP::section;
+    using SectionHeader = typename LP::section;
 
     auto *c = reinterpret_cast<SegmentCommand *>(buf);
     buf += sizeof(SegmentCommand);
@@ -248,8 +248,8 @@
       if (osec->isHidden())
         continue;
 
-      auto *sectHdr = reinterpret_cast<Section *>(buf);
-      buf += sizeof(Section);
+      auto *sectHdr = reinterpret_cast<SectionHeader *>(buf);
+      buf += sizeof(SectionHeader);
 
       memcpy(sectHdr->sectname, osec->name.data(), osec->name.size());
       memcpy(sectHdr->segname, name.data(), name.size());