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
Abs8relocations (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
.sos as generated by Lucet, but is not actually what we want to do when theis_picflag is set. macOS is more strict and fails to link object files generated with theseAbs8relocations. Instead, we need to use the GOT (global offset table).This PR changes the lowering of
func_addr/symbol_addr/callwith non-colocated symbols to use a PC-relative load from the GOT instead, and emits the special GOTPCRel4 relocation type. This is equivalent to (ingassyntax) amovq symbol@GOTPCREL(%rip), %destinstruction.
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
Abs8relocations (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
.sos as generated by Lucet, but is not actually what we want to do when theis_picflag is set. macOS is more strict and fails to link object files generated with theseAbs8relocations. Instead, we need to use the GOT (global offset table).This PR changes the lowering of
func_addr/symbol_addr/callwith non-colocated symbols to use a PC-relative load from the GOT instead, and emits the special GOTPCRel4 relocation type. This is equivalent to (ingassyntax) amovq symbol@GOTPCREL(%rip), %destinstruction.
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: Dec 13 2025 at 21:03 UTC