authorgravatar for xtex@astrafall.orgxtex <xtex@astrafall.org> 2026-10-06 11:13:22+08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-10-09 15:50:50-07:00
log96001011ecf85c1b08d4de843ce38a15a68ad6b5
tree5a109b3b5524df446c34e218ed9694a8a9f45795
parent2f9d5cc454477deeea5f98d5e550be07fc1770c5

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.

1 files changed, 1 insertions(+), 0 deletions(-)

lib/compiler/objcopy.zig+1
......@@ -669,6 +669,7 @@ fn padFile(out: *File.Writer, opt_size: ?u64) !void {
669669 const io = out.io;
670670 const size = opt_size orelse return;
671671 try out.file.setLength(io, size);
672 try out.seekTo(size);
672673}
673674
674675test "HexWriter.Record.Address has correct payload and checksum" {