[lld] Trace all references with lld --trace-symbol

Previously undefined symbol references were only traced if they were
seen before that definition.

Fixes https://bugs.llvm.org/show_bug.cgi?id=41878

Differential Revision: https://reviews.llvm.org/D61929

llvm-svn: 361636
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index d44b24d..45c545d 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -291,7 +291,7 @@
 }
 
 // Print out a log message for --trace-symbol.
-void elf::printTraceSymbol(Symbol *Sym) {
+void elf::printTraceSymbol(const Symbol *Sym) {
   std::string S;
   if (Sym->isUndefined())
     S = ": reference to ";
@@ -413,6 +413,9 @@
     return;
   }
 
+  if (Traced)
+    printTraceSymbol(&Other);
+
   if (isShared() || isLazy() || (isUndefined() && Other.Binding != STB_WEAK))
     Binding = Other.Binding;