[PATCH] D152841: Prevent out of range fixup encoding on AArch64

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 15 16:55:10 PDT 2023


efriedma added a comment.

In D152841#4426366 <https://reviews.llvm.org/D152841#4426366>, @dhoekwater wrote:

> In D152841#4423980 <https://reviews.llvm.org/D152841#4423980>, @efriedma wrote:
>
>> I saw the 4GB issue with other relocations.  Actually, I didn't even try adrp.  I don't think we ever use this codepath for adrp.
>
> Oh, interesting! I can't recreate that behavior by manually setting large offsets in this test. What assembly did you use to expose that?



  printf ".Lfoo:\n.space (1<<32)\ntbz x0, #1, .Lfoo\n" | llvm-mc -triple=aarch64 -filetype=obj -o  /dev/null



> We do use this codepath for adrp, but I guess only on Windows. `case AArch64::fixup_aarch64_pcrel_adrp_imm21` handles the fixup, and it's tested in `llvm/test/MC/AArch64/fixup-out-of-range.s`.

Oh, right; in that case, the offset isn't the offset relative to the instruction; it's the offset relative to the specified symbol, which needs to be encoded in a 21-bit field.  On ELF, we can encode arbitrary offsets (it'll just fail to link if the resolved address isn't close enough).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152841/new/

https://reviews.llvm.org/D152841



More information about the llvm-commits mailing list