-fPIC produces un-share-able X86_64 relocations
Summary
x86_64 (cross)compiler with -fPIC
produces R_X86_64_PC32
relocations that don't work for ld -shared
.
That's required on the Haiku platform: executables must be linked with -shared. I know nothing about this, but ...
- only some
R_X86_64_PC32
relocations fail, while others that appear in objdump -r output seem to be normal. - some of the offending symbols appear in assembler output:
leaq base_DataziTuple_swap_closure(%rip),%rbx
- the working native C compiler writes this to load a function address, producing an acceptable
R_X86_64_REX_GOTPCRELX
relocation:movq testfunction@GOTPCREL(%rip), %rax
movq %rax, %rdi
Steps to reproduce
link compiled files with features like base_DataziTuple_swap_closure
, on ELF platform, with collect2
/ld -shared
option.
Expected behavior
ld: Tuple.o: relocation R_X86_64_PC32 against symbol `base_DataziTuple_swap_closure' can not be used when making a shared object; recompile with -fPIC
ld: final link failed: bad value
8.6.3 stage1 cross compiler, built and running on i386; as far as I'm able to get 8.8.1, it generates the same code, so I expect it to have the same problem if I can compile it.
Environment
- GHC version used: 8.6.3
Optional:
- Operating System: Haiku
- System Architecture: i386 / x86_64
Edited by Ben Gamari