[lld] r174091 - [ELF] Create atoms for progbits sections with no symbols but still have content.

Michael J. Spencer bigcheesegs at gmail.com
Thu Jan 31 13:00:43 PST 2013


Author: mspencer
Date: Thu Jan 31 15:00:42 2013
New Revision: 174091

URL: http://llvm.org/viewvc/llvm-project?rev=174091&view=rev
Log:
[ELF] Create atoms for progbits sections with no symbols but still have content.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/File.h

Modified: lld/trunk/lib/ReaderWriter/ELF/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/File.h?rev=174091&r1=174090&r2=174091&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/File.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/File.h Thu Jan 31 15:00:42 2013
@@ -87,6 +87,10 @@ public:
 
       const Elf_Shdr *section = _objFile->getElfSection(sit);
 
+      // Create a sectionSymbols entry for every progbits section.
+      if (section->sh_type == llvm::ELF::SHT_PROGBITS)
+        sectionSymbols[section];
+
       if (section->sh_type == llvm::ELF::SHT_RELA) {
         StringRef sectionName;
         if ((EC = _objFile->getSectionName(section, sectionName)))
@@ -190,6 +194,24 @@ public:
       if ((EC = _objFile->getSectionName(i.first, sectionName)))
         return;
 
+      // If the section has no symbols, create a custom atom for it.
+      if (i.first->sh_type == llvm::ELF::SHT_PROGBITS && symbols.empty() &&
+          !sectionContents.empty()) {
+        Elf_Sym *sym = new (_readerStorage) Elf_Sym;
+        sym->st_name = 0;
+        sym->setBindingAndType(llvm::ELF::STB_LOCAL, llvm::ELF::STT_SECTION);
+        sym->st_other = 0;
+        sym->st_shndx = 0;
+        sym->st_value = 0;
+        sym->st_size = 0;
+        ArrayRef<uint8_t> content((const uint8_t *)sectionContents.data(),
+                                  sectionContents.size());
+        _definedAtoms._atoms.push_back(
+            new (_readerStorage)
+            ELFDefinedAtom<ELFT>(*this, sectionName, sectionName, sym, i.first,
+                                 content, 0, 0, _references));
+      }
+
       // i.first is the section the symbol lives in
       for (auto si = symbols.begin(), se = symbols.end(); si != se; ++si) {
         StringRef symbolName;





More information about the llvm-commits mailing list