commit aa0906e9aaaf36bc928b5502bdb34e7a0409b2c0 (tree)
parent 4400d2d7abb3be8c7b9fde9754fc58d4510c5107
Author: joachimschmidt557 <joachim.schmidt557@outlook.com>
Date: Sat, 2 Jan 2021 18:53:11 +0100
stage2 x86_64: fix bug in Function.gen
Previously, the x86_64 backend would remove code for exitlude relocs
if the jump amount were 0. This causes issues as earlier jumps rely on
the jump being present at the same address.
Diffstat:
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/codegen.zig b/src/codegen.zig
@@ -543,13 +543,10 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
if (self.code.items.len >= math.maxInt(i32)) {
return self.fail(self.src, "unable to perform relocation: jump too far", .{});
}
- for (self.exitlude_jump_relocs.items) |jmp_reloc| {
+ if (self.exitlude_jump_relocs.items.len == 1) {
+ self.code.items.len -= 5;
+ } else for (self.exitlude_jump_relocs.items) |jmp_reloc| {
const amt = self.code.items.len - (jmp_reloc + 4);
- // If it wouldn't jump at all, elide it.
- if (amt == 0) {
- self.code.items.len -= 5;
- continue;
- }
const s32_amt = @intCast(i32, amt);
mem.writeIntLittle(i32, self.code.items[jmp_reloc..][0..4], s32_amt);
}