diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp --- a/lld/ELF/Arch/AArch64.cpp +++ b/lld/ELF/Arch/AArch64.cpp @@ -103,6 +103,7 @@ case R_AARCH64_LD_PREL_LO19: return R_PC; case R_AARCH64_ADR_PREL_PG_HI21: + case R_AARCH64_ADR_PREL_PG_HI21_NC: return R_AARCH64_PAGE_PC; case R_AARCH64_LD64_GOT_LO12_NC: case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: @@ -270,6 +271,8 @@ case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: case R_AARCH64_TLSDESC_ADR_PAGE21: checkInt(Loc, Val, 33, Type); + LLVM_FALLTHROUGH; + case R_AARCH64_ADR_PREL_PG_HI21_NC: write32AArch64Addr(Loc, Val >> 12); break; case R_AARCH64_ADR_PREL_LO21: diff --git a/lld/test/ELF/aarch64-hi21-nc.s b/lld/test/ELF/aarch64-hi21-nc.s new file mode 100644 --- /dev/null +++ b/lld/test/ELF/aarch64-hi21-nc.s @@ -0,0 +1,8 @@ +// REQUIRES: aarch64 +// RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-linux %s -o %t.o +// RUN: ld.lld %t.o -o %t +// RUN: llvm-objdump -d %t | FileCheck %s + +foo = . + 0x1100000000000000 +// CHECK: adrp x0, #0 +adrp x0, :pg_hi21_nc:foo