From b90b080836734bc5c2d0f684ed2aad5c95ede453 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