| ... | ... | @@ -561,21 +561,26 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 561 | 561 | try self.writeLinkeditSegmentData(&ncmds, lc_writer); |
| 562 | 562 | try load_commands.writeDylinkerLC(&ncmds, lc_writer); |
| 563 | 563 | |
| 564 | | if (self.base.options.output_mode == .Exe) blk: { |
| 565 | | const seg_id = self.header_segment_cmd_index.?; |
| 566 | | const seg = self.segments.items[seg_id]; |
| 567 | | const global = self.getEntryPoint() catch |err| switch (err) { |
| 568 | | error.MissingMainEntrypoint => { |
| 569 | | self.error_flags.no_entry_point_found = true; |
| 570 | | break :blk; |
| 571 | | }, |
| 572 | | else => |e| return e, |
| 573 | | }; |
| 574 | | const sym = self.getSymbol(global); |
| 575 | | try load_commands.writeMainLC(@intCast(u32, sym.n_value - seg.vmaddr), &self.base.options, &ncmds, lc_writer); |
| 564 | switch (self.base.options.output_mode) { |
| 565 | .Exe => blk: { |
| 566 | const seg_id = self.header_segment_cmd_index.?; |
| 567 | const seg = self.segments.items[seg_id]; |
| 568 | const global = self.getEntryPoint() catch |err| switch (err) { |
| 569 | error.MissingMainEntrypoint => { |
| 570 | self.error_flags.no_entry_point_found = true; |
| 571 | break :blk; |
| 572 | }, |
| 573 | else => |e| return e, |
| 574 | }; |
| 575 | const sym = self.getSymbol(global); |
| 576 | try load_commands.writeMainLC(@intCast(u32, sym.n_value - seg.vmaddr), &self.base.options, &ncmds, lc_writer); |
| 577 | }, |
| 578 | .Lib => if (self.base.options.link_mode == .Dynamic) { |
| 579 | try load_commands.writeDylibIdLC(self.base.allocator, &self.base.options, &ncmds, lc_writer); |
| 580 | }, |
| 581 | else => {}, |
| 576 | 582 | } |
| 577 | 583 | |
| 578 | | try load_commands.writeDylibIdLC(self.base.allocator, &self.base.options, &ncmds, lc_writer); |
| 579 | 584 | try load_commands.writeRpathLCs(self.base.allocator, &self.base.options, &ncmds, lc_writer); |
| 580 | 585 | |
| 581 | 586 | { |