[PATCH] D13345: [ELF2] Add --undefined option

Denis Protivensky via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 08:18:17 PDT 2015


denis-protivensky added inline comments.

================
Comment at: ELF/SymbolTable.cpp:83
@@ +82,3 @@
+  auto Sym =
+      new (Alloc) Undefined<ELFT>(Name, Undefined<ELFT>::SyntheticOptional);
+  resolve<ELFT>(Sym);
----------------
ruiu wrote:
> Why optional? All symbols specified with -u must be resolved, no?
As I understand, the doc says it shouldn't make linking process degrade, I mean, it shouldn't cause link errors if some of these undefined symbols are not resolved. The only purpose of this is to trigger adding of object files from archives if they contain symbols specified.
These symbols technically don't have any logical impact on binary, so with these left undefined there won't be any changes in runtime behavior since these undefines are not used by any code.

================
Comment at: ELF/Symbols.h:250-263
@@ -247,4 +249,16 @@
 
+namespace {
+template <class ELFT>
+static typename llvm::object::ELFFile<ELFT>::Elf_Sym initGlobalSym() {
+  typename llvm::object::ELFFile<ELFT>::Elf_Sym Sym;
+  Sym.setBinding(llvm::ELF::STB_GLOBAL);
+  return Sym;
+}
+}
+
+template <class ELFT>
+typename Undefined<ELFT>::Elf_Sym Undefined<ELFT>::SyntheticRequired;
 template <class ELFT>
-typename Undefined<ELFT>::Elf_Sym Undefined<ELFT>::Synthetic;
+typename Undefined<ELFT>::Elf_Sym
+    Undefined<ELFT>::SyntheticOptional = initGlobalSym<ELFT>();
 
----------------
ruiu wrote:
> This seems overkill because I don't think we are going to allocate a lot of Synthetic Undefined symbols. Can you simply make these static fields non-static? It's going to allocate a Elf_Sym per Undefined, but that wouldn't really affect anything to performance.
Good.


http://reviews.llvm.org/D13345





More information about the llvm-commits mailing list