cfallin opened PR #2558 from pic-symbol-refs
to main
:
The new x64 backend, up till now, was generating references to non-colocated symbols using
Abs8
relocations (i.e., place the absolute 64-bit address in a 64-bit immediate to an instruction).This works fine on Linux/x86-64, even in
.so
s as generated by Lucet, but is not actually what we want to do when theis_pic
flag is set. macOS is more strict and fails to link object files generated with theseAbs8
relocations. Instead, we need to use the GOT (global offset table).This PR changes the lowering of
func_addr
/symbol_addr
/call
with non-colocated symbols to use a PC-relative load from the GOT instead, and emits the special GOTPCRel4 relocation type. This is equivalent to (ingas
syntax) amovq symbol@GOTPCREL(%rip), %dest
instruction.
cfallin requested pchickey for a review on PR #2558.
bjorn3 submitted PR Review.
bjorn3 created PR Review Comment:
i32::min_value()?
cfallin updated PR #2558 from pic-symbol-refs
to main
:
The new x64 backend, up till now, was generating references to non-colocated symbols using
Abs8
relocations (i.e., place the absolute 64-bit address in a 64-bit immediate to an instruction).This works fine on Linux/x86-64, even in
.so
s as generated by Lucet, but is not actually what we want to do when theis_pic
flag is set. macOS is more strict and fails to link object files generated with theseAbs8
relocations. Instead, we need to use the GOT (global offset table).This PR changes the lowering of
func_addr
/symbol_addr
/call
with non-colocated symbols to use a PC-relative load from the GOT instead, and emits the special GOTPCRel4 relocation type. This is equivalent to (ingas
syntax) amovq symbol@GOTPCREL(%rip), %dest
instruction.
cfallin submitted PR Review.
cfallin created PR Review Comment:
Done -- actually -i32::MAX is more clear (since it's a positive i32 passed as an immediate to
sub
).
pchickey submitted PR Review.
cfallin merged PR #2558.
Last updated: Nov 22 2024 at 16:03 UTC