[lld] r265794 - Don't lower the visibility because of shared symbols.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 8 09:11:43 PDT 2016


Author: rafael
Date: Fri Apr  8 11:11:42 2016
New Revision: 265794

URL: http://llvm.org/viewvc/llvm-project?rev=265794&view=rev
Log:
Don't lower the visibility because of shared symbols.

If a shared library has a protected symbol 'foo', that doesn't imply
that the symbol 'foo' in the output should be protected or not.

Modified:
    lld/trunk/ELF/Symbols.cpp
    lld/trunk/test/ELF/Inputs/protected-shared.s
    lld/trunk/test/ELF/protected-shared.s

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=265794&r1=265793&r2=265794&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Fri Apr  8 11:11:42 2016
@@ -218,9 +218,11 @@ int SymbolBody::compare(SymbolBody *Othe
   if (L > R)
     return -Other->compare(this);
 
-  uint8_t V = getMinVisibility(getVisibility(), Other->getVisibility());
-  setVisibility(V);
-  Other->setVisibility(V);
+  if (!isShared() && !Other->isShared()) {
+    uint8_t V = getMinVisibility(getVisibility(), Other->getVisibility());
+    setVisibility(V);
+    Other->setVisibility(V);
+  }
 
   if (IsUsedInRegularObj || Other->IsUsedInRegularObj)
     IsUsedInRegularObj = Other->IsUsedInRegularObj = true;

Modified: lld/trunk/test/ELF/Inputs/protected-shared.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/protected-shared.s?rev=265794&r1=265793&r2=265794&view=diff
==============================================================================
--- lld/trunk/test/ELF/Inputs/protected-shared.s (original)
+++ lld/trunk/test/ELF/Inputs/protected-shared.s Fri Apr  8 11:11:42 2016
@@ -1,3 +1,7 @@
         .global foo
         .protected foo
 foo:
+
+        .global bar
+        .protected bar
+bar:

Modified: lld/trunk/test/ELF/protected-shared.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/protected-shared.s?rev=265794&r1=265793&r2=265794&view=diff
==============================================================================
--- lld/trunk/test/ELF/protected-shared.s (original)
+++ lld/trunk/test/ELF/protected-shared.s Fri Apr  8 11:11:42 2016
@@ -9,6 +9,17 @@
 _start:
         .quad foo
 
+        .global bar
+bar:
+
+// CHECK:      Name: bar
+// CHECK-NEXT: Value:
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Global
+// CHECK-NEXT: Type: None
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: .text
+
 // CHECK:      Name: foo
 // CHECK-NEXT: Value: 0x0
 // CHECK-NEXT: Size: 0




More information about the llvm-commits mailing list