Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -671,11 +671,11 @@ return In.MipsGot->getVA() + In.MipsGot->getTlsIndexOffset(File) - In.MipsGot->getGp(File); case R_AARCH64_PAGE_PC: { - uint64_t Val = Sym.isUndefWeak() ? A : Sym.getVA(A); + uint64_t Val = Sym.isUndefWeak() ? P + A : Sym.getVA(A); return getAArch64Page(Val) - getAArch64Page(P); } case R_AARCH64_PLT_PAGE_PC: { - uint64_t Val = Sym.isUndefWeak() ? A : Sym.getPltVA() + A; + uint64_t Val = Sym.isUndefWeak() ? P + A : Sym.getPltVA() + A; return getAArch64Page(Val) - getAArch64Page(P); } case R_RISCV_PC_INDIRECT: { Index: test/ELF/aarch64-undefined-weak.s =================================================================== --- test/ELF/aarch64-undefined-weak.s +++ test/ELF/aarch64-undefined-weak.s @@ -40,7 +40,7 @@ // CHECK-NEXT: 210008: {{.*}} b.eq #4 // CHECK-NEXT: 21000c: {{.*}} cbz x1, #4 // CHECK-NEXT: 210010: {{.*}} adr x0, #0 -// CHECK-NEXT: 210014: {{.*}} adrp x0, #-2162688 +// CHECK-NEXT: 210014: {{.*}} adrp x0, #0 // CHECK: 210018: {{.*}} .word 0x00000000 // CHECK-NEXT: 21001c: {{.*}} .word 0x00000000 // CHECK-NEXT: 210020: {{.*}} .word 0x00000000