aboutsummaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorLuuk de Gram <luuk@degram.dev>2024-01-24 16:52:46 +0100
committerLuuk de Gram <luuk@degram.dev>2024-02-29 15:23:04 +0100
commit8f96e7eec1b2af005e17bf21f91fc91add92d7dd (patch)
tree700d2e8440f4a111e5ad5687335124bc8f0a2010 /src/arch
parenta028b10b9f8213f5f31c06b57cd18f9852f0df13 (diff)
downloadzig-8f96e7eec1b2af005e17bf21f91fc91add92d7dd.tar.gz
zig-8f96e7eec1b2af005e17bf21f91fc91add92d7dd.zip
wasm: re-implement `updateExports`
We now correctly create a symbol for each exported decl with its export- name. The symbol points to the same linker-object. We store a map from decl to all of its exports so we can update exports if it already exists rather than infinitely create new exports.
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/wasm/CodeGen.zig2
-rw-r--r--src/arch/wasm/Emit.zig8
2 files changed, 5 insertions, 5 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig
index 314518caef..5440147296 100644
--- a/src/arch/wasm/CodeGen.zig
+++ b/src/arch/wasm/CodeGen.zig
@@ -2239,7 +2239,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif
}
if (callee) |direct| {
- const atom_index = func.bin_file.zigObjectPtr().?.decls.get(direct).?;
+ const atom_index = func.bin_file.zigObjectPtr().?.decls_map.get(direct).?.atom;
try func.addLabel(.call, func.bin_file.getAtom(atom_index).sym_index);
} else {
// in this case we call a function pointer
diff --git a/src/arch/wasm/Emit.zig b/src/arch/wasm/Emit.zig
index 3d495dcff6..31c15ce0ef 100644
--- a/src/arch/wasm/Emit.zig
+++ b/src/arch/wasm/Emit.zig
@@ -310,7 +310,7 @@ fn emitGlobal(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void {
const global_offset = emit.offset();
try emit.code.appendSlice(&buf);
- const atom_index = emit.bin_file.zigObjectPtr().?.decls.get(emit.decl_index).?;
+ const atom_index = emit.bin_file.zigObjectPtr().?.decls_map.get(emit.decl_index).?.atom;
const atom = emit.bin_file.getAtomPtr(atom_index);
try atom.relocs.append(gpa, .{
.index = label,
@@ -370,7 +370,7 @@ fn emitCall(emit: *Emit, inst: Mir.Inst.Index) !void {
try emit.code.appendSlice(&buf);
if (label != 0) {
- const atom_index = emit.bin_file.zigObjectPtr().?.decls.get(emit.decl_index).?;
+ const atom_index = emit.bin_file.zigObjectPtr().?.decls_map.get(emit.decl_index).?.atom;
const atom = emit.bin_file.getAtomPtr(atom_index);
try atom.relocs.append(gpa, .{
.offset = call_offset,
@@ -400,7 +400,7 @@ fn emitFunctionIndex(emit: *Emit, inst: Mir.Inst.Index) !void {
try emit.code.appendSlice(&buf);
if (symbol_index != 0) {
- const atom_index = emit.bin_file.zigObjectPtr().?.decls.get(emit.decl_index).?;
+ const atom_index = emit.bin_file.zigObjectPtr().?.decls_map.get(emit.decl_index).?.atom;
const atom = emit.bin_file.getAtomPtr(atom_index);
try atom.relocs.append(gpa, .{
.offset = index_offset,
@@ -431,7 +431,7 @@ fn emitMemAddress(emit: *Emit, inst: Mir.Inst.Index) !void {
}
if (mem.pointer != 0) {
- const atom_index = emit.bin_file.zigObjectPtr().?.decls.get(emit.decl_index).?;
+ const atom_index = emit.bin_file.zigObjectPtr().?.decls_map.get(emit.decl_index).?.atom;
const atom = emit.bin_file.getAtomPtr(atom_index);
try atom.relocs.append(gpa, .{
.offset = mem_offset,