[lld] r230218 - [ELF] Add comments in the ELF reader

Shankar Easwaran shankare at codeaurora.org
Mon Feb 23 05:25:44 PST 2015


Author: shankare
Date: Mon Feb 23 07:25:44 2015
New Revision: 230218

URL: http://llvm.org/viewvc/llvm-project?rev=230218&view=rev
Log:
[ELF] Add comments in the ELF reader

Address review comments from Ruiu, and add some more TODO's.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/Atoms.h
    lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
    lld/trunk/lib/ReaderWriter/ELF/TODO.txt

Modified: lld/trunk/lib/ReaderWriter/ELF/Atoms.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Atoms.h?rev=230218&r1=230217&r2=230218&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Atoms.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Atoms.h Mon Feb 23 07:25:44 2015
@@ -74,6 +74,8 @@ public:
 
   void setTarget(const Atom *newAtom) override { _target = newAtom; }
 
+  /// Is used for lookup the symbol or section that refers is in the same group
+  /// or not in a group.
   const Elf_Sym *symbol() const { return _sym; }
 
 private:

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=230218&r1=230217&r2=230218&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Mon Feb 23 07:25:44 2015
@@ -180,13 +180,13 @@ public:
       return targetAtom;
     if (!redirectReferenceUsingUndefAtom(sourceSymbol, targetSymbol))
       return targetAtom;
-    auto undefForGroupchild = _undefAtomsForgroupChild.find(targetSymbolName);
-    if (undefForGroupchild != _undefAtomsForgroupChild.end())
+    auto undefForGroupchild = _undefAtomsForGroupChild.find(targetSymbolName);
+    if (undefForGroupchild != _undefAtomsForGroupChild.end())
       return undefForGroupchild->getValue();
     auto undefGroupChildAtom =
         new (_readerStorage) SimpleUndefinedAtom(*this, targetSymbolName);
     _undefinedAtoms._atoms.push_back(undefGroupChildAtom);
-    return (_undefAtomsForgroupChild[targetSymbolName] = undefGroupChildAtom);
+    return (_undefAtomsForGroupChild[targetSymbolName] = undefGroupChildAtom);
   }
 
 protected:
@@ -318,7 +318,7 @@ protected:
 
   /// Returns true if the section is a gnulinkonce section.
   bool isGnuLinkOnceSection(StringRef sectionName) const {
-    return sectionName.startswith(".gnu.linkonce");
+    return sectionName.startswith(".gnu.linkonce.");
   }
 
   /// Returns true if the section is a COMDAT group section.
@@ -378,6 +378,12 @@ protected:
     return mergeAtom;
   }
 
+  /// References to the sections comprising a group, from sections
+  /// outside the group, must be made via global UNDEF symbols,
+  /// referencing global symbols defined as addresses in the group
+  /// sections. They may not reference local symbols for addresses in
+  /// the group's sections, including section symbols.
+  /// ABI Doc : https://mentorembedded.github.io/cxx-abi/abi/prop-72-comdat.html
   /// Does the atom need to be redirected using a separate undefined atom ?
   bool redirectReferenceUsingUndefAtom(const Elf_Sym *sourceSymbol,
                                        const Elf_Sym *targetSymbol) const;
@@ -403,7 +409,7 @@ protected:
   // section header of the section that was used for generating the signature.
   llvm::DenseMap<const Elf_Sym *, std::pair<StringRef, const Elf_Shdr *>>
       _groupChild;
-  llvm::StringMap<Atom *> _undefAtomsForgroupChild;
+  llvm::StringMap<Atom *> _undefAtomsForGroupChild;
 
   /// \brief Atoms that are created for a section that has the merge property
   /// set
@@ -891,6 +897,7 @@ std::error_code ELFFile<ELFT>::handleGnu
     StringRef signature,
     llvm::StringMap<std::vector<ELFDefinedAtom<ELFT> *>> &atomsForSection,
     const Elf_Shdr *shdr) {
+  // TODO: Check for errors.
   unsigned int referenceStart = _references.size();
   std::vector<ELFReference<ELFT> *> refs;
   for (auto ha : atomsForSection[signature]) {
@@ -918,6 +925,7 @@ std::error_code ELFFile<ELFT>::handleSec
     llvm::StringMap<std::vector<ELFDefinedAtom<ELFT> *>> &atomsForSection,
     llvm::DenseMap<const Elf_Shdr *, std::vector<StringRef>> &comdatSections,
     const Elf_Shdr *shdr) {
+  // TODO: Check for errors.
   unsigned int referenceStart = _references.size();
   std::vector<ELFReference<ELFT> *> refs;
   auto sectionNamesInGroup = comdatSections[shdr];

Modified: lld/trunk/lib/ReaderWriter/ELF/TODO.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/TODO.txt?rev=230218&r1=230217&r2=230218&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/TODO.txt (original)
+++ lld/trunk/lib/ReaderWriter/ELF/TODO.txt Mon Feb 23 07:25:44 2015
@@ -12,6 +12,7 @@ lib/ReaderWriter/ELF
 
 - Weak references to symbols defined in a DSO should remain weak.
 
-- Section Groups.
-
 - Fix section flags as they appear in input (update content permissions)
+
+- Check for errors in the ELFReader when creating atoms for LinkOnce
+  sections/Group sections. Add tests to account for the change when it happens.





More information about the llvm-commits mailing list