From 96001011ecf85c1b08d4de843ce38a15a68ad6b5 Mon Sep 17 00:00:00 2001 From: xtex Date: Tue, 6 Oct 2026 11:13:22 +0800 Subject: [PATCH] objcopy: call seekTo after setLength Previously, --pad-to is implemented using File.setLength which does a ftruncate syscall immediately. However, for positional writers, setLength will be called again in out.end(), truncating the file back to out.pos bytes. Therefore, seekTo should be called after setLength to update out.pos. --- lib/compiler/objcopy.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/compiler/objcopy.zig b/lib/compiler/objcopy.zig index 02573432905f61cbbdd3756db86c6e4b9a2aa3f6..34504ee084b7f3f20680df62b5f3ff6d4a67159d 100644 --- a/lib/compiler/objcopy.zig +++ b/lib/compiler/objcopy.zig @@ -669,6 +669,7 @@ fn padFile(out: *File.Writer, opt_size: ?u64) !void { const io = out.io; const size = opt_size orelse return; try out.file.setLength(io, size); + try out.seekTo(size); } test "HexWriter.Record.Address has correct payload and checksum" { -- 2.54.0