authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-12-09 11:43:04+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-12-09 20:36:58+01:00
log44e2f210bb3fee78d339bc5c75822e0311600f70
treea7dbccbc90d0a390668e99896d639e631582ee6f
parent184c0f3c4e140d3f0971bac184f0abce00d8d336

lld+macho: clean up error message when padding insufficient


1 files changed, 6 insertions(+), 4 deletions(-)

src/link/MachO.zig+6-4
......@@ -760,13 +760,15 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
760760 const text_segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
761761 const text_section = text_segment.sections.items[self.text_section_index.?];
762762 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
764765 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'.", .{});
768769 return error.NotEnoughPadding;
769770 }
771
770772 const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
771773 // TODO This is clunky.
772774 self.linkedit_segment_next_offset = @intCast(u32, mem.alignForwardGeneric(u64, linkedit_segment.inner.fileoff + linkedit_segment.inner.filesize, @sizeOf(u64)));