mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
macho: fix symbol visibility merging logic
This commit is contained in:
parent
3d58faed12
commit
90c54f1eb6
@ -1536,7 +1536,7 @@ pub fn mergeSymbolVisibility(self: *Object, macho_file: *MachO) void {
|
||||
for (self.symbols.items, 0..) |sym, i| {
|
||||
const ref = self.getSymbolRef(@intCast(i), macho_file);
|
||||
const global = ref.getSymbol(macho_file) orelse continue;
|
||||
if (global.visibility != .global) {
|
||||
if (sym.visibility.rank() < global.visibility.rank()) {
|
||||
global.visibility = sym.visibility;
|
||||
}
|
||||
if (sym.flags.weak_ref) {
|
||||
|
||||
@ -331,9 +331,14 @@ fn format2(
|
||||
if (symbol.getAtom(ctx.macho_file)) |atom| {
|
||||
try writer.print(" : atom({d})", .{atom.atom_index});
|
||||
}
|
||||
var buf: [2]u8 = .{'_'} ** 2;
|
||||
var buf: [3]u8 = .{'_'} ** 3;
|
||||
if (symbol.flags.@"export") buf[0] = 'E';
|
||||
if (symbol.flags.import) buf[1] = 'I';
|
||||
switch (symbol.visibility) {
|
||||
.local => buf[2] = 'L',
|
||||
.hidden => buf[2] = 'H',
|
||||
.global => buf[2] = 'G',
|
||||
}
|
||||
try writer.print(" : {s}", .{&buf});
|
||||
if (symbol.flags.weak) try writer.writeAll(" : weak");
|
||||
if (symbol.isSymbolStab(ctx.macho_file)) try writer.writeAll(" : stab");
|
||||
@ -402,6 +407,14 @@ pub const Visibility = enum {
|
||||
global,
|
||||
hidden,
|
||||
local,
|
||||
|
||||
pub fn rank(vis: Visibility) u2 {
|
||||
return switch (vis) {
|
||||
.local => 2,
|
||||
.hidden => 1,
|
||||
.global => 0,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
pub const Extra = struct {
|
||||
|
||||
@ -267,7 +267,7 @@ pub fn mergeSymbolVisibility(self: *ZigObject, macho_file: *MachO) void {
|
||||
for (self.symbols.items, 0..) |sym, i| {
|
||||
const ref = self.getSymbolRef(@intCast(i), macho_file);
|
||||
const global = ref.getSymbol(macho_file) orelse continue;
|
||||
if (global.visibility != .global) {
|
||||
if (sym.visibility.rank() < global.visibility.rank()) {
|
||||
global.visibility = sym.visibility;
|
||||
}
|
||||
if (sym.flags.weak_ref) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user