diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2018-01-17 19:19:55 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2018-01-17 19:19:55 +0000 |
commit | d7008692355f5029ffc6360d25574e65613d63af (patch) | |
tree | 40146b40e778d6de16c1718d88ffe7556c4750bb /llvm/lib/Target/TargetMachine.cpp | |
parent | bbcaf4ac5caadf71593cdd1bee8d0697ac190aaf (diff) | |
download | bcm5719-llvm-d7008692355f5029ffc6360d25574e65613d63af.tar.gz bcm5719-llvm-d7008692355f5029ffc6360d25574e65613d63af.zip |
Use a got to access a hidden weak undefined on MachO.
Trying to link
__attribute__((weak, visibility("hidden"))) extern int foo;
int *main(void) {
return &foo;
}
on OS X fails with
ld: 32-bit RIP relative reference out of range (-4294971318 max is +/-2GB): from _main (0x100000FAB) to _foo@0x00001000 (0x00000000) in '_main' from test.o for architecture x86_64
The problem being that 0 cannot be computed as a fixed difference from
%rip. Exactly the same issue exists on ELF and we can use the same
solution.
llvm-svn: 322739
Diffstat (limited to 'llvm/lib/Target/TargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/TargetMachine.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 8e3a818690f..ee5b010ecf2 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -141,9 +141,7 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M, // produce a 0 if it turns out the symbol is undefined. While this // is ABI and relocation depended, it seems worth it to handle it // here. - // FIXME: this is probably not ELF specific. - if (GV && isPositionIndependent() && TT.isOSBinFormatELF() && - GV->hasExternalWeakLinkage()) + if (GV && isPositionIndependent() && GV->hasExternalWeakLinkage()) return false; if (GV && !GV->hasDefaultVisibility()) |