From 9af7a3ae2af6b1b33d214b59b2286fde9ae1f80d Mon Sep 17 00:00:00 2001
From: wangding16 <wangding16@huawei.com>
Date: Tue, 21 Jun 2022 17:42:52 +0800
Subject: [PATCH] Fix gold adrp signed shift

---
 gold/aarch64.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gold/aarch64.cc b/gold/aarch64.cc
index 9f3af466..521908ff 100644
--- a/gold/aarch64.cc
+++ b/gold/aarch64.cc
@@ -1182,7 +1182,7 @@ class Reloc_stub : public Stub_base<size, big_endian>
   aarch64_valid_for_adrp_p(AArch64_address location, AArch64_address dest)
   {
     typedef AArch64_relocate_functions<size, big_endian> Reloc;
-    int64_t adrp_imm = (Reloc::Page(dest) - Reloc::Page(location)) >> 12;
+    int64_t adrp_imm = ((int64_t)(Reloc::Page(dest) - Reloc::Page(location))) >> 12;
     return adrp_imm >= MIN_ADRP_IMM && adrp_imm <= MAX_ADRP_IMM;
   }
 
-- 
2.27.0

