| ... | ... | @@ -135,7 +135,9 @@ fn resolveAarch64( |
| 135 | 135 | inst.pc_relative_address.immlo = @truncate(u2, pages); |
| 136 | 136 | mem.writeIntLittle(u32, &buffer, inst.toU32()); |
| 137 | 137 | }, |
| 138 | | .ARM64_RELOC_PAGEOFF12 => { |
| 138 | .ARM64_RELOC_PAGEOFF12, |
| 139 | .ARM64_RELOC_GOT_LOAD_PAGEOFF12, |
| 140 | => { |
| 139 | 141 | const narrowed = @truncate(u12, @intCast(u64, target_addr)); |
| 140 | 142 | if (isArithmeticOp(&buffer)) { |
| 141 | 143 | var inst = aarch64.Instruction{ |
| ... | ... | @@ -170,18 +172,6 @@ fn resolveAarch64( |
| 170 | 172 | mem.writeIntLittle(u32, &buffer, inst.toU32()); |
| 171 | 173 | } |
| 172 | 174 | }, |
| 173 | | .ARM64_RELOC_GOT_LOAD_PAGEOFF12 => { |
| 174 | | const narrowed = @truncate(u12, @intCast(u64, target_addr)); |
| 175 | | var inst: aarch64.Instruction = .{ |
| 176 | | .load_store_register = mem.bytesToValue(meta.TagPayload( |
| 177 | | aarch64.Instruction, |
| 178 | | aarch64.Instruction.load_store_register, |
| 179 | | ), &buffer), |
| 180 | | }; |
| 181 | | const offset = @divExact(narrowed, 8); |
| 182 | | inst.load_store_register.offset = offset; |
| 183 | | mem.writeIntLittle(u32, &buffer, inst.toU32()); |
| 184 | | }, |
| 185 | 175 | .ARM64_RELOC_TLVP_LOAD_PAGEOFF12 => { |
| 186 | 176 | const RegInfo = struct { |
| 187 | 177 | rd: u5, |
| ... | ... | @@ -226,11 +216,8 @@ fn resolveAarch64( |
| 226 | 216 | mem.writeIntLittle(u32, &buffer, inst.toU32()); |
| 227 | 217 | }, |
| 228 | 218 | .ARM64_RELOC_POINTER_TO_GOT => { |
| 229 | | const result = math.cast( |
| 230 | | i32, |
| 231 | | @intCast(i64, target_addr) - @intCast(i64, source_addr), |
| 232 | | ) orelse return error.Overflow; |
| 233 | | mem.writeIntLittle(u32, &buffer, @bitCast(u32, result)); |
| 219 | const result = @intCast(i32, @intCast(i64, target_addr) - @intCast(i64, source_addr)); |
| 220 | mem.writeIntLittle(i32, &buffer, result); |
| 234 | 221 | }, |
| 235 | 222 | .ARM64_RELOC_SUBTRACTOR => unreachable, |
| 236 | 223 | .ARM64_RELOC_ADDEND => unreachable, |
| ... | ... | @@ -255,10 +242,7 @@ fn resolveX8664( |
| 255 | 242 | .X86_64_RELOC_GOT_LOAD, |
| 256 | 243 | .X86_64_RELOC_TLV, |
| 257 | 244 | => { |
| 258 | | const displacement = math.cast( |
| 259 | | i32, |
| 260 | | @intCast(i64, target_addr) - @intCast(i64, source_addr) - 4, |
| 261 | | ) orelse return error.Overflow; |
| 245 | const displacement = @intCast(i32, @intCast(i64, target_addr) - @intCast(i64, source_addr) - 4); |
| 262 | 246 | mem.writeIntLittle(u32, buffer[0..4], @bitCast(u32, displacement)); |
| 263 | 247 | break :blk buffer[0..4]; |
| 264 | 248 | }, |
| ... | ... | @@ -274,10 +258,7 @@ fn resolveX8664( |
| 274 | 258 | .X86_64_RELOC_SIGNED_4 => 4, |
| 275 | 259 | else => unreachable, |
| 276 | 260 | }; |
| 277 | | const displacement = math.cast( |
| 278 | | i32, |
| 279 | | target_addr - @intCast(i64, source_addr + correction + 4), |
| 280 | | ) orelse return error.Overflow; |
| 261 | const displacement = @intCast(i32, target_addr - @intCast(i64, source_addr + correction + 4)); |
| 281 | 262 | mem.writeIntLittle(u32, buffer[0..4], @bitCast(u32, displacement)); |
| 282 | 263 | break :blk buffer[0..4]; |
| 283 | 264 | }, |