[PATCH] D71795: [ELF] Delete an unused special rule from isStaticLinkTimeConstant. NFC
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 17:18:25 PST 2020
pcc added a comment.
> Weak undefined symbols are preemptible after D71794 <https://reviews.llvm.org/D71794>.
What about hidden weak undefined symbols? We now reject the following input:
cat foo.cpp
__attribute__((weak, visibility("hidden"))) void f();
void g() {
if (f) f();
}
$ clang -shared -fuse-ld=lld foo.cpp
ld.lld: error: relocation R_X86_64_PLT32 cannot refer to absolute symbol: f()
>>> defined in /tmp/foo-014d89.o
>>> referenced by foo.cpp
>>> /tmp/foo-014d89.o:(g())
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This seems like a reasonable thing to want to do. I actually hit this problem in a slightly different case (`--exclude-libs` demoted the weak undef to hidden) which we could fix like so:
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 19598f52cd4..54c033303f6 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1374,7 +1374,7 @@ static void excludeLibs(opt::InputArgList &args) {
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;
};
But I'm somewhat more concerned about the explicit hidden case.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71795/new/
https://reviews.llvm.org/D71795
More information about the llvm-commits
mailing list