[lld] [lld][ELF] Fix a corner case of elf::getLoongArchPageDelta (PR #71907)

Lu Weining via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 12 18:17:34 PST 2023


================
@@ -159,6 +159,10 @@ uint64_t elf::getLoongArchPageDelta(uint64_t dest, uint64_t pc) {
   bool negativeA = lo12(dest) > 0x7ff;
   bool negativeB = (result & 0x8000'0000) != 0;
 
+  // A corner case; directly return the expected result.
+  if (result == 0xfffffffffffff000 && negativeA)
+    return result = 0xffffffff00000000;
----------------
SixWeining wrote:

Seems that mold uses the same impl as binutils. https://github.com/rui314/mold/blob/v2.3.2/elf/arch-loongarch.cc#L53

https://github.com/llvm/llvm-project/pull/71907


More information about the llvm-commits mailing list