Previously we failed to resolve them:
"relocation R_X86_64_32 cannot be used against shared object; recompile with -fPIC"
This finishes fixing PR35720.
Differential D41551
[ELF] - Allow relocation to a weak undefined symbol when -z notext is given. grimar on Dec 23 2017, 3:31 AM. Authored by
Details
Previously we failed to resolve them: This finishes fixing PR35720.
Diff Detail Event TimelineComment Actions This LGTM, I had a similar change in my repo while trying to fix PR35720.
Comment Actions That testcase looks close to what this patch trying to fix. It contains weak undef. It seems to me we should fix that testcase as well. I'll rebase this patch now. Comment Actions Ah no. Actually gold and bfd of v2.29.51.20171006 produce relocation when -shared is given (I tested without). And do not produce it for executable. Comment Actions Ok, I think GNU linkers do correct thing. We also should produce the relocation for week undefined when building shared library. 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. Comment Actions The original FreeBSD test case (a 'hello world' linked with lld -znotext) works with this change applied.
|
minor nit, "and we are producing an executable"