aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-08-31 20:03:41 +0200
committerJakub Konka <kubkon@jakubkonka.com>2022-09-07 22:42:55 +0200
commit51fba37af70283427a7ef5d2f2fd39f97aaa1e35 (patch)
tree06bc9cf2718be8296e88184b45936e209f24c331 /src
parenta35f156cf60ed3d8095c15c4ab26aee267761a56 (diff)
downloadzig-51fba37af70283427a7ef5d2f2fd39f97aaa1e35.tar.gz
zig-51fba37af70283427a7ef5d2f2fd39f97aaa1e35.zip
coff: add relocation for call_extern
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86_64/Emit.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/arch/x86_64/Emit.zig b/src/arch/x86_64/Emit.zig
index 12f3e9118f..055216e2bb 100644
--- a/src/arch/x86_64/Emit.zig
+++ b/src/arch/x86_64/Emit.zig
@@ -1157,6 +1157,18 @@ fn mirCallExtern(emit: *Emit, inst: Mir.Inst.Index) InnerError!void {
.length = 2,
.@"type" = @enumToInt(std.macho.reloc_type_x86_64.X86_64_RELOC_BRANCH),
});
+ } else if (emit.bin_file.cast(link.File.Coff)) |coff_file| {
+ // Add relocation to the decl.
+ const atom = coff_file.atom_by_index_table.get(relocation.atom_index).?;
+ try atom.addRelocation(coff_file, .{
+ .@"type" = .direct,
+ .target = .{ .sym_index = relocation.sym_index, .file = null },
+ .offset = offset,
+ .addend = 0,
+ .pcrel = true,
+ .length = 2,
+ .prev_vaddr = atom.getSymbol(coff_file).value,
+ });
} else {
return emit.fail("TODO implement call_extern for linking backends different than MachO", .{});
}