zld: differentiate between static and global in stabs

This commit is contained in:
Jakub Konka 2021-04-10 11:00:12 +02:00
parent 717d382871
commit 3b7c9dd6bd
2 changed files with 17 additions and 3 deletions

View File

@ -399,8 +399,13 @@ pub fn parseDebugInfo(self: *Object) !void {
}
} else null;
// TODO How do we work out static, global, local?
const tag: Stab.Tag = if (size == null) .global else .function;
const tag: Stab.Tag = tag: {
if (size != null) break :tag .function;
switch (sym.tag) {
.weak, .strong => break :tag .global,
else => break :tag .static,
}
};
try self.stabs.append(self.allocator, .{
.tag = tag,
.size = size,

View File

@ -2519,7 +2519,16 @@ fn writeDebugInfo(self: *Zld) !void {
.n_value = stab.size.?,
});
},
else => {
.global => {
try stabs.append(.{
.n_strx = sym.inner.n_strx,
.n_type = macho.N_GSYM,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
},
.static => {
try stabs.append(.{
.n_strx = sym.inner.n_strx,
.n_type = macho.N_STSYM,