[PATCH] D35544: [COFF, ARM64] Force ADRP relocations

Tim Northover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 15:28:16 PDT 2017


t.p.northover added a comment.

> So it seems to me like it actually does use ADRP, but probably via some other codepath, since it does generate a relocation. But fixing it for handwritten assembly obviously also is worthwhile.

MachO always splits up the __text section by its global symbols (sorry, I realise I was a bit vague earlier), so it emits a relocation for those reasons. You'd need to convince LLVM to use ADRP for something in the same function to see the effect. I'm not aware of any LLVM or C code that would do that (aside from inline asm, of course).

> Actually, when I try to move the function from ELFAArch64AsmBackend to AArch64AsmBackend, I suddenly started getting the following errors when assembling your test snippet:

Ah, interesting! I actually think that's correct behaviour. The MachO adrp always has a textual tag for the kind of relocation you want. For example `adrp x0, Lthere at PAGE`. So without that function we silently miscompiled invalid code instead of diagnosing it; with your change it survives to the relocation phase to be reported.

Technically we should probably diagnose it earlier (AsmParser), but for your purposes just checking that there is an error in the MachO case is probably the right thing to do.


https://reviews.llvm.org/D35544





More information about the llvm-commits mailing list