[PATCH] D72681: [ELF] --exclude-libs: don't assign VER_NDX_LOCAL to undefined symbols
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 01:23:14 PST 2020
MaskRay updated this revision to Diff 237877.
MaskRay added a comment.
Add comment
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72681/new/
https://reviews.llvm.org/D72681
Files:
lld/ELF/Driver.cpp
lld/test/ELF/exclude-libs-undef.s
Index: lld/test/ELF/exclude-libs-undef.s
===================================================================
--- /dev/null
+++ lld/test/ELF/exclude-libs-undef.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+## Test we don't assign VER_NDX_LOCAL to an undefined symbol.
+## If we does, an undefined weak will become non-preemptible,
+## and we will report an error when an R_PLT_PC (optimized to R_PC)
+## references the undefined weak (considered absolute).
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+# RUN: rm -f %t.a
+# RUN: llvm-ar rc %t.a %t.o
+# RUN: ld.lld -shared --whole-archive --exclude-libs=ALL %t.a -o %t.so
+# RUN: llvm-readelf --dyn-syms %t.so | FileCheck %s
+
+# CHECK: 1: {{.*}} WEAK DEFAULT UND bar
+# CHECK-NOT: 2:
+
+.globl foo
+.weak bar
+foo:
+ call bar
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -1375,7 +1375,7 @@
if (!file->archiveName.empty())
if (all || libs.count(path::filename(file->archiveName)))
for (Symbol *sym : file->getSymbols())
- if (!sym->isLocal() && sym->file == file)
+ if (!sym->isUndefined() && !sym->isLocal() && sym->file == file)
sym->versionId = VER_NDX_LOCAL;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72681.237877.patch
Type: text/x-patch
Size: 1279 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200114/453be287/attachment.bin>
More information about the llvm-commits
mailing list