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 | |
| parent | f3a503eca26e39e7a0870bf02c24b2879ae2cc18 (diff) | |
| download | zig-d31eb744cec1d991def2d6d42a14ded82af1dbbe.tar.gz zig-d31eb744cec1d991def2d6d42a14ded82af1dbbe.zip | |
link/macho: fix 32bit build
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/MachO/InternalObject.zig | 5 | ||||
| -rw-r--r-- | src/link/MachO/Object.zig | 11 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/link/MachO/InternalObject.zig b/src/link/MachO/InternalObject.zig index 10f81355f0..cbc7f3025c 100644 --- a/src/link/MachO/InternalObject.zig +++ b/src/link/MachO/InternalObject.zig @@ -134,8 +134,9 @@ pub fn resolveLiterals(self: InternalObject, lp: *MachO.LiteralPool, macho_file: assert(rel.tag == .local); const target = macho_file.getAtom(rel.target).?; const addend = std.math.cast(u32, rel.addend) orelse return error.Overflow; - try buffer.ensureUnusedCapacity(target.size); - buffer.resize(target.size) catch unreachable; + const target_size = std.math.cast(usize, target.size) orelse return error.Overflow; + try buffer.ensureUnusedCapacity(target_size); + buffer.resize(target_size) catch unreachable; try target.getData(macho_file, buffer.items); const res = try lp.insert(gpa, header.type(), buffer.items[addend..]); buffer.clearRetainingCapacity(); 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(); |
