diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-05-23 12:03:46 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2024-05-23 12:04:17 +0200 |
| commit | d31eb744cec1d991def2d6d42a14ded82af1dbbe (patch) | |
| tree | f613ac6f06fe2cb46c58cd55eb1eaaee09990e07 /src/link/MachO/Object.zig | |
| parent | f3a503eca26e39e7a0870bf02c24b2879ae2cc18 (diff) | |
| download | zig-d31eb744cec1d991def2d6d42a14ded82af1dbbe.tar.gz zig-d31eb744cec1d991def2d6d42a14ded82af1dbbe.zip | |
link/macho: fix 32bit build
Diffstat (limited to 'src/link/MachO/Object.zig')
| -rw-r--r-- | src/link/MachO/Object.zig | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig index b3e5d01c6c..28c3c127e3 100644 --- a/src/link/MachO/Object.zig +++ b/src/link/MachO/Object.zig @@ -508,7 +508,7 @@ fn initPointerLiterals(self: *Object, macho_file: *MachO) !void { ); return error.MalformedObject; } - const num_ptrs = @divExact(sect.size, rec_size); + const num_ptrs = math.cast(usize, @divExact(sect.size, rec_size)) orelse return error.Overflow; for (0..num_ptrs) |i| { const pos: u32 = @as(u32, @intCast(i)) * rec_size; @@ -541,7 +541,9 @@ pub fn resolveLiterals(self: Object, lp: *MachO.LiteralPool, macho_file: *MachO) for (subs.items) |sub| { const atom = macho_file.getAtom(sub.atom).?; - const atom_data = data[atom.off..][0..atom.size]; + const atom_off = math.cast(usize, atom.off) orelse return error.Overflow; + const atom_size = math.cast(usize, atom.size) orelse return error.Overflow; + const atom_data = data[atom_off..][0..atom_size]; const res = try lp.insert(gpa, header.type(), atom_data); if (!res.found_existing) { res.atom.* = sub.atom; @@ -561,8 +563,9 @@ pub fn resolveLiterals(self: Object, lp: *MachO.LiteralPool, macho_file: *MachO) }; const addend = math.cast(u32, rel.addend) orelse return error.Overflow; const target_atom = macho_file.getAtom(target).?; - try buffer.ensureUnusedCapacity(target_atom.size); - buffer.resize(target_atom.size) catch unreachable; + const target_atom_size = math.cast(usize, target_atom.size) orelse return error.Overflow; + try buffer.ensureUnusedCapacity(target_atom_size); + buffer.resize(target_atom_size) catch unreachable; try target_atom.getData(macho_file, buffer.items); const res = try lp.insert(gpa, header.type(), buffer.items[addend..]); buffer.clearRetainingCapacity(); |
