aboutsummaryrefslogtreecommitdiff
path: root/src/link
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2020-12-31 14:57:05 +0100
committerJakub Konka <kubkon@jakubkonka.com>2020-12-31 14:57:08 +0100
commitfbf269cc47a0a0bc0b60676ad97d4c57fda645c6 (patch)
treeb6740270874896b91ed533d1f4c81a5c1f495aac /src/link
parent102e45e04feea00548134c2f31a62ad472f8bbd1 (diff)
downloadzig-fbf269cc47a0a0bc0b60676ad97d4c57fda645c6.tar.gz
zig-fbf269cc47a0a0bc0b60676ad97d4c57fda645c6.zip
More MachO.zig fixes ensuring 32bit compat
Partial resolution to #7614.
Diffstat (limited to 'src/link')
-rw-r--r--src/link/MachO.zig16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index ea6dcbbc33..88cb40db3d 100644
--- a/src/link/MachO.zig
+++ b/src/link/MachO.zig
@@ -1632,10 +1632,14 @@ pub fn populateMissingMetadata(self: *MachO) !void {
}
if (self.dylinker_cmd_index == null) {
self.dylinker_cmd_index = @intCast(u16, self.load_commands.items.len);
- const cmdsize = mem.alignForwardGeneric(u64, @sizeOf(macho.dylinker_command) + mem.lenZ(DEFAULT_DYLD_PATH), @sizeOf(u64));
+ const cmdsize = @intCast(u32, mem.alignForwardGeneric(
+ u64,
+ @sizeOf(macho.dylinker_command) + mem.lenZ(DEFAULT_DYLD_PATH),
+ @sizeOf(u64),
+ ));
var dylinker_cmd = emptyGenericCommandWithData(macho.dylinker_command{
.cmd = macho.LC_LOAD_DYLINKER,
- .cmdsize = @intCast(u32, cmdsize),
+ .cmdsize = cmdsize,
.name = @sizeOf(macho.dylinker_command),
});
dylinker_cmd.data = try self.base.allocator.alloc(u8, cmdsize - dylinker_cmd.inner.name);
@@ -1647,13 +1651,17 @@ pub fn populateMissingMetadata(self: *MachO) !void {
}
if (self.libsystem_cmd_index == null) {
self.libsystem_cmd_index = @intCast(u16, self.load_commands.items.len);
- const cmdsize = mem.alignForwardGeneric(u64, @sizeOf(macho.dylib_command) + mem.lenZ(LIB_SYSTEM_PATH), @sizeOf(u64));
+ const cmdsize = @intCast(u32, mem.alignForwardGeneric(
+ u64,
+ @sizeOf(macho.dylib_command) + mem.lenZ(LIB_SYSTEM_PATH),
+ @sizeOf(u64),
+ ));
// TODO Find a way to work out runtime version from the OS version triple stored in std.Target.
// In the meantime, we're gonna hardcode to the minimum compatibility version of 0.0.0.
const min_version = 0x0;
var dylib_cmd = emptyGenericCommandWithData(macho.dylib_command{
.cmd = macho.LC_LOAD_DYLIB,
- .cmdsize = @intCast(u32, cmdsize),
+ .cmdsize = cmdsize,
.dylib = .{
.name = @sizeOf(macho.dylib_command),
.timestamp = 2, // not sure why not simply 0; this is reverse engineered from Mach-O files