From 1f7fb560ab5a3a82af24ab7abe11dce8f877c7fe Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Mon, 30 Nov 2020 23:57:36 +0100 Subject: lld: use commands.LoadCommand in self-hosted linker --- src/codegen.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/codegen.zig') diff --git a/src/codegen.zig b/src/codegen.zig index ee3f0ee4a8..2bc5381975 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -1790,7 +1790,8 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { if (inst.func.cast(ir.Inst.Constant)) |func_inst| { if (func_inst.val.cast(Value.Payload.Function)) |func_val| { const func = func_val.func; - const got = &macho_file.sections.items[macho_file.got_section_index.?]; + const text_segment = &macho_file.load_commands.items[macho_file.text_segment_cmd_index.?].Segment; + const got = &text_segment.sections.items[macho_file.got_section_index.?]; const got_addr = got.addr + func.owner_decl.link.macho.offset_table_index * @sizeOf(u64); switch (arch) { .x86_64 => { @@ -3191,7 +3192,8 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { return MCValue{ .memory = got_addr }; } else if (self.bin_file.cast(link.File.MachO)) |macho_file| { const decl = payload.decl; - const got = &macho_file.sections.items[macho_file.got_section_index.?]; + const text_segment = &macho_file.load_commands.items[macho_file.text_segment_cmd_index.?].Segment; + const got = &text_segment.sections.items[macho_file.got_section_index.?]; const got_addr = got.addr + decl.link.macho.offset_table_index * ptr_bytes; return MCValue{ .memory = got_addr }; } else if (self.bin_file.cast(link.File.Coff)) |coff_file| { -- cgit v1.2.3