Don't produce a duplicated __wrap_foo if there is no __real_foo.
authorRafael Espindola <rafael.espindola@gmail.com>
Sat, 11 Nov 2017 00:53:52 +0000 (00:53 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sat, 11 Nov 2017 00:53:52 +0000 (00:53 +0000)
This fixes a regression from r317426.

llvm-svn: 317956

lld/ELF/SymbolTable.cpp
lld/test/ELF/wrap-no-real.s

index c0666fb..3757fe8 100644 (file)
@@ -196,11 +196,11 @@ void SymbolTable::applySymbolWrap() {
     W.Sym->copyFrom(W.Wrap);
     W.Sym->Binding = W.SymBinding;
 
-    if (Real) {
-      // We now have two copies of __wrap_sym. Drop one.
-      W.Wrap->IsUsedInRegularObj = false;
+    // We now have two copies of __wrap_sym. Drop one.
+    W.Wrap->IsUsedInRegularObj = false;
+
+    if (Real)
       SymVector.push_back(Real);
-    }
   }
 }
 
index 27de3f3..100efa6 100644 (file)
 // CHECK-NEXT: movl $0x11000, %edx
 
 // RUN: llvm-readobj -t %t | FileCheck -check-prefix=SYM %s
-// SYM-NOT:  Name: __real_foo
-// SYM:      Name: foo
-// SYM-NEXT: Value: 0x11000
-// SYM-NOT:  Name: __real_foo
-// SYM:      Name: __wrap_foo
-// SYM-NEXT: Value: 0x11010
-// SYM-NOT:  Name: __real_foo
+
+// Test the full symbol table. It is verbose, but lld at times
+// produced duplicated symbols which are hard to test otherwise.
+
+// SYM:       Symbols [
+// SYM-NEXT:    Symbol {
+// SYM-NEXT:     Name:  (0)
+// SYM-NEXT:     Value:
+// SYM-NEXT:     Size:
+// SYM-NEXT:     Binding:
+// SYM-NEXT:     Type
+// SYM-NEXT:     Other:
+// SYM-NEXT:     Section:
+// SYM-NEXT:   }
+// SYM-NEXT:   Symbol {
+// SYM-NEXT:     Name: _DYNAMIC
+// SYM-NEXT:     Value:
+// SYM-NEXT:     Size:
+// SYM-NEXT:     Binding:
+// SYM-NEXT:     Type:
+// SYM-NEXT:     Other [
+// SYM-NEXT:       STV_HIDDEN
+// SYM-NEXT:     ]
+// SYM-NEXT:     Section: .dynamic
+// SYM-NEXT:   }
+// SYM-NEXT:   Symbol {
+// SYM-NEXT:     Name: foo
+// SYM-NEXT:     Value: 0x11000
+// SYM-NEXT:     Size:
+// SYM-NEXT:     Binding:
+// SYM-NEXT:     Type:
+// SYM-NEXT:     Other:
+// SYM-NEXT:     Section:
+// SYM-NEXT:   }
+// SYM-NEXT:   Symbol {
+// SYM-NEXT:     Name: _start
+// SYM-NEXT:     Value:
+// SYM-NEXT:     Size:
+// SYM-NEXT:     Binding:
+// SYM-NEXT:     Type
+// SYM-NEXT:     Other:
+// SYM-NEXT:     Section:
+// SYM-NEXT:   }
+// SYM-NEXT:   Symbol {
+// SYM-NEXT:     Name: __wrap_foo
+// SYM-NEXT:     Value: 0x11010
+// SYM-NEXT:     Size:
+// SYM-NEXT:     Binding:
+// SYM-NEXT:     Type:
+// SYM-NEXT:     Other:
+// SYM-NEXT:     Section:
+// SYM-NEXT:   }
+// SYM-NEXT: ]
 
 .global _start
 _start: