[PATCH] D41551: [ELF] - Allow relocation to a weak undefined symbol when -z notext is given.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 26 02:48:03 PST 2017
grimar added a comment.
Ok, I think GNU linkers do correct thing. We also should produce the relocation for week undefined when building shared library.
Imagine next code:
dso.c:
extern __attribute__((visibility("default"), weak)) unsigned long long foo();
unsigned long long func() {
return &foo;
}
unsigned long long run() {
return func();
}
main.c:
unsigned long long run();
unsigned long long foo() {
return 1;
}
int main() {
return run() > 0 ? 1 : 0;
}
If we do not produce the relocation for week undefined `foo` when linkind DSO, code would work incorrectly:
~/LLVM/build/bin/clang -o dso dso.c -shared -fuse-ld=lld -O0 -z notext
~/LLVM/build/bin/clang -o main main.c dso -fuse-ld=lld -O0
./main
echo $?
0
Output should be 1.
I'll update the patch and testcase.
https://reviews.llvm.org/D41551
More information about the llvm-commits
mailing list