aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-10-03 14:55:18 +0200
committerAndrew Kelley <andrew@ziglang.org>2023-10-03 12:49:12 -0700
commit0134e5d2a1a5042b1485b7bb121870d2eaeb00b6 (patch)
tree1c5e41cffa699a0e396a08771152d6e024a61af5 /src/codegen.zig
parent0483b4a5126c0d07b1e9ad298729e8d34b5d2272 (diff)
downloadzig-0134e5d2a1a5042b1485b7bb121870d2eaeb00b6.tar.gz
zig-0134e5d2a1a5042b1485b7bb121870d2eaeb00b6.zip
codegen: separate getAnonDeclVAddr into lowerAnonDecl and the former
Implement the stub for Elf. I believe that separating the concerns, namely, having an interface function that is responsible for signalling the linker to lower the anon decl only, and a separate function to obtain the decl's vaddr is preferable since it allows us to handle codegen errors in a simpler way.
Diffstat (limited to 'src/codegen.zig')
-rw-r--r--src/codegen.zig7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/codegen.zig b/src/codegen.zig
index f2eff7806a..dd1b6e0cbf 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -739,7 +739,6 @@ fn lowerAnonDeclRef(
debug_output: DebugInfoOutput,
reloc_info: RelocInfo,
) CodeGenError!Result {
- _ = src_loc;
_ = debug_output;
const target = bin_file.options.target;
const mod = bin_file.options.module.?;
@@ -752,6 +751,12 @@ fn lowerAnonDeclRef(
return Result.ok;
}
+ const res = try bin_file.lowerAnonDecl(decl_val, src_loc);
+ switch (res) {
+ .ok => {},
+ .fail => |em| return .{ .fail = em },
+ }
+
const vaddr = try bin_file.getAnonDeclVAddr(decl_val, .{
.parent_atom_index = reloc_info.parent_atom_index,
.offset = code.items.len,