summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2018-02-16 04:27:46 +0000
committerRui Ueyama <ruiu@google.com>2018-02-16 04:27:46 +0000
commit6de1e858a1cd65407475dde50bf9bd0e34e1b95e (patch)
treebd9b0866afb3d96525bfa81bd783d9523ade554b
parent015125d7ff4c72387c8ce9437c3bb6374365999b (diff)
downloadbcm5719-llvm-6de1e858a1cd65407475dde50bf9bd0e34e1b95e.tar.gz
bcm5719-llvm-6de1e858a1cd65407475dde50bf9bd0e34e1b95e.zip
Fix an issue that weak bit is dropped when there's a lazy object symbol.
Previously, we accidentally dropped STB_WEAK bit from an undefined symbol if there is a lazy object symbol with the same name. That caused a compatibility issue with GNU gold. llvm-svn: 325316
-rw-r--r--lld/ELF/SymbolTable.cpp7
-rw-r--r--lld/test/ELF/weak-undef-lib.s19
2 files changed, 24 insertions, 2 deletions
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index 01d43d28972..c270f85c5e3 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -568,9 +568,12 @@ void SymbolTable::addLazyObject(StringRef Name, LazyObjFile &Obj) {
return;
// See comment for addLazyArchive above.
- if (S->isWeak())
+ if (S->isWeak()) {
replaceSymbol<LazyObject>(S, Obj, Name, S->Type);
- else if (InputFile *F = Obj.fetch())
+ S->Binding = STB_WEAK;
+ return;
+ }
+ if (InputFile *F = Obj.fetch())
addFile<ELFT>(F);
}
diff --git a/lld/test/ELF/weak-undef-lib.s b/lld/test/ELF/weak-undef-lib.s
new file mode 100644
index 00000000000..e4e7f46ebaa
--- /dev/null
+++ b/lld/test/ELF/weak-undef-lib.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
+# RUN: echo -e '.globl foo\nfoo: ret' | \
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t2.o
+
+# RUN: ld.lld -shared -o %t.so %t1.o --start-lib %t2.o
+# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck %s
+
+# CHECK: Name: foo
+# CHECK-NEXT: Value: 0x0
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Weak
+# CHECK-NEXT: Type: None
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: Undefined
+
+.weak foo
+.data
+.quad foo
OpenPOWER on IntegriCloud