aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoachimschmidt557 <joachim.schmidt557@outlook.com>2021-01-02 18:53:11 +0100
committerAndrew Kelley <andrew@ziglang.org>2021-01-03 19:54:12 -0800
commitaa0906e9aaaf36bc928b5502bdb34e7a0409b2c0 (patch)
treed6f669cebdae86ea204b4db4086cdd44bdcc8b87
parent4400d2d7abb3be8c7b9fde9754fc58d4510c5107 (diff)
downloadzig-aa0906e9aaaf36bc928b5502bdb34e7a0409b2c0.tar.gz
zig-aa0906e9aaaf36bc928b5502bdb34e7a0409b2c0.zip
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.
-rw-r--r--src/codegen.zig9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/codegen.zig b/src/codegen.zig
index cd6ea15737..c2537a1ca0 100644
--- 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);
}