aboutsummaryrefslogtreecommitdiff
path: root/src/arch/aarch64
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-08-30 14:29:41 +0200
committerGitHub <noreply@github.com>2022-08-30 14:29:41 +0200
commit7ef0c9d298d5645b4b6d1ffdfd34c69c04423ed2 (patch)
tree12b54077e1533b1abcb8d9a9cd1222b24478f5fc /src/arch/aarch64
parentb64e4c5bf28286091ff97245e61f08b897e3eb5e (diff)
parente57fbe8069e672483b0c9ae1fa28c00812596306 (diff)
downloadzig-7ef0c9d298d5645b4b6d1ffdfd34c69c04423ed2.tar.gz
zig-7ef0c9d298d5645b4b6d1ffdfd34c69c04423ed2.zip
Merge pull request #12677 from ziglang/coff-linker
coff: initial rewrite of the COFF/PE linker
Diffstat (limited to 'src/arch/aarch64')
-rw-r--r--src/arch/aarch64/CodeGen.zig16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/arch/aarch64/CodeGen.zig b/src/arch/aarch64/CodeGen.zig
index d256f9a558..884fd68d55 100644
--- a/src/arch/aarch64/CodeGen.zig
+++ b/src/arch/aarch64/CodeGen.zig
@@ -3466,19 +3466,16 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.
// on linking.
const mod = self.bin_file.options.module.?;
if (self.air.value(callee)) |func_value| {
- if (self.bin_file.tag == link.File.Elf.base_tag or self.bin_file.tag == link.File.Coff.base_tag) {
+ if (self.bin_file.cast(link.File.Elf)) |elf_file| {
if (func_value.castTag(.function)) |func_payload| {
const func = func_payload.data;
const ptr_bits = self.target.cpu.arch.ptrBitWidth();
const ptr_bytes: u64 = @divExact(ptr_bits, 8);
const fn_owner_decl = mod.declPtr(func.owner_decl);
- const got_addr = if (self.bin_file.cast(link.File.Elf)) |elf_file| blk: {
+ const got_addr = blk: {
const got = &elf_file.program_headers.items[elf_file.phdr_got_index.?];
break :blk @intCast(u32, got.p_vaddr + fn_owner_decl.link.elf.offset_table_index * ptr_bytes);
- } else if (self.bin_file.cast(link.File.Coff)) |coff_file|
- coff_file.offset_table_virtual_address + fn_owner_decl.link.coff.offset_table_index * ptr_bytes
- else
- unreachable;
+ };
try self.genSetReg(Type.initTag(.usize), .x30, .{ .memory = got_addr });
@@ -3546,6 +3543,8 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.
} else {
return self.fail("TODO implement calling bitcasted functions", .{});
}
+ } else if (self.bin_file.cast(link.File.Coff)) |_| {
+ return self.fail("TODO implement calling in COFF for {}", .{self.target.cpu.arch});
} else unreachable;
} else {
assert(ty.zigTypeTag() == .Pointer);
@@ -5109,9 +5108,8 @@ fn lowerDeclRef(self: *Self, tv: TypedValue, decl_index: Module.Decl.Index) Inne
// the linker has enough info to perform relocations.
assert(decl.link.macho.sym_index != 0);
return MCValue{ .got_load = decl.link.macho.sym_index };
- } else if (self.bin_file.cast(link.File.Coff)) |coff_file| {
- const got_addr = coff_file.offset_table_virtual_address + decl.link.coff.offset_table_index * ptr_bytes;
- return MCValue{ .memory = got_addr };
+ } else if (self.bin_file.cast(link.File.Coff)) |_| {
+ return self.fail("TODO codegen COFF const Decl pointer", .{});
} else if (self.bin_file.cast(link.File.Plan9)) |p9| {
try p9.seeDecl(decl_index);
const got_addr = p9.bases.data + decl.link.plan9.got_index.? * ptr_bytes;