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

Daniel Hoekwater via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 14 15:52:13 PDT 2023


dhoekwater added a comment.

In D152841#4419129 <https://reviews.llvm.org/D152841#4419129>, @efriedma wrote:

> Funny side-note, while experimenting, I found that we don't emit an error if the distance is greater than 4GB.  Probably accidentally truncating an offset somewhere.

I actually did consider adding a check to ADRP to ensure the distance isn't greater than 4GB (because it only has 21 offset bits to encode the page), but I couldn't quite figure out how to expose that behavior here. Should I add the check? If so, what triple do I have to use to get this function to be called for ADRP fixups?

In In D152841#4419087 <https://reviews.llvm.org/D152841#4419087>, @MaskRay wrote:

> `  adr x0, adr1-8`

I didn't realize that adding an offset to the destination label like that was valid assembly. In that case, let's not emit any `.space`s at all and just use custom offsets. I'll push an updated change in a little bit.

  # CHECK: [[#@LINE+1]]:3: error: fixup value out of range
  adr_self:
    adr x0, adr_self-(1<<20)-1


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