aboutsummaryrefslogtreecommitdiff
path: root/src/link
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2020-10-07 11:00:40 +0200
committerJakub Konka <kubkon@jakubkonka.com>2020-10-07 17:18:37 +0200
commit07c33dfc951af5e7bf1c29c94142d49e3acf08b0 (patch)
tree1681539cdd41885d381881f9fcf2272f1056f3f8 /src/link
parent53dee08af99dd334b0d227afb5ce2a0f92c35a5d (diff)
downloadzig-07c33dfc951af5e7bf1c29c94142d49e3acf08b0.tar.gz
zig-07c33dfc951af5e7bf1c29c94142d49e3acf08b0.zip
Remove obsolete addPadding fn and callsites from MachO linker
This is no longer needed due to the way writing to the output file is structured. Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
Diffstat (limited to 'src/link')
-rw-r--r--src/link/MachO.zig21
1 files changed, 0 insertions, 21 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index 68307a5fc6..a1b9484e13 100644
--- a/src/link/MachO.zig
+++ b/src/link/MachO.zig
@@ -287,9 +287,6 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void {
}
const cmd = &self.load_commands.items[self.dylinker_cmd_index.?].Dylinker;
off += cmd.name;
- const padding = cmd.cmdsize - @sizeOf(macho.dylinker_command);
- log.debug("writing LC_LOAD_DYLINKER padding of size {} at 0x{x}\n", .{ padding, off });
- try self.addPadding(padding, off);
log.debug("writing LC_LOAD_DYLINKER path to dyld at 0x{x}\n", .{off});
try self.base.file.?.pwriteAll(mem.spanZ(DEFAULT_DYLD_PATH), off);
}
@@ -302,9 +299,6 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void {
}
const cmd = &self.load_commands.items[self.libsystem_cmd_index.?].Dylib;
off += cmd.dylib.name;
- const padding = cmd.cmdsize - @sizeOf(macho.dylib_command);
- log.debug("writing LC_LOAD_DYLIB padding of size {} at 0x{x}\n", .{ padding, off });
- try self.addPadding(padding, off);
log.debug("writing LC_LOAD_DYLIB path to libSystem at 0x{x}\n", .{off});
try self.base.file.?.pwriteAll(mem.spanZ(LIB_SYSTEM_PATH), off);
}
@@ -1264,21 +1258,6 @@ fn updateString(self: *MachO, old_str_off: u32, new_name: []const u8) !u32 {
return self.makeString(new_name);
}
-/// TODO This should not heap allocate, instead it should utilize a fixed size, statically allocated
-/// global const array. You could even use pwritev to write the same buffer multiple times with only
-/// 1 syscall if you needed to, for example, write 8192 bytes using a buffer of only 4096 bytes.
-/// This size parameter should probably be a usize not u64.
-fn addPadding(self: *MachO, size: u64, file_offset: u64) !void {
- if (size == 0) return;
-
- const buf = try self.base.allocator.alloc(u8, @intCast(usize, size));
- defer self.base.allocator.free(buf);
-
- mem.set(u8, buf[0..], 0);
-
- try self.base.file.?.pwriteAll(buf, file_offset);
-}
-
fn detectAllocCollision(self: *MachO, start: u64, size: u64) ?u64 {
const hdr_size: u64 = @sizeOf(macho.mach_header_64);
if (start < hdr_size) return hdr_size;