Index: lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp =================================================================== --- lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp +++ lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp @@ -580,6 +580,13 @@ MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override { return createAArch64WinCOFFObjectWriter(OS); } + bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup, + const MCValue &Target) override { + // The same reason as in ELFAArch64AsmBackend above + if ((uint32_t)Fixup.getKind() == AArch64::fixup_aarch64_pcrel_adrp_imm21) + return true; + return false; + } }; } Index: test/MC/AArch64/adrp-relocation-coff.s =================================================================== --- /dev/null +++ test/MC/AArch64/adrp-relocation-coff.s @@ -0,0 +1,11 @@ +// RUN: llvm-mc -triple=aarch64-windows -filetype=obj -o - %s| llvm-readobj -r - | FileCheck %s + .text +// This tests that LLVM doesn't think it can deal with the relocation on the ADRP +// itself (even though it knows everything about the relative offsets of sym and +// the adrp instruction) because its value depends on where this object file's +// .text section gets relocated in memory. + adrp x0, sym + + .global sym +sym: +// CHECK: IMAGE_REL_ARM64_PAGEBASE_REL21 sym