From da55af1cae6065be5313946ec4c9acd465bb04ad Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Sun, 21 Apr 2024 00:27:16 +0200 Subject: [PATCH] link/elf: fix 32bit build --- src/link/Elf.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/link/Elf.zig b/src/link/Elf.zig index c182e7ab3e..975e5da045 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -3399,15 +3399,15 @@ pub fn writeMergeSections(self: *Elf) !void { for (self.merge_sections.items) |msec| { const shdr = self.shdrs.items[msec.output_section_index]; - - try buffer.ensureTotalCapacity(shdr.sh_size); - buffer.appendNTimesAssumeCapacity(0, shdr.sh_size); + const size = math.cast(usize, shdr.sh_size) orelse return error.Overflow; + try buffer.ensureTotalCapacity(size); + buffer.appendNTimesAssumeCapacity(0, size); for (msec.subsections.items) |msub_index| { const msub = self.mergeSubsection(msub_index); assert(msub.alive); const string = msub.getString(self); - const off: u64 = @intCast(msub.value); + const off = math.cast(usize, msub.value) orelse return error.Overflow; @memcpy(buffer.items[off..][0..string.len], string); }