mirror of
https://github.com/ziglang/zig.git
synced 2025-12-27 08:33:15 +00:00
elf: do not align end of archive to 2bytes; fix archive parser
This commit is contained in:
parent
a333ac846d
commit
ed2984f335
@ -1682,13 +1682,6 @@ pub fn flushStaticLib(self: *Elf, comp: *Compilation) link.File.FlushError!void
|
||||
pos += @sizeOf(Archive.ar_hdr) + entry[2];
|
||||
}
|
||||
|
||||
if (pos % 2 != 0) {
|
||||
pos += 1;
|
||||
try self.base.file.?.pwriteAll(&[1]u8{0}, pos);
|
||||
}
|
||||
|
||||
assert(mem.isAligned(pos, 2));
|
||||
|
||||
// TODO parsed positionals
|
||||
|
||||
// Magic bytes.
|
||||
|
||||
@ -85,11 +85,12 @@ pub fn parse(self: *Archive, elf_file: *Elf) !void {
|
||||
_ = try reader.readBytesNoEof(SARMAG);
|
||||
|
||||
while (true) {
|
||||
if (stream.pos >= self.data.len) break;
|
||||
|
||||
if (stream.pos % 2 != 0) {
|
||||
stream.pos += 1;
|
||||
}
|
||||
// TODO flag an error if stream.pos > self.data.len after alignment
|
||||
const hdr = reader.readStruct(ar_hdr) catch break;
|
||||
const hdr = try reader.readStruct(ar_hdr);
|
||||
|
||||
if (!mem.eql(u8, &hdr.ar_fmag, ARFMAG)) {
|
||||
// TODO convert into an error
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user