diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-10-03 14:55:18 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-10-03 12:49:12 -0700 |
| commit | 0134e5d2a1a5042b1485b7bb121870d2eaeb00b6 (patch) | |
| tree | 1c5e41cffa699a0e396a08771152d6e024a61af5 /src/link.zig | |
| parent | 0483b4a5126c0d07b1e9ad298729e8d34b5d2272 (diff) | |
| download | zig-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/link.zig')
| -rw-r--r-- | src/link.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/link.zig b/src/link.zig index 3c4a6d18f4..1cc187c3f4 100644 --- a/src/link.zig +++ b/src/link.zig @@ -937,6 +937,22 @@ pub const File = struct { } } + pub const LowerResult = @import("codegen.zig").Result; + + pub fn lowerAnonDecl(base: *File, decl_val: InternPool.Index, src_loc: Module.SrcLoc) !LowerResult { + if (build_options.only_c) unreachable; + switch (base.tag) { + .coff => return @fieldParentPtr(Coff, "base", base).lowerAnonDecl(decl_val, src_loc), + .elf => return @fieldParentPtr(Elf, "base", base).lowerAnonDecl(decl_val, src_loc), + .macho => return @fieldParentPtr(MachO, "base", base).lowerAnonDecl(decl_val, src_loc), + .plan9 => return @fieldParentPtr(Plan9, "base", base).lowerAnonDecl(decl_val, src_loc), + .c => unreachable, + .wasm => return @fieldParentPtr(Wasm, "base", base).lowerAnonDecl(decl_val, src_loc), + .spirv => unreachable, + .nvptx => unreachable, + } + } + pub fn getAnonDeclVAddr(base: *File, decl_val: InternPool.Index, reloc_info: RelocInfo) !u64 { if (build_options.only_c) unreachable; switch (base.tag) { |
