[PATCH] D18743: [ELF] - Do not handle ELF and program header as dummy sections
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 3 13:42:50 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:
> Why +1?
Because we have one "dummy-zero" section:
```
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
```
================
Comment at: ELF/Writer.cpp:1346
@@ -1357,1 +1345,3 @@
+template <class ELFT> void Writer<ELFT>::fixHeaders() {
+ uintX_t Off = 0;
----------------
ruiu wrote:
> This function needs a comment.
Done.
================
Comment at: ELF/Writer.cpp:1347-1349
@@ +1346,5 @@
+template <class ELFT> void Writer<ELFT>::fixHeaders() {
+ uintX_t Off = 0;
+ Out<ELFT>::ElfHeader->setVA(Off + Target->getVAStart());
+ Out<ELFT>::ElfHeader->setFileOffset(Off);
+ Off += Out<ELFT>::ElfHeader->getSize();
----------------
ruiu wrote:
> "Off" is always zero, so please do this.
>
> Out<ELFT>::ElfHeader->setVA(Target->getVAStart());
> Out<ELFT>::ElfHeader->setFileOffset(0);
Done.
http://reviews.llvm.org/D18743
More information about the llvm-commits
mailing list