aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-06-16 21:57:33 -0700
committerGitHub <noreply@github.com>2023-06-16 21:57:33 -0700
commit78c8cb4225c3c3d429764151ad703a4bfa67d75a (patch)
tree8352b61ff54c133f78e4b8d1e05714561ee105bb /src/codegen.zig
parent0f5aff34414bcb024443540fe905039f3783803a (diff)
parent5343a2f566a5c235055f4aebb4ab9c10773e57f0 (diff)
downloadzig-78c8cb4225c3c3d429764151ad703a4bfa67d75a.tar.gz
zig-78c8cb4225c3c3d429764151ad703a4bfa67d75a.zip
Merge pull request #16003 from g-w1/plan9-lazy-syms
Plan9: lots of fixes
Diffstat (limited to 'src/codegen.zig')
-rw-r--r--src/codegen.zig16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/codegen.zig b/src/codegen.zig
index b39c3c5ec0..d446200a3b 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -852,10 +852,9 @@ fn genDeclRef(
const sym_index = coff_file.getAtom(atom_index).getSymbolIndex().?;
return GenResult.mcv(.{ .load_got = sym_index });
} else if (bin_file.cast(link.File.Plan9)) |p9| {
- const decl_block_index = try p9.seeDecl(decl_index);
- const decl_block = p9.getDeclBlock(decl_block_index);
- const got_addr = p9.bases.data + decl_block.got_index.? * ptr_bytes;
- return GenResult.mcv(.{ .memory = got_addr });
+ const atom_index = try p9.seeDecl(decl_index);
+ const atom = p9.getAtom(atom_index);
+ return GenResult.mcv(.{ .memory = atom.getOffsetTableAddress(p9) });
} else {
return GenResult.fail(bin_file.allocator, src_loc, "TODO genDeclRef for target {}", .{target});
}
@@ -880,12 +879,9 @@ fn genUnnamedConst(
return GenResult.mcv(.{ .load_direct = local_sym_index });
} else if (bin_file.cast(link.File.Coff)) |_| {
return GenResult.mcv(.{ .load_direct = local_sym_index });
- } else if (bin_file.cast(link.File.Plan9)) |p9| {
- const ptr_bits = target.ptrBitWidth();
- const ptr_bytes: u64 = @divExact(ptr_bits, 8);
- const got_index = local_sym_index; // the plan9 backend returns the got_index
- const got_addr = p9.bases.data + got_index * ptr_bytes;
- return GenResult.mcv(.{ .memory = got_addr });
+ } else if (bin_file.cast(link.File.Plan9)) |_| {
+ const atom_index = local_sym_index; // plan9 returns the atom_index
+ return GenResult.mcv(.{ .load_direct = atom_index });
} else {
return GenResult.fail(bin_file.allocator, src_loc, "TODO genUnnamedConst for target {}", .{target});
}