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 {
16321632 }
16331633 if (self.dylinker_cmd_index == null) {
16341634 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 ));
16361640 var dylinker_cmd = emptyGenericCommandWithData(macho.dylinker_command{
16371641 .cmd = macho.LC_LOAD_DYLINKER,
1638 .cmdsize = @intCast(u32, cmdsize),
1642 .cmdsize = cmdsize,
16391643 .name = @sizeOf(macho.dylinker_command),
16401644 });
16411645 dylinker_cmd.data = try self.base.allocator.alloc(u8, cmdsize - dylinker_cmd.inner.name);
......@@ -1647,13 +1651,17 @@ pub fn populateMissingMetadata(self: *MachO) !void {
16471651 }
16481652 if (self.libsystem_cmd_index == null) {
16491653 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 ));
16511659 // TODO Find a way to work out runtime version from the OS version triple stored in std.Target.
16521660 // In the meantime, we're gonna hardcode to the minimum compatibility version of 0.0.0.
16531661 const min_version = 0x0;
16541662 var dylib_cmd = emptyGenericCommandWithData(macho.dylib_command{
16551663 .cmd = macho.LC_LOAD_DYLIB,
1656 .cmdsize = @intCast(u32, cmdsize),
1664 .cmdsize = cmdsize,
16571665 .dylib = .{
16581666 .name = @sizeOf(macho.dylib_command),
16591667 .timestamp = 2, // not sure why not simply 0; this is reverse engineered from Mach-O files