[PATCH] [lld][ELF] Fix non SHF_ALLOC sections.

Shankar Kalpathi Easwaran shankarke at gmail.com
Wed Sep 18 14:14:48 PDT 2013


  Other than the below comments, LGTM.


================
Comment at: lib/ReaderWriter/ELF/Atoms.h:309-312
@@ -305,2 +308,6 @@
     case llvm::ELF::SHT_PROGBITS:
+      if (!(flags & llvm::ELF::SHF_ALLOC)) {
+        ret = typeNoAlloc;
+        break;
+      }
       flags &= ~llvm::ELF::SHF_ALLOC;
----------------
isnt this already handled lines (288-290) ?

================
Comment at: lib/ReaderWriter/ELF/DefaultLayout.h:829-835
@@ -825,2 +828,9 @@
     si->setVAddr(0);
+    if (section) {
+      section->assignOffsets(fileoffset);
+      if (auto as = dyn_cast<AtomSection<ELFT>>(section)) {
+        uint64_t addr = -fileoffset;
+        section->assignVirtualAddress(addr);
+      }
+    }
     fileoffset += si->fileSize();
----------------
I will clean this up after this patch is submitted, so that assignVirtualAddress/assignFileOffsets would take care of NonAlloc sections in the input.

================
Comment at: lib/ReaderWriter/ELF/DefaultLayout.h:832
@@ +831,3 @@
+      if (auto as = dyn_cast<AtomSection<ELFT>>(section)) {
+        uint64_t addr = -fileoffset;
+        section->assignVirtualAddress(addr);
----------------
Why is addr set to -fileoffset ?

================
Comment at: lib/ReaderWriter/ELF/OutputELFWriter.h:344-346
@@ -346,2 +343,5 @@
 
+  // Build the Atom To Address map for applying relocations
+  buildAtomToAddressMap(file);
+
   return error_code::success();
----------------
this would essentially move up after the cleanup that I plan to do.


http://llvm-reviews.chandlerc.com/D1680



More information about the llvm-commits mailing list