[PATCH] [lld][ELF] add undefined atoms from dynamic library

Michael Spencer bigcheesegs at gmail.com
Tue Apr 9 11:54:47 PDT 2013



================
Comment at: lib/ReaderWriter/ELF/DynamicFile.h:57-78
@@ -58,9 +56,24 @@
       StringRef name;
-      if (error_code ec =
-              obj.getSymbolName(obj.getDynamicSymbolTableSectionHeader(), &*i,
-                                name))
-        return ec;
-      file->_nameToSym[name]._symbol = &*i;
-
-      // TODO: Read undefined dynamic symbols into _undefinedAtoms.
+      const Elf_Sym *symbol = &*i;
+      if ((EC = obj.getSymbolName(obj.getDynamicSymbolTableSectionHeader(), &*i,
+                                  name)))
+        return;
+      if (symbol->st_shndx == llvm::ELF::SHN_ABS) {
+        // TODO : create absolute atoms
+        // need a change in the SymbolTable functionality to override absolute
+        // atoms properly
+        // Create an absolute atom.
+        // auto *newAtom = new (_alloc)
+        //      ELFAbsoluteAtom<ELFT>(*this, name, symbol, symbol->st_value);
+        // _absoluteAtoms._atoms.push_back(newAtom);
+      } else if ((symbol->st_shndx == llvm::ELF::SHN_UNDEF)) {
+        // Create an undefined atom.
+        if (!name.empty()) {
+          auto *newAtom =
+              new (_alloc) ELFUndefinedAtom<ELFT>(*this, name, symbol);
+          _undefinedAtoms._atoms.push_back(newAtom);
+        }
+      } else {
+        _nameToSym[name]._symbol = symbol;
+      }
     }
----------------
This and the tests are the only part of this patch that are needed.


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



More information about the llvm-commits mailing list