aboutsummaryrefslogtreecommitdiff
path: root/src/arch/x86_64/CodeGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-10-29 17:45:00 -0400
committerGitHub <noreply@github.com>2022-10-29 17:45:00 -0400
commit28dc208f65c0a3feca4d6018fb316d7c219d29a7 (patch)
tree80b19479b1a50431e138e138cb8eaaf750905db6 /src/arch/x86_64/CodeGen.zig
parente036cc48d59e5f7c025df7bbd9923a13e30c6ec9 (diff)
parent5aef54cbc83cce5c1afe9aededfc505d89559741 (diff)
downloadzig-28dc208f65c0a3feca4d6018fb316d7c219d29a7.tar.gz
zig-28dc208f65c0a3feca4d6018fb316d7c219d29a7.zip
Merge pull request #13082 from g-w1/unnamed-decls-and-relocs-p9
Plan9: Fix The Backend
Diffstat (limited to 'src/arch/x86_64/CodeGen.zig')
-rw-r--r--src/arch/x86_64/CodeGen.zig8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig
index 965a34251c..7b9ef863ae 100644
--- a/src/arch/x86_64/CodeGen.zig
+++ b/src/arch/x86_64/CodeGen.zig
@@ -6953,8 +6953,12 @@ fn lowerUnnamedConst(self: *Self, tv: TypedValue) InnerError!MCValue {
.@"type" = .direct,
.sym_index = local_sym_index,
} };
- } else if (self.bin_file.cast(link.File.Plan9)) |_| {
- return self.fail("TODO lower unnamed const in Plan9", .{});
+ } else if (self.bin_file.cast(link.File.Plan9)) |p9| {
+ const ptr_bits = self.target.cpu.arch.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 MCValue{ .memory = got_addr };
} else {
return self.fail("TODO lower unnamed const", .{});
}