elf: fix 32bit build

This commit is contained in:
Jakub Konka 2024-02-13 10:48:10 +01:00
parent 8bd01eb7a9
commit e5483b4ffc
2 changed files with 5 additions and 3 deletions

View File

@ -5903,8 +5903,8 @@ fn fmtDumpState(
}
/// Caller owns the memory.
pub fn preadAllAlloc(allocator: Allocator, handle: std.fs.File, offset: usize, size: usize) ![]u8 {
const buffer = try allocator.alloc(u8, size);
pub fn preadAllAlloc(allocator: Allocator, handle: std.fs.File, offset: u64, size: u64) ![]u8 {
const buffer = try allocator.alloc(u8, math.cast(usize, size) orelse return error.Overflow);
errdefer allocator.free(buffer);
const amt = try handle.preadAll(buffer, offset);
if (amt != size) return error.InputOutput;

View File

@ -945,7 +945,9 @@ fn preadShdrContentsAlloc(self: Object, allocator: Allocator, handle: std.fs.Fil
assert(index < self.shdrs.items.len);
const offset = if (self.archive) |ar| ar.offset else 0;
const shdr = self.shdrs.items[index];
return Elf.preadAllAlloc(allocator, handle, offset + shdr.sh_offset, shdr.sh_size);
const sh_offset = math.cast(u64, shdr.sh_offset) orelse return error.Overflow;
const sh_size = math.cast(u64, shdr.sh_size) orelse return error.Overflow;
return Elf.preadAllAlloc(allocator, handle, offset + sh_offset, sh_size);
}
/// Caller owns the memory.