[PATCH] D18743: [ELF] - Do not handle ELF and program header as dummy sections

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 23:28:49 PDT 2016


grimar added inline comments.

================
Comment at: ELF/Writer.cpp:103
@@ -105,10 +102,3 @@
   std::vector<std::unique_ptr<OutputSectionBase<ELFT>>> OwningSections;
-
-  // We create a section for the ELF header and one for the program headers.
-  ArrayRef<OutputSectionBase<ELFT> *> getSections() const {
-    return makeArrayRef(OutputSections).slice(dummySectionsNum());
-  }
-  unsigned getNumSections() const {
-    return OutputSections.size() + 1 - dummySectionsNum();
-  }
+  unsigned getNumSections() const { return OutputSections.size() + 1; }
 
----------------
ruiu wrote:
> It's a bit weird to count the first null entry of the section table as a section. You can just remove this function, no?
Removed, but there was 2 places where it was called, I put (OutputSections.size() + 1) there instead:

```
  EHdr->e_shnum = OutputSections.size() + 1;
```

```
  FileSize = SectionHeaderOff + (OutputSections.size() + 1) * sizeof(Elf_Shdr);
```


http://reviews.llvm.org/D18743





More information about the llvm-commits mailing list