summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/OutputSections.cpp2
-rw-r--r--lld/test/ELF/relocatable-visibility.s19
2 files changed, 21 insertions, 0 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 139e67505c7..972457ae43a 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -1316,6 +1316,8 @@ static bool sortMipsSymbols(const std::pair<SymbolBody *, unsigned> &L,
static uint8_t getSymbolBinding(SymbolBody *Body) {
Symbol *S = Body->symbol();
+ if (Config->Relocatable)
+ return S->Binding;
uint8_t Visibility = S->Visibility;
if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED)
return STB_LOCAL;
diff --git a/lld/test/ELF/relocatable-visibility.s b/lld/test/ELF/relocatable-visibility.s
new file mode 100644
index 00000000000..7cc7da3097b
--- /dev/null
+++ b/lld/test/ELF/relocatable-visibility.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld -r %t.o -o %t1
+# RUN: llvm-readobj -t %t1 | FileCheck --check-prefix=RELOCATABLE %s
+
+# RELOCATABLE: Name: foo
+# RELOCATABLE-NEXT: Value: 0x0
+# RELOCATABLE-NEXT: Size: 0
+# RELOCATABLE-NEXT: Binding: Global
+# RELOCATABLE-NEXT: Type: None
+# RELOCATABLE-NEXT: Other [
+# RELOCATABLE-NEXT: STV_HIDDEN
+# RELOCATABLE-NEXT: ]
+# RELOCATABLE-NEXT: Section: Undefined
+
+.global _start
+_start:
+ callq foo
+ .hidden foo
OpenPOWER on IntegriCloud