[PATCH] D11612: [lld][ELF2] Apply relocations.

Rui Ueyama ruiu at google.com
Wed Jul 29 16:19:57 PDT 2015


ruiu accepted this revision.
ruiu added a comment.
This revision is now accepted and ready to land.

I kind of like the original approach to teach Chunks how to apply
relocations to themselves. It looks more modular and easy to use
(the writer has to just tell Chunks to "write to here" and everything
including applying relocations is done in one shot).

For COFF, we iterate the relocation table three times for dead-
stripping, applying relocations, and construct COFF base relocation
table. Iterating over a relocation table is not slow -- it's fast enough
to make me think to keep the three things separated. I'd keep them
separated in this file too.


================
Comment at: ELF/Chunks.cpp:21-22
@@ -19,3 +20,4 @@
 template <class ELFT>
-SectionChunk<ELFT>::SectionChunk(object::ELFFile<ELFT> *Obj,
+SectionChunk<ELFT>::SectionChunk(ObjectFile<ELFT> *F,
                                  const Elf_Shdr *Header)
+    : Chunk(SectionKind), File(F), Header(Header) {
----------------
May fit in 80 cols?

================
Comment at: ELF/InputFiles.cpp:48
@@ -40,2 +47,3 @@
   }
+  std::stable_sort(RelocMap.begin(), RelocMap.end());
 }
----------------
Does this have to be std::stable_sort? std::sort doesn't work?

================
Comment at: ELF/Symbols.h:90
@@ -86,1 +89,3 @@
   }
+  // Returns the Virtual Address of this symbol.
+  uint64_t getVA() const;
----------------
Add a blank line.

================
Comment at: ELF/Writer.h:54
@@ -53,2 +53,3 @@
   void assignAddresses();
+  void applyRelocations();
   void openFile(StringRef OutputPath);
----------------
These functions are sorted in the same order as they are called. So move this after writeSections (and move writeHeader below writeSections.)


http://reviews.llvm.org/D11612







More information about the llvm-commits mailing list