diff options
| author | Luuk de Gram <luuk@degram.dev> | 2024-01-08 16:15:28 +0100 |
|---|---|---|
| committer | Luuk de Gram <luuk@degram.dev> | 2024-01-12 14:57:32 +0100 |
| commit | 2b3e6f680c5843877f6252bd3d85a20abe367da6 (patch) | |
| tree | e895655b3a7ca6ac29def54d6b0b8da968ce3552 /src/link/Wasm.zig | |
| parent | 63de8a59891f2c342d1a51b808cf04a895ba54d6 (diff) | |
| download | zig-2b3e6f680c5843877f6252bd3d85a20abe367da6.tar.gz zig-2b3e6f680c5843877f6252bd3d85a20abe367da6.zip | |
wasm-linker: ensure custom sections are parsed
Not all custom sections are represented by a symbol, which means the
section will not be parsed by the lazy parsing and therefore get garbage-
collected. This is problematic as it may contain debug information that
should not be garbage-collected. To resolve this, we manually create
local symbols for those sections and also ensure they do not get garbage-
collected.
Diffstat (limited to 'src/link/Wasm.zig')
| -rw-r--r-- | src/link/Wasm.zig | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 9dbef32648..34b0c62414 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -3260,7 +3260,7 @@ pub fn getMatchingSegment(wasm: *Wasm, object_index: u16, symbol_index: u32) !u3 break :blk index; }; } else if (mem.eql(u8, section_name, ".debug_ranges")) { - return wasm.debug_line_index orelse blk: { + return wasm.debug_ranges_index orelse blk: { wasm.debug_ranges_index = index; try wasm.appendDummySegment(); break :blk index; @@ -5301,14 +5301,8 @@ fn markReferences(wasm: *Wasm) !void { const object = &wasm.objects.items[file]; const atom_index = try Object.parseSymbolIntoAtom(object, file, sym_loc.index, wasm); const atom = wasm.getAtom(atom_index); - for (atom.relocs.items) |reloc| { - const target_loc: SymbolLoc = .{ .index = reloc.index, .file = atom.file }; - const target_sym = target_loc.getSymbol(wasm); - if (target_sym.isAlive() or !do_garbage_collect) { - sym.mark(); - continue; // Skip all other relocations as this debug atom is already marked now - } - } + const atom_sym = atom.symbolLoc().getSymbol(wasm); + atom_sym.mark(); } } } |
