aboutsummaryrefslogtreecommitdiff
path: root/src/link/Wasm/Atom.zig
diff options
context:
space:
mode:
authorLuuk de Gram <luuk@degram.dev>2023-01-27 19:24:15 +0100
committerLuuk de Gram <luuk@degram.dev>2023-01-27 19:24:15 +0100
commitb25efb86e1b1b2a9e8aa269bf83b717d54f7e276 (patch)
tree774b958f096b5eb6363b0326b294ca8c9b57e4af /src/link/Wasm/Atom.zig
parentcc1d7a0e315ba63b0d8c0cd647b4c7e92a571bf2 (diff)
downloadzig-b25efb86e1b1b2a9e8aa269bf83b717d54f7e276.tar.gz
zig-b25efb86e1b1b2a9e8aa269bf83b717d54f7e276.zip
wasm: migrate to new non-allocateDeclIndexes API
Diffstat (limited to 'src/link/Wasm/Atom.zig')
-rw-r--r--src/link/Wasm/Atom.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/link/Wasm/Atom.zig b/src/link/Wasm/Atom.zig
index de9cefebdc..20f847e475 100644
--- a/src/link/Wasm/Atom.zig
+++ b/src/link/Wasm/Atom.zig
@@ -95,6 +95,17 @@ pub fn symbolLoc(atom: Atom) Wasm.SymbolLoc {
return .{ .file = atom.file, .index = atom.sym_index };
}
+pub fn ensureInitialized(atom: *Atom, wasm_bin: *Wasm) !void {
+ if (atom.getSymbolIndex() != null) return; // already initialized
+ atom.sym_index = try wasm_bin.allocateSymbol();
+ try wasm_bin.symbol_atom.putNoClobber(wasm_bin.base.allocator, atom.symbolLoc(), atom);
+}
+
+pub fn getSymbolIndex(atom: Atom) ?u32 {
+ if (atom.sym_index == 0) return null;
+ return atom.sym_index;
+}
+
/// Returns the virtual address of the `Atom`. This is the address starting
/// from the first entry within a section.
pub fn getVA(atom: Atom, wasm: *const Wasm, symbol: *const Symbol) u32 {