authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-06-10 10:29:57+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-06-10 10:29:57+02:00
log66ff56c58f3ef71f5cc3b8392632b3ec8abec43f
tree1fa2f35826f3ede01b2355d052951c50689798ee
parent96bb81b6ef0896d0b63c54bfd5d1ac0fa267d68a

zld: add Symbol.Tentative to denote common symbol


2 files changed, 31 insertions(+), 3 deletions(-)

src/link/MachO/Object.zig+13-3
......@@ -388,9 +388,19 @@ pub fn parseSymbols(self: *Object) !void {
388388 }
389389
390390 if (sym.n_value != 0) {
391 const comm_size = sym.n_value;
392 const comm_align = (sym.n_desc >> 8) & 0x0f;
393 log.err("Common symbol {s} in {s}: size 0x{x}, align 0x{x}", .{ sym_name, self.name.?, comm_size, comm_align });
391 const tentative = try self.allocator.create(Symbol.Tentative);
392 errdefer self.allocator.destroy(tentative);
393 tentative.* = .{
394 .base = .{
395 .@"type" = .tentative,
396 .name = name,
397 },
398 .size = sym.n_value,
399 .alignment = (sym.n_desc >> 8) & 0x0f,
400 .file = self,
401 };
402
403 log.err("Common symbol {s} in {s}: {}", .{ sym_name, self.name.?, tentative });
394404 return error.UnhandledSymbolType;
395405 }
396406
src/link/MachO/Symbol.zig+18
......@@ -12,6 +12,7 @@ pub const Type = enum {
1212 regular,
1313 proxy,
1414 unresolved,
15 tentative,
1516};
1617
1718/// Symbol type.
......@@ -94,6 +95,23 @@ pub const Unresolved = struct {
9495 pub const base_type: Symbol.Type = .unresolved;
9596};
9697
98pub const Tentative = struct {
99 base: Symbol,
100
101 /// Symbol size.
102 size: u64,
103
104 /// Symbol alignment as power of two.
105 alignment: u16,
106
107 /// File where this symbol was referenced.
108 file: *Object,
109
110 // TODO debug info?
111
112 pub const base_type: Symbol.Type = .tentative;
113};
114
97115pub fn deinit(base: *Symbol, allocator: *Allocator) void {
98116 allocator.free(base.name);
99117}