| author | |
| committer | |
| log | 4ca9b4c44a4fbe2b64b11d2c8a951c2c3e961619 |
| tree | 210ed90046909bef6a650a0f74fc94935212f513 |
| parent | 1a80315836f77e38eee3e4c0a646b82febbc3604 |
4 files changed, 45 insertions(+), 48 deletions(-)
src/codegen.zig+15-16| ... | ... | @@ -1,26 +1,25 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const build_options = @import("build_options"); | |
| 2 | 3 | const builtin = @import("builtin"); |
| 4 | const assert = std.debug.assert; | |
| 5 | const leb128 = std.leb; | |
| 6 | const link = @import("link.zig"); | |
| 7 | const log = std.log.scoped(.codegen); | |
| 3 | 8 | const mem = std.mem; |
| 4 | 9 | const math = std.math; |
| 5 | const assert = std.debug.assert; | |
| 10 | const trace = @import("tracy.zig").trace; | |
| 11 | ||
| 6 | 12 | const Air = @import("Air.zig"); |
| 7 | const Zir = @import("Zir.zig"); | |
| 8 | const Liveness = @import("Liveness.zig"); | |
| 9 | const Type = @import("type.zig").Type; | |
| 10 | const Value = @import("value.zig").Value; | |
| 11 | const TypedValue = @import("TypedValue.zig"); | |
| 12 | const link = @import("link.zig"); | |
| 13 | const Module = @import("Module.zig"); | |
| 13 | const Allocator = mem.Allocator; | |
| 14 | 14 | const Compilation = @import("Compilation.zig"); |
| 15 | 15 | const ErrorMsg = Module.ErrorMsg; |
| 16 | const Liveness = @import("Liveness.zig"); | |
| 17 | const Module = @import("Module.zig"); | |
| 16 | 18 | const Target = std.Target; |
| 17 | const Allocator = mem.Allocator; | |
| 18 | const trace = @import("tracy.zig").trace; | |
| 19 | const DW = std.dwarf; | |
| 20 | const leb128 = std.leb; | |
| 21 | const log = std.log.scoped(.codegen); | |
| 22 | const build_options = @import("build_options"); | |
| 23 | const RegisterManager = @import("register_manager.zig").RegisterManager; | |
| 19 | const Type = @import("type.zig").Type; | |
| 20 | const TypedValue = @import("TypedValue.zig"); | |
| 21 | const Value = @import("value.zig").Value; | |
| 22 | const Zir = @import("Zir.zig"); | |
| 24 | 23 | |
| 25 | 24 | pub const FnResult = union(enum) { |
| 26 | 25 | /// The `code` parameter passed to `generateSymbol` has the value appended. |
| ... | ... | @@ -46,7 +45,7 @@ pub const DebugInfoOutput = union(enum) { |
| 46 | 45 | dwarf: struct { |
| 47 | 46 | dbg_line: *std.ArrayList(u8), |
| 48 | 47 | dbg_info: *std.ArrayList(u8), |
| 49 | dbg_info_type_relocs: *link.File.DbgInfoTypeRelocsTable, | |
| 48 | dbg_info_type_relocs: *link.File.Dwarf.DbgInfoTypeRelocsTable, | |
| 50 | 49 | }, |
| 51 | 50 | /// the plan9 debuginfo output is a bytecode with 4 opcodes |
| 52 | 51 | /// assume all numbers/variables are bytes |
src/link.zig+10-28| ... | ... | @@ -1,22 +1,22 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const build_options = @import("build_options"); | |
| 2 | 3 | const builtin = @import("builtin"); |
| 3 | const mem = std.mem; | |
| 4 | const Allocator = std.mem.Allocator; | |
| 4 | const assert = std.debug.assert; | |
| 5 | 5 | const fs = std.fs; |
| 6 | const mem = std.mem; | |
| 6 | 7 | const log = std.log.scoped(.link); |
| 7 | const assert = std.debug.assert; | |
| 8 | const trace = @import("tracy.zig").trace; | |
| 9 | const wasi_libc = @import("wasi_libc.zig"); | |
| 8 | 10 | |
| 11 | const Air = @import("Air.zig"); | |
| 12 | const Allocator = std.mem.Allocator; | |
| 13 | const Cache = @import("Cache.zig"); | |
| 9 | 14 | const Compilation = @import("Compilation.zig"); |
| 15 | const LibCInstallation = @import("libc_installation.zig").LibCInstallation; | |
| 16 | const Liveness = @import("Liveness.zig"); | |
| 10 | 17 | const Module = @import("Module.zig"); |
| 11 | const trace = @import("tracy.zig").trace; | |
| 12 | 18 | const Package = @import("Package.zig"); |
| 13 | 19 | const Type = @import("type.zig").Type; |
| 14 | const Cache = @import("Cache.zig"); | |
| 15 | const build_options = @import("build_options"); | |
| 16 | const LibCInstallation = @import("libc_installation.zig").LibCInstallation; | |
| 17 | const wasi_libc = @import("wasi_libc.zig"); | |
| 18 | const Air = @import("Air.zig"); | |
| 19 | const Liveness = @import("Liveness.zig"); | |
| 20 | 20 | const TypedValue = @import("TypedValue.zig"); |
| 21 | 21 | |
| 22 | 22 | pub const SystemLib = struct { |
| ... | ... | @@ -245,24 +245,6 @@ pub const File = struct { |
| 245 | 245 | nvptx: void, |
| 246 | 246 | }; |
| 247 | 247 | |
| 248 | /// For DWARF .debug_info. | |
| 249 | pub const DbgInfoTypeRelocsTable = std.ArrayHashMapUnmanaged( | |
| 250 | Type, | |
| 251 | DbgInfoTypeReloc, | |
| 252 | Type.HashContext32, | |
| 253 | true, | |
| 254 | ); | |
| 255 | ||
| 256 | /// For DWARF .debug_info. | |
| 257 | pub const DbgInfoTypeReloc = struct { | |
| 258 | /// Offset from `TextBlock.dbg_info_off` (the buffer that is local to a Decl). | |
| 259 | /// This is where the .debug_info tag for the type is. | |
| 260 | off: u32, | |
| 261 | /// Offset from `TextBlock.dbg_info_off` (the buffer that is local to a Decl). | |
| 262 | /// List of DW.AT.type / DW.FORM.ref4 that points to the type. | |
| 263 | relocs: std.ArrayListUnmanaged(u32), | |
| 264 | }; | |
| 265 | ||
| 266 | 248 | /// Attempts incremental linking, if the file already exists. If |
| 267 | 249 | /// incremental linking fails, falls back to truncating the file and |
| 268 | 250 | /// rewriting it. A malicious file is detected as incremental link failure |
src/link/Dwarf.zig+19-3| ... | ... | @@ -82,6 +82,22 @@ pub const SrcFn = struct { |
| 82 | 82 | |
| 83 | 83 | pub const PtrWidth = enum { p32, p64 }; |
| 84 | 84 | |
| 85 | pub const DbgInfoTypeRelocsTable = std.ArrayHashMapUnmanaged( | |
| 86 | Type, | |
| 87 | DbgInfoTypeReloc, | |
| 88 | Type.HashContext32, | |
| 89 | true, | |
| 90 | ); | |
| 91 | ||
| 92 | pub const DbgInfoTypeReloc = struct { | |
| 93 | /// Offset from `TextBlock.dbg_info_off` (the buffer that is local to a Decl). | |
| 94 | /// This is where the .debug_info tag for the type is. | |
| 95 | off: u32, | |
| 96 | /// Offset from `TextBlock.dbg_info_off` (the buffer that is local to a Decl). | |
| 97 | /// List of DW.AT.type / DW.FORM.ref4 that points to the type. | |
| 98 | relocs: std.ArrayListUnmanaged(u32), | |
| 99 | }; | |
| 100 | ||
| 85 | 101 | pub const abbrev_compile_unit = 1; |
| 86 | 102 | pub const abbrev_subprogram = 2; |
| 87 | 103 | pub const abbrev_subprogram_retvoid = 3; |
| ... | ... | @@ -138,7 +154,7 @@ pub fn deinit(self: *Dwarf) void { |
| 138 | 154 | pub const DeclDebugBuffers = struct { |
| 139 | 155 | dbg_line_buffer: std.ArrayList(u8), |
| 140 | 156 | dbg_info_buffer: std.ArrayList(u8), |
| 141 | dbg_info_type_relocs: File.DbgInfoTypeRelocsTable, | |
| 157 | dbg_info_type_relocs: DbgInfoTypeRelocsTable, | |
| 142 | 158 | }; |
| 143 | 159 | |
| 144 | 160 | pub fn initDeclDebugInfo(self: *Dwarf, decl: *Module.Decl) !DeclDebugBuffers { |
| ... | ... | @@ -153,7 +169,7 @@ pub fn initDeclDebugInfo(self: *Dwarf, decl: *Module.Decl) !DeclDebugBuffers { |
| 153 | 169 | const gpa = self.allocator; |
| 154 | 170 | var dbg_line_buffer = std.ArrayList(u8).init(gpa); |
| 155 | 171 | var dbg_info_buffer = std.ArrayList(u8).init(gpa); |
| 156 | var dbg_info_type_relocs: File.DbgInfoTypeRelocsTable = .{}; | |
| 172 | var dbg_info_type_relocs: DbgInfoTypeRelocsTable = .{}; | |
| 157 | 173 | |
| 158 | 174 | assert(decl.has_tv); |
| 159 | 175 | |
| ... | ... | @@ -890,7 +906,7 @@ fn addDbgInfoType( |
| 890 | 906 | module: *Module, |
| 891 | 907 | ty: Type, |
| 892 | 908 | dbg_info_buffer: *std.ArrayList(u8), |
| 893 | dbg_info_type_relocs: *File.DbgInfoTypeRelocsTable, | |
| 909 | dbg_info_type_relocs: *DbgInfoTypeRelocsTable, | |
| 894 | 910 | nested_ref4_relocs: *std.ArrayList(u32), |
| 895 | 911 | ) error{OutOfMemory}!void { |
| 896 | 912 | const target = self.target; |
src/link/Elf.zig+1-1| ... | ... | @@ -2232,7 +2232,7 @@ pub fn freeDecl(self: *Elf, decl: *Module.Decl) void { |
| 2232 | 2232 | } |
| 2233 | 2233 | } |
| 2234 | 2234 | |
| 2235 | fn deinitRelocs(gpa: Allocator, table: *File.DbgInfoTypeRelocsTable) void { | |
| 2235 | fn deinitRelocs(gpa: Allocator, table: *link.File.Dwarf.DbgInfoTypeRelocsTable) void { | |
| 2236 | 2236 | for (table.values()) |*value| { |
| 2237 | 2237 | value.relocs.deinit(gpa); |
| 2238 | 2238 | } |