From: Vladislav Khmelevsky Date: Fri, 11 Nov 2022 00:46:23 +0000 (-0800) Subject: Fix adrp distance check X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cde010e1a866e67b7e895cbcb95dedd3de0a1e56;p=binutils-gdb.git Fix adrp distance check gold/ * aarch64.cc (aarch64_valid_for_adrp_p): Shift offset as a signed number. --- diff --git a/gold/aarch64.cc b/gold/aarch64.cc index d1f5c3299b0..c5aa2c710da 100644 --- a/gold/aarch64.cc +++ b/gold/aarch64.cc @@ -1182,7 +1182,8 @@ class Reloc_stub : public Stub_base aarch64_valid_for_adrp_p(AArch64_address location, AArch64_address dest) { typedef AArch64_relocate_functions Reloc; - int64_t adrp_imm = (Reloc::Page(dest) - Reloc::Page(location)) >> 12; + int64_t adrp_imm = Reloc::Page (dest) - Reloc::Page (location); + adrp_imm = adrp_imm < 0 ? ~(~adrp_imm >> 12) : adrp_imm >> 12; return adrp_imm >= MIN_ADRP_IMM && adrp_imm <= MAX_ADRP_IMM; }