diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-01-09 19:51:01 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2024-01-24 12:34:38 +0100 |
| commit | dd0addab1fe11b019e83c0050eedfa0ec67eb408 (patch) | |
| tree | 852e59e811627cb8fb13f4091c5e1532fccda706 /src/arch/x86_64/CodeGen.zig | |
| parent | 2f94dc939e8acf0dab4cf1f3cf01b132ac6fdd3c (diff) | |
| download | zig-dd0addab1fe11b019e83c0050eedfa0ec67eb408.tar.gz zig-dd0addab1fe11b019e83c0050eedfa0ec67eb408.zip | |
macho: get the ball rolling!
Diffstat (limited to 'src/arch/x86_64/CodeGen.zig')
| -rw-r--r-- | src/arch/x86_64/CodeGen.zig | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 55e241cbd4..870b6a2472 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -139,8 +139,10 @@ const Owner = union(enum) { if (ctx.bin_file.cast(link.File.Elf)) |elf_file| { return elf_file.zigObjectPtr().?.getOrCreateMetadataForDecl(elf_file, decl_index); } else if (ctx.bin_file.cast(link.File.MachO)) |macho_file| { - const atom = try macho_file.getOrCreateAtomForDecl(decl_index); - return macho_file.getAtom(atom).getSymbolIndex().?; + _ = macho_file; + // const atom = try macho_file.getOrCreateAtomForDecl(decl_index); + // return macho_file.getAtom(atom).getSymbolIndex().?; + @panic("TODO getSymbolIndex"); } else if (ctx.bin_file.cast(link.File.Coff)) |coff_file| { const atom = try coff_file.getOrCreateAtomForDecl(decl_index); return coff_file.getAtom(atom).getSymbolIndex().?; @@ -153,9 +155,11 @@ const Owner = union(enum) { return elf_file.zigObjectPtr().?.getOrCreateMetadataForLazySymbol(elf_file, lazy_sym) catch |err| ctx.fail("{s} creating lazy symbol", .{@errorName(err)}); } else if (ctx.bin_file.cast(link.File.MachO)) |macho_file| { - const atom = macho_file.getOrCreateAtomForLazySymbol(lazy_sym) catch |err| - return ctx.fail("{s} creating lazy symbol", .{@errorName(err)}); - return macho_file.getAtom(atom).getSymbolIndex().?; + _ = macho_file; + // const atom = macho_file.getOrCreateAtomForLazySymbol(lazy_sym) catch |err| + // return ctx.fail("{s} creating lazy symbol", .{@errorName(err)}); + // return macho_file.getAtom(atom).getSymbolIndex().?; + @panic("TODO getSymbolIndex"); } else if (ctx.bin_file.cast(link.File.Coff)) |coff_file| { const atom = coff_file.getOrCreateAtomForLazySymbol(lazy_sym) catch |err| return ctx.fail("{s} creating lazy symbol", .{@errorName(err)}); @@ -10951,10 +10955,12 @@ fn genCall(self: *Self, info: union(enum) { try self.genSetReg(.rax, Type.usize, .{ .lea_got = sym_index }); try self.asmRegister(.{ ._, .call }, .rax); } else if (self.bin_file.cast(link.File.MachO)) |macho_file| { - const atom = try macho_file.getOrCreateAtomForDecl(func.owner_decl); - const sym_index = macho_file.getAtom(atom).getSymbolIndex().?; - try self.genSetReg(.rax, Type.usize, .{ .lea_got = sym_index }); - try self.asmRegister(.{ ._, .call }, .rax); + _ = macho_file; + @panic("TODO genCall"); + // const atom = try macho_file.getOrCreateAtomForDecl(func.owner_decl); + // const sym_index = macho_file.getAtom(atom).getSymbolIndex().?; + // try self.genSetReg(.rax, Type.usize, .{ .lea_got = sym_index }); + // try self.asmRegister(.{ ._, .call }, .rax); } else if (self.bin_file.cast(link.File.Plan9)) |p9| { const atom_index = try p9.seeDecl(func.owner_decl); const atom = p9.getAtom(atom_index); @@ -13814,11 +13820,15 @@ fn genExternSymbolRef( _ = try self.addInst(.{ .tag = .call, .ops = .extern_fn_reloc, - .data = .{ .reloc = .{ - .atom_index = atom_index, - .sym_index = link.File.MachO.global_symbol_bit | global_index, - } }, + .data = .{ + .reloc = .{ + .atom_index = atom_index, + // .sym_index = link.File.MachO.global_symbol_bit | global_index, + .sym_index = global_index, + }, + }, }); + @panic("TODO genExternSymbolRef"); } else return self.fail("TODO implement calling extern functions", .{}); } @@ -13906,19 +13916,21 @@ fn genLazySymbolRef( else => unreachable, } } else if (self.bin_file.cast(link.File.MachO)) |macho_file| { - const atom_index = macho_file.getOrCreateAtomForLazySymbol(lazy_sym) catch |err| - return self.fail("{s} creating lazy symbol", .{@errorName(err)}); - const sym_index = macho_file.getAtom(atom_index).getSymbolIndex().?; - switch (tag) { - .lea, .call => try self.genSetReg(reg, Type.usize, .{ .lea_got = sym_index }), - .mov => try self.genSetReg(reg, Type.usize, .{ .load_got = sym_index }), - else => unreachable, - } - switch (tag) { - .lea, .mov => {}, - .call => try self.asmRegister(.{ ._, .call }, reg), - else => unreachable, - } + _ = macho_file; + @panic("TODO genLazySymbolRef"); + // const atom_index = macho_file.getOrCreateAtomForLazySymbol(lazy_sym) catch |err| + // return self.fail("{s} creating lazy symbol", .{@errorName(err)}); + // const sym_index = macho_file.getAtom(atom_index).getSymbolIndex().?; + // switch (tag) { + // .lea, .call => try self.genSetReg(reg, Type.usize, .{ .lea_got = sym_index }), + // .mov => try self.genSetReg(reg, Type.usize, .{ .load_got = sym_index }), + // else => unreachable, + // } + // switch (tag) { + // .lea, .mov => {}, + // .call => try self.asmRegister(.{ ._, .call }, reg), + // else => unreachable, + // } } else { return self.fail("TODO implement genLazySymbol for x86_64 {s}", .{@tagName(self.bin_file.tag)}); } |
