Skip to content

Commit

Permalink
aarch64, Darwin: Constrain page offset values to fit in the relocation.
Browse files Browse the repository at this point in the history
This fixes issue #52.

We need to constrain the offsets in the @PAGE/@PAGEOFFS relocations
to fit in a 24bit field - +/- 8Mb.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/
	* config/aarch64/aarch64.c
	(aarch64_load_symref_appropriately): If the offset will not fit
	into the relocation, then rewrite it as an addition.
  • Loading branch information
iains committed Mar 12, 2022
1 parent b6ee63f commit 7d72fb6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gcc/config/aarch64/aarch64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3982,15 +3982,15 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm,
rtx sym, off;
split_const (imm, &sym, &off);
/* Negative offsets don't work, whether by intention is TBD. */
if (INTVAL (off) < 0)
if (INTVAL (off) < 0 || INTVAL (off) > 8 * 1024 * 1024)
{
emit_move_insn (tmp_reg, gen_rtx_HIGH (mode, sym));
emit_insn (gen_add_losym (dest, tmp_reg, sym));
/* FIXME: add the SI option if/when we support ilp32. */
emit_insn (gen_adddi3 (dest, dest, off));
return;
}
/* else positive offset is OK. */
/* else small enough positive offset is OK. */
}
emit_move_insn (tmp_reg, gen_rtx_HIGH (mode, imm));
emit_insn (gen_add_losym (dest, tmp_reg, imm));
Expand Down

0 comments on commit 7d72fb6

Please sign in to comment.