summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2020-05-15 13:34:31 +0800
committerBen Gamari <ben@smart-cactus.org>2020-07-08 11:53:43 -0400
commit8eb55fc96cc77d24e2da693fd582d386d09e6525 (patch)
tree4c537b381baf2a323c4d989af5115b1f2290d3dc
parent31e2bfbf45c7f5959a33c364ec9140f664cb8eb9 (diff)
downloadhaskell-8eb55fc96cc77d24e2da693fd582d386d09e6525.tar.gz
Range is actually +/-2^32, not +/-2^31
See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf (cherry picked from commit 4a158ffc4e0ac250897aefaf6caf03eb5f688182)
-rw-r--r--rts/linker/elf_reloc_aarch64.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/rts/linker/elf_reloc_aarch64.c b/rts/linker/elf_reloc_aarch64.c
index bb15576d06..e676c68775 100644
--- a/rts/linker/elf_reloc_aarch64.c
+++ b/rts/linker/elf_reloc_aarch64.c
@@ -90,12 +90,14 @@ encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend) {
// ... hi ] [ Rd ]
//
// imm64 = SignExtend(hi:lo:0x000,64)
- assert(isInt64(32, addend));
+ // Range is 21 bits + the 12 page relative bits
+ // known to be 0. -2^32 <= X < 2^32
+ assert(isInt64(21+12, addend));
assert((addend & 0xfff) == 0); /* page relative */
*(inst_t *)P = (*(inst_t *)P & 0x9f00001f)
- | (inst_t) (((uint64_t) addend << 17) & 0x60000000)
- | (inst_t) (((uint64_t) addend >> 9) & 0x00ffffe0);
+ | (inst_t) (((uint64_t) addend << 17) & 0x60000000)
+ | (inst_t) (((uint64_t) addend >> 9) & 0x00ffffe0);
break;
}
/* - control flow relocations */
@@ -108,8 +110,8 @@ encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend) {
break;
}
case COMPAT_R_AARCH64_ADR_GOT_PAGE: {
-
- assert(isInt64(32, addend)); /* X in range */
+ /* range is -2^32 <= X < 2^32 */
+ assert(isInt64(21+12, addend)); /* X in range */
assert((addend & 0xfff) == 0); /* page relative */
*(inst_t *)P = (*(inst_t *)P & 0x9f00001f)