zld: add Symbol.Tentative to denote common symbol

This commit is contained in:
Jakub Konka 2021-06-10 10:29:57 +02:00
parent 96bb81b6ef
commit 66ff56c58f
2 changed files with 31 additions and 3 deletions

View File

@ -388,9 +388,19 @@ pub fn parseSymbols(self: *Object) !void {
}
if (sym.n_value != 0) {
const comm_size = sym.n_value;
const comm_align = (sym.n_desc >> 8) & 0x0f;
log.err("Common symbol {s} in {s}: size 0x{x}, align 0x{x}", .{ sym_name, self.name.?, comm_size, comm_align });
const tentative = try self.allocator.create(Symbol.Tentative);
errdefer self.allocator.destroy(tentative);
tentative.* = .{
.base = .{
.@"type" = .tentative,
.name = name,
},
.size = sym.n_value,
.alignment = (sym.n_desc >> 8) & 0x0f,
.file = self,
};
log.err("Common symbol {s} in {s}: {}", .{ sym_name, self.name.?, tentative });
return error.UnhandledSymbolType;
}

View File

@ -12,6 +12,7 @@ pub const Type = enum {
regular,
proxy,
unresolved,
tentative,
};
/// Symbol type.
@ -94,6 +95,23 @@ pub const Unresolved = struct {
pub const base_type: Symbol.Type = .unresolved;
};
pub const Tentative = struct {
base: Symbol,
/// Symbol size.
size: u64,
/// Symbol alignment as power of two.
alignment: u16,
/// File where this symbol was referenced.
file: *Object,
// TODO debug info?
pub const base_type: Symbol.Type = .tentative;
};
pub fn deinit(base: *Symbol, allocator: *Allocator) void {
allocator.free(base.name);
}