authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-12-28 18:57:18-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-15 15:11:36-08:00
logc5822879a1da97e6c381c6684f4b9281400e5de0
tree023152ba6b374af83c88042542f492374484bbdc
parentb7a95911ab209b7b0657f9eb135c64d9c47ac561

fix bad archive name calculation


2 files changed, 4 insertions(+), 4 deletions(-)

src/link/Wasm.zig+1-2
...@@ -2462,8 +2462,7 @@ fn parseArchive(wasm: *Wasm, obj: link.Input.Object) !void {...@@ -2462,8 +2462,7 @@ fn parseArchive(wasm: *Wasm, obj: link.Input.Object) !void {
24622462
2463 try wasm.objects.ensureUnusedCapacity(gpa, offsets.count());2463 try wasm.objects.ensureUnusedCapacity(gpa, offsets.count());
2464 for (offsets.keys()) |file_offset| {2464 for (offsets.keys()) |file_offset| {
2465 const contents = file_contents[file_offset..];2465 const object = try archive.parseObject(wasm, file_contents, file_offset, obj.path, wasm.object_host_name, &ss, obj.must_link, gc_sections);
2466 const object = try archive.parseObject(wasm, contents, obj.path, wasm.object_host_name, &ss, obj.must_link, gc_sections);
2467 wasm.objects.appendAssumeCapacity(object);2466 wasm.objects.appendAssumeCapacity(object);
2468 }2467 }
2469}2468}
src/link/Wasm/Archive.zig+3-2
...@@ -146,13 +146,14 @@ pub fn parseObject(...@@ -146,13 +146,14 @@ pub fn parseObject(
146 archive: Archive,146 archive: Archive,
147 wasm: *Wasm,147 wasm: *Wasm,
148 file_contents: []const u8,148 file_contents: []const u8,
149 object_offset: u32,
149 path: Path,150 path: Path,
150 host_name: Wasm.OptionalString,151 host_name: Wasm.OptionalString,
151 scratch_space: *Object.ScratchSpace,152 scratch_space: *Object.ScratchSpace,
152 must_link: bool,153 must_link: bool,
153 gc_sections: bool,154 gc_sections: bool,
154) !Object {155) !Object {
155 const header = mem.bytesAsValue(Header, file_contents[0..@sizeOf(Header)]);156 const header = mem.bytesAsValue(Header, file_contents[object_offset..][0..@sizeOf(Header)]);
156 if (!mem.eql(u8, &header.fmag, ARFMAG)) return error.BadHeaderDelimiter;157 if (!mem.eql(u8, &header.fmag, ARFMAG)) return error.BadHeaderDelimiter;
157158
158 const name_or_index = try header.nameOrIndex();159 const name_or_index = try header.nameOrIndex();
...@@ -166,7 +167,7 @@ pub fn parseObject(...@@ -166,7 +167,7 @@ pub fn parseObject(
166 };167 };
167168
168 const object_file_size = try header.parsedSize();169 const object_file_size = try header.parsedSize();
169 const contents = file_contents[@sizeOf(Header)..][0..object_file_size];170 const contents = file_contents[object_offset + @sizeOf(Header) ..][0..object_file_size];
170171
171 return Object.parse(wasm, contents, path, object_name, host_name, scratch_space, must_link, gc_sections);172 return Object.parse(wasm, contents, path, object_name, host_name, scratch_space, must_link, gc_sections);
172}173}