authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-12-31 14:57:05+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-12-31 14:57:08+01:00
logfbf269cc47a0a0bc0b60676ad97d4c57fda645c6
treeb6740270874896b91ed533d1f4c81a5c1f495aac
parent102e45e04feea00548134c2f31a62ad472f8bbd1

More MachO.zig fixes ensuring 32bit compat

Partial resolution to #7614.

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

src/link/MachO.zig+12-4
...@@ -1632,10 +1632,14 @@ pub fn populateMissingMetadata(self: *MachO) !void {...@@ -1632,10 +1632,14 @@ pub fn populateMissingMetadata(self: *MachO) !void {
1632 }1632 }
1633 if (self.dylinker_cmd_index == null) {1633 if (self.dylinker_cmd_index == null) {
1634 self.dylinker_cmd_index = @intCast(u16, self.load_commands.items.len);1634 self.dylinker_cmd_index = @intCast(u16, self.load_commands.items.len);
1635 const cmdsize = mem.alignForwardGeneric(u64, @sizeOf(macho.dylinker_command) + mem.lenZ(DEFAULT_DYLD_PATH), @sizeOf(u64));1635 const cmdsize = @intCast(u32, mem.alignForwardGeneric(
1636 u64,
1637 @sizeOf(macho.dylinker_command) + mem.lenZ(DEFAULT_DYLD_PATH),
1638 @sizeOf(u64),
1639 ));
1636 var dylinker_cmd = emptyGenericCommandWithData(macho.dylinker_command{1640 var dylinker_cmd = emptyGenericCommandWithData(macho.dylinker_command{
1637 .cmd = macho.LC_LOAD_DYLINKER,1641 .cmd = macho.LC_LOAD_DYLINKER,
1638 .cmdsize = @intCast(u32, cmdsize),1642 .cmdsize = cmdsize,
1639 .name = @sizeOf(macho.dylinker_command),1643 .name = @sizeOf(macho.dylinker_command),
1640 });1644 });
1641 dylinker_cmd.data = try self.base.allocator.alloc(u8, cmdsize - dylinker_cmd.inner.name);1645 dylinker_cmd.data = try self.base.allocator.alloc(u8, cmdsize - dylinker_cmd.inner.name);
...@@ -1647,13 +1651,17 @@ pub fn populateMissingMetadata(self: *MachO) !void {...@@ -1647,13 +1651,17 @@ pub fn populateMissingMetadata(self: *MachO) !void {
1647 }1651 }
1648 if (self.libsystem_cmd_index == null) {1652 if (self.libsystem_cmd_index == null) {
1649 self.libsystem_cmd_index = @intCast(u16, self.load_commands.items.len);1653 self.libsystem_cmd_index = @intCast(u16, self.load_commands.items.len);
1650 const cmdsize = mem.alignForwardGeneric(u64, @sizeOf(macho.dylib_command) + mem.lenZ(LIB_SYSTEM_PATH), @sizeOf(u64));1654 const cmdsize = @intCast(u32, mem.alignForwardGeneric(
1655 u64,
1656 @sizeOf(macho.dylib_command) + mem.lenZ(LIB_SYSTEM_PATH),
1657 @sizeOf(u64),
1658 ));
1651 // TODO Find a way to work out runtime version from the OS version triple stored in std.Target.1659 // TODO Find a way to work out runtime version from the OS version triple stored in std.Target.
1652 // In the meantime, we're gonna hardcode to the minimum compatibility version of 0.0.0.1660 // In the meantime, we're gonna hardcode to the minimum compatibility version of 0.0.0.
1653 const min_version = 0x0;1661 const min_version = 0x0;
1654 var dylib_cmd = emptyGenericCommandWithData(macho.dylib_command{1662 var dylib_cmd = emptyGenericCommandWithData(macho.dylib_command{
1655 .cmd = macho.LC_LOAD_DYLIB,1663 .cmd = macho.LC_LOAD_DYLIB,
1656 .cmdsize = @intCast(u32, cmdsize),1664 .cmdsize = cmdsize,
1657 .dylib = .{1665 .dylib = .{
1658 .name = @sizeOf(macho.dylib_command),1666 .name = @sizeOf(macho.dylib_command),
1659 .timestamp = 2, // not sure why not simply 0; this is reverse engineered from Mach-O files1667 .timestamp = 2, // not sure why not simply 0; this is reverse engineered from Mach-O files