aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2020-12-09 11:43:04 +0100
committerJakub Konka <kubkon@jakubkonka.com>2020-12-09 20:36:58 +0100
commit44e2f210bb3fee78d339bc5c75822e0311600f70 (patch)
treea7dbccbc90d0a390668e99896d639e631582ee6f
parent184c0f3c4e140d3f0971bac184f0abce00d8d336 (diff)
downloadzig-44e2f210bb3fee78d339bc5c75822e0311600f70.tar.gz
zig-44e2f210bb3fee78d339bc5c75822e0311600f70.zip
lld+macho: clean up error message when padding insufficient
-rw-r--r--src/link/MachO.zig10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index 1466f75486..6fd0561cb1 100644
--- a/src/link/MachO.zig
+++ b/src/link/MachO.zig
@@ -760,13 +760,15 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
const text_segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const text_section = text_segment.sections.items[self.text_section_index.?];
const after_last_cmd_offset = self.header.?.sizeofcmds + @sizeOf(macho.mach_header_64);
- const needed_size = @sizeOf(macho.linkedit_data_command);
+ const needed_size = @sizeOf(macho.linkedit_data_command) * alloc_num / alloc_den;
+
if (needed_size + after_last_cmd_offset > text_section.offset) {
- std.log.err("Unable to extend padding between load commands and start of __text section.", .{});
- std.log.err("Re-run the linker with '-headerpad 0x{x}' option if available, or", .{needed_size * alloc_num / alloc_den});
- std.log.err("fall back to the system linker.", .{});
+ std.log.err("Unable to extend padding between the end of load commands and start of __text section.", .{});
+ std.log.err("Re-run the linker with '-headerpad 0x{x}' option if available, or", .{needed_size});
+ std.log.err("fall back to the system linker by exporting 'ZIG_SYSTEM_LINKER_HACK=1'.", .{});
return error.NotEnoughPadding;
}
+
const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
// TODO This is clunky.
self.linkedit_segment_next_offset = @intCast(u32, mem.alignForwardGeneric(u64, linkedit_segment.inner.fileoff + linkedit_segment.inner.filesize, @sizeOf(u64)));