| ... | ... | @@ -760,13 +760,15 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 760 | 760 | const text_segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment; |
| 761 | 761 | const text_section = text_segment.sections.items[self.text_section_index.?]; |
| 762 | 762 | const after_last_cmd_offset = self.header.?.sizeofcmds + @sizeOf(macho.mach_header_64); |
| 763 | | const needed_size = @sizeOf(macho.linkedit_data_command); |
| 763 | const needed_size = @sizeOf(macho.linkedit_data_command) * alloc_num / alloc_den; |
| 764 | |
| 764 | 765 | if (needed_size + after_last_cmd_offset > text_section.offset) { |
| 765 | | std.log.err("Unable to extend padding between load commands and start of __text section.", .{}); |
| 766 | | std.log.err("Re-run the linker with '-headerpad 0x{x}' option if available, or", .{needed_size * alloc_num / alloc_den}); |
| 767 | | std.log.err("fall back to the system linker.", .{}); |
| 766 | std.log.err("Unable to extend padding between the end of load commands and start of __text section.", .{}); |
| 767 | std.log.err("Re-run the linker with '-headerpad 0x{x}' option if available, or", .{needed_size}); |
| 768 | std.log.err("fall back to the system linker by exporting 'ZIG_SYSTEM_LINKER_HACK=1'.", .{}); |
| 768 | 769 | return error.NotEnoughPadding; |
| 769 | 770 | } |
| 771 | |
| 770 | 772 | const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment; |
| 771 | 773 | // TODO This is clunky. |
| 772 | 774 | self.linkedit_segment_next_offset = @intCast(u32, mem.alignForwardGeneric(u64, linkedit_segment.inner.fileoff + linkedit_segment.inner.filesize, @sizeOf(u64))); |