mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
macho: do not preserve temp symbol names
and do not write out local symbol in MachO's symbol table if global symbol exists with the same name.
This commit is contained in:
parent
3ac973c706
commit
71d19318e7
@ -2584,12 +2584,11 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void {
|
||||
return error.UnhandledSymbolType;
|
||||
}
|
||||
|
||||
const n_strx = try self.makeString(sym_name);
|
||||
if (sym.sect()) {
|
||||
// Defined symbol regardless of scope lands in the locals symbol table.
|
||||
const local_sym_index = @intCast(u32, self.locals.items.len);
|
||||
try self.locals.append(self.base.allocator, .{
|
||||
.n_strx = n_strx,
|
||||
.n_strx = if (symbolIsTemp(sym, sym_name)) 0 else try self.makeString(sym_name),
|
||||
.n_type = macho.N_SECT,
|
||||
.n_sect = 0,
|
||||
.n_desc = 0,
|
||||
@ -2602,6 +2601,7 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void {
|
||||
// if we should save the symbol as a global, or potentially flag the error.
|
||||
if (!sym.ext()) continue;
|
||||
|
||||
const n_strx = try self.makeString(sym_name);
|
||||
const local = self.locals.items[local_sym_index];
|
||||
const resolv = self.symbol_resolver.getPtr(n_strx) orelse {
|
||||
const global_sym_index = @intCast(u32, self.globals.items.len);
|
||||
@ -2672,6 +2672,7 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void {
|
||||
};
|
||||
} else if (sym.tentative()) {
|
||||
// Symbol is a tentative definition.
|
||||
const n_strx = try self.makeString(sym_name);
|
||||
const resolv = self.symbol_resolver.getPtr(n_strx) orelse {
|
||||
const global_sym_index = @intCast(u32, self.globals.items.len);
|
||||
try self.globals.append(self.base.allocator, .{
|
||||
@ -2729,6 +2730,7 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void {
|
||||
}
|
||||
} else {
|
||||
// Symbol is undefined.
|
||||
const n_strx = try self.makeString(sym_name);
|
||||
if (self.symbol_resolver.contains(n_strx)) continue;
|
||||
|
||||
const undef_sym_index = @intCast(u32, self.undefs.items.len);
|
||||
@ -5394,7 +5396,7 @@ fn writeSymbolTable(self: *MachO) !void {
|
||||
|
||||
for (self.locals.items) |sym| {
|
||||
if (sym.n_strx == 0) continue;
|
||||
if (symbolIsTemp(sym, self.getString(sym.n_strx))) continue;
|
||||
if (self.symbol_resolver.get(sym.n_strx)) |_| continue;
|
||||
try locals.append(sym);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user