mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
elf: fix 32bit build
This commit is contained in:
parent
8bd01eb7a9
commit
e5483b4ffc
@ -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;
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user