authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-12-08 21:55:30+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-12-09 09:38:23+01:00
logeb70c8801e62a7f81ffcea735cb628995ca35d42
tree482bf7bbce30b8ba65a3328fe4e4b6ca626794df
parent36981d46a3551ef1b6d673e620c4cffb1d9eea5e

lib/std/Build/CheckObject: dump Mach-O symbol attributes


3 files changed, 16 insertions(+), 11 deletions(-)

lib/std/Build/Step/CheckObject.zig+13-8
......@@ -923,9 +923,18 @@ const MachODumper = struct {
923923 sect.segName(),
924924 sect.sectName(),
925925 });
926 if (sym.n_desc & macho.REFERENCED_DYNAMICALLY != 0) try writer.writeAll(" [referenced dynamically]");
927 if (sym.weakDef()) try writer.writeAll(" weak");
928 if (sym.weakRef()) try writer.writeAll(" weakref");
926929 if (sym.ext()) {
930 if (sym.pext()) try writer.writeAll(" private");
927931 try writer.writeAll(" external");
928 }
932 } else if (sym.pext()) try writer.writeAll(" (was private external)");
933 try writer.print(" {s}\n", .{sym_name});
934 } else if (sym.tentative()) {
935 const alignment = (sym.n_desc >> 8) & 0x0F;
936 try writer.print(" 0x{x:0>16} (common) (alignment 2^{d})", .{ sym.n_value, alignment });
937 if (sym.ext()) try writer.writeAll(" external");
929938 try writer.print(" {s}\n", .{sym_name});
930939 } else if (sym.undf()) {
931940 const ordinal = @divTrunc(@as(i16, @bitCast(sym.n_desc)), macho.N_SYMBOL_RESOLVER);
......@@ -946,17 +955,13 @@ const MachODumper = struct {
946955 break :blk basename[0..ext];
947956 };
948957 try writer.writeAll("(undefined)");
949 if (sym.weakRef()) {
950 try writer.writeAll(" weak");
951 }
952 if (sym.ext()) {
953 try writer.writeAll(" external");
954 }
958 if (sym.weakRef()) try writer.writeAll(" weakref");
959 if (sym.ext()) try writer.writeAll(" external");
955960 try writer.print(" {s} (from {s})\n", .{
956961 sym_name,
957962 import_name,
958963 });
959 } else unreachable;
964 }
960965 }
961966 }
962967};
test/link/macho/unwind_info/build.zig+1-1
......@@ -46,7 +46,7 @@ fn testUnwindInfo(
4646 }
4747
4848 check.checkInSymtab();
49 check.checkContains("(__TEXT,__text) external ___gxx_personality_v0");
49 check.checkContains("(__TEXT,__text) private external ___gxx_personality_v0");
5050 test_step.dependOn(&check.step);
5151
5252 const run = b.addRunArtifact(exe);
test/link/macho/weak_library/build.zig+2-2
......@@ -42,10 +42,10 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
4242 check.checkExact("name @rpath/liba.dylib");
4343
4444 check.checkInSymtab();
45 check.checkExact("(undefined) weak external _a (from liba)");
45 check.checkExact("(undefined) weakref external _a (from liba)");
4646
4747 check.checkInSymtab();
48 check.checkExact("(undefined) weak external _asStr (from liba)");
48 check.checkExact("(undefined) weakref external _asStr (from liba)");
4949 test_step.dependOn(&check.step);
5050
5151 const run = b.addRunArtifact(exe);