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