diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-08-28 16:10:02 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-08-30 10:42:21 +0200 |
| commit | e5b8a1ac27367402c703a25774bc228499cfeb37 (patch) | |
| tree | 673ac4cad74ecb4dd3cfabd295870fe2ffed49db /src/link/Coff | |
| parent | 2a994ba4a713f0bd469265ea3c55e335048d4c91 (diff) | |
| download | zig-e5b8a1ac27367402c703a25774bc228499cfeb37.tar.gz zig-e5b8a1ac27367402c703a25774bc228499cfeb37.zip | |
coff: allocate and write atoms to file
Diffstat (limited to 'src/link/Coff')
| -rw-r--r-- | src/link/Coff/Atom.zig | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/link/Coff/Atom.zig b/src/link/Coff/Atom.zig index b61e77f53e..d8420c8850 100644 --- a/src/link/Coff/Atom.zig +++ b/src/link/Coff/Atom.zig @@ -20,7 +20,7 @@ sym_index: u32, file: ?u32, /// Used size of the atom -size: u64, +size: u32, /// Alignment of the atom alignment: u32, @@ -44,10 +44,12 @@ pub fn deinit(self: *Atom, gpa: Allocator) void { _ = gpa; } +/// Returns symbol referencing this atom. pub fn getSymbol(self: Atom, coff_file: *Coff) coff.Symbol { return self.getSymbolPtr(coff_file).*; } +/// Returns pointer-to-symbol referencing this atom. pub fn getSymbolPtr(self: Atom, coff_file: *Coff) *coff.Symbol { return coff_file.getSymbolPtr(.{ .sym_index = self.sym_index, @@ -59,8 +61,16 @@ pub fn getSymbolWithLoc(self: Atom) SymbolWithLoc { return .{ .sym_index = self.sym_index, .file = self.file }; } +/// Returns the name of this atom. +pub fn getName(self: Atom, coff_file: *Coff) []const u8 { + return coff_file.getSymbolName(.{ + .sym_index = self.sym_index, + .file = self.file, + }); +} + /// Returns how much room there is to grow in virtual address space. -pub fn capacity(self: Atom, coff_file: *Coff) u64 { +pub fn capacity(self: Atom, coff_file: *Coff) u32 { const self_sym = self.getSymbol(coff_file); if (self.next) |next| { const next_sym = next.getSymbol(coff_file); @@ -68,7 +78,7 @@ pub fn capacity(self: Atom, coff_file: *Coff) u64 { } else { // We are the last atom. // The capacity is limited only by virtual address space. - return std.math.maxInt(u64) - self_sym.value; + return std.math.maxInt(u32) - self_sym.value; } } |
