| ... | ... | @@ -538,6 +538,7 @@ fn resolveSymbolsInArchives(self: *Wasm) !void { |
| 538 | 538 | continue; |
| 539 | 539 | }; |
| 540 | 540 | |
| 541 | log.debug("Detected symbol '{s}' in archive '{s}', parsing objects..", .{ sym_name, archive.name }); |
| 541 | 542 | // Symbol is found in unparsed object file within current archive. |
| 542 | 543 | // Parse object and and resolve symbols again before we check remaining |
| 543 | 544 | // undefined symbols. |
| ... | ... | @@ -581,11 +582,17 @@ pub fn deinit(self: *Wasm) void { |
| 581 | 582 | object.deinit(gpa); |
| 582 | 583 | } |
| 583 | 584 | |
| 585 | for (self.archives.items) |*archive| { |
| 586 | archive.file.close(); |
| 587 | archive.deinit(gpa); |
| 588 | } |
| 589 | |
| 584 | 590 | self.decls.deinit(gpa); |
| 585 | 591 | self.symbols.deinit(gpa); |
| 586 | 592 | self.symbols_free_list.deinit(gpa); |
| 587 | 593 | self.globals.deinit(gpa); |
| 588 | 594 | self.resolved_symbols.deinit(gpa); |
| 595 | self.undefs.deinit(gpa); |
| 589 | 596 | self.discarded.deinit(gpa); |
| 590 | 597 | self.symbol_atom.deinit(gpa); |
| 591 | 598 | self.export_names.deinit(gpa); |
| ... | ... | @@ -599,6 +606,7 @@ pub fn deinit(self: *Wasm) void { |
| 599 | 606 | self.data_segments.deinit(gpa); |
| 600 | 607 | self.segment_info.deinit(gpa); |
| 601 | 608 | self.objects.deinit(gpa); |
| 609 | self.archives.deinit(gpa); |
| 602 | 610 | |
| 603 | 611 | // free output sections |
| 604 | 612 | self.imports.deinit(gpa); |
| ... | ... | @@ -1838,10 +1846,10 @@ pub fn flushModule(self: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod |
| 1838 | 1846 | |
| 1839 | 1847 | try self.parseInputFiles(positionals.items); |
| 1840 | 1848 | |
| 1841 | | var object_index: u16 = 0; |
| 1842 | | while (object_index < self.objects.items.len) : (object_index += 1) { |
| 1843 | | try self.resolveSymbolsInObject(object_index); |
| 1849 | for (self.objects.items) |_, object_index| { |
| 1850 | try self.resolveSymbolsInObject(@intCast(u16, object_index)); |
| 1844 | 1851 | } |
| 1852 | |
| 1845 | 1853 | try self.resolveSymbolsInArchives(); |
| 1846 | 1854 | |
| 1847 | 1855 | // When we finish/error we reset the state of the linker |
| ... | ... | @@ -1867,9 +1875,8 @@ pub fn flushModule(self: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod |
| 1867 | 1875 | } |
| 1868 | 1876 | } |
| 1869 | 1877 | |
| 1870 | | while (object_index > 0) { |
| 1871 | | object_index -= 1; |
| 1872 | | try self.objects.items[object_index].parseIntoAtoms(self.base.allocator, object_index, self); |
| 1878 | for (self.objects.items) |*object, object_index| { |
| 1879 | try object.parseIntoAtoms(self.base.allocator, @intCast(u16, object_index), self); |
| 1873 | 1880 | } |
| 1874 | 1881 | |
| 1875 | 1882 | if (self.dwarf) |*dwarf| { |