authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-09-08 14:03:11+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-09-30 13:44:51+01:00
log0c7b2a7bd5433b7e7bcde3bb49d48226dc2adef9
tree1cc257c75956449de2cd833b91ce17b73b29f724
parent202aeacc05a2fc53762c49d18daeefdf0fa5fbec
signaturelock-open Commit is signed but in an unrecognized format.

fix compiler ftbfs from std.macho and std.dwarf changes


12 files changed, 165 insertions(+), 147 deletions(-)

lib/std/debug/Dwarf/Unwind.zig+1-1
......@@ -603,13 +603,13 @@ fn readEhPointerAbs(r: *Reader, enc_ty: EH.PE.Type, addr_size_bytes: u8, endian:
603603/// Returns `error.InvalidDebugInfo` if the encoding is `EH.PE.omit`.
604604fn readEhPointer(r: *Reader, enc: EH.PE, addr_size_bytes: u8, ctx: EhPointerContext, endian: Endian) !u64 {
605605 const offset = try readEhPointerAbs(r, enc.type, addr_size_bytes, endian);
606 if (enc.indirect) return bad(); // GCC extension; not supported
606607 const base = switch (enc.rel) {
607608 .abs, .aligned => 0,
608609 .pcrel => ctx.pc_rel_base,
609610 .textrel => ctx.text_rel_base orelse return bad(),
610611 .datarel => ctx.data_rel_base orelse return bad(),
611612 .funcrel => ctx.function_rel_base orelse return bad(),
612 .indirect => return bad(), // GCC extension; not supported
613613 _ => return bad(),
614614 };
615615 return switch (offset) {
lib/std/dwarf/EH.zig+5-3
......@@ -1,6 +1,8 @@
11pub const PE = packed struct(u8) {
22 type: Type,
33 rel: Rel,
4 /// Undocumented GCC extension
5 indirect: bool = false,
46
57 /// This is a special encoding which does not correspond to named `type`/`rel` values.
68 pub const omit: PE = @bitCast(@as(u8, 0xFF));
......@@ -18,15 +20,15 @@ pub const PE = packed struct(u8) {
1820 _,
1921 };
2022
21 pub const Rel = enum(u4) {
23 /// The specification considers this a `u4`, but the GCC `indirect` field extension conflicts
24 /// with that, so we consider it a `u3` instead.
25 pub const Rel = enum(u3) {
2226 abs = 0x0,
2327 pcrel = 0x1,
2428 textrel = 0x2,
2529 datarel = 0x3,
2630 funcrel = 0x4,
2731 aligned = 0x5,
28 /// Undocumented GCC extension
29 indirect = 0x8,
3032 _,
3133 };
3234};
src/link/Dwarf.zig+1-1
......@@ -4852,7 +4852,7 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (FlushError || Writer.Erro
48524852 hw.writeSleb128(dwarf.debug_frame.header.data_alignment_factor) catch unreachable;
48534853 hw.writeUleb128(dwarf.debug_frame.header.return_address_register) catch unreachable;
48544854 hw.writeUleb128(1) catch unreachable;
4855 hw.writeByte(DW.EH.PE.pcrel | DW.EH.PE.sdata4) catch unreachable;
4855 hw.writeByte(@bitCast(@as(DW.EH.PE, .{ .type = .sdata4, .rel = .pcrel }))) catch unreachable;
48564856 hw.writeByte(DW.CFA.def_cfa_sf) catch unreachable;
48574857 hw.writeUleb128(Register.rsp.dwarfNum()) catch unreachable;
48584858 hw.writeSleb128(-1) catch unreachable;
src/link/Elf/eh_frame.zig+3-3
......@@ -456,10 +456,10 @@ pub fn writeEhFrameRelocs(elf_file: *Elf, relocs: *std.array_list.Managed(elf.El
456456
457457pub fn writeEhFrameHdr(elf_file: *Elf, writer: anytype) !void {
458458 try writer.writeByte(1); // version
459 try writer.writeByte(DW_EH_PE.pcrel | DW_EH_PE.sdata4); // eh_frame_ptr_enc
459 try writer.writeByte(@bitCast(@as(DW_EH_PE, .{ .type = .sdata4, .rel = .pcrel }))); // eh_frame_ptr_enc
460460 // Building the lookup table would be expensive work on every `flush` -- omit it.
461 try writer.writeByte(DW_EH_PE.omit); // fde_count_enc
462 try writer.writeByte(DW_EH_PE.omit); // table_enc
461 try writer.writeByte(@bitCast(DW_EH_PE.omit)); // fde_count_enc
462 try writer.writeByte(@bitCast(DW_EH_PE.omit)); // table_enc
463463
464464 const shdrs = elf_file.sections.items(.shdr);
465465 const eh_frame_shdr = shdrs[elf_file.section_indexes.eh_frame.?];
src/link/MachO.zig+2-2
......@@ -4149,9 +4149,9 @@ pub const SymtabCtx = struct {
41494149
41504150pub const null_sym = macho.nlist_64{
41514151 .n_strx = 0,
4152 .n_type = 0,
4152 .n_type = @bitCast(@as(u8, 0)),
41534153 .n_sect = 0,
4154 .n_desc = 0,
4154 .n_desc = @bitCast(@as(u16, 0)),
41554155 .n_value = 0,
41564156};
41574157
src/link/MachO/InternalObject.zig+15-15
......@@ -69,9 +69,9 @@ pub fn initSymbols(self: *InternalObject, macho_file: *MachO) !void {
6969 const nlist = obj.symtab.addOneAssumeCapacity();
7070 nlist.* = .{
7171 .n_strx = name.pos,
72 .n_type = args.type,
72 .n_type = @bitCast(args.type),
7373 .n_sect = 0,
74 .n_desc = args.desc,
74 .n_desc = @bitCast(args.desc),
7575 .n_value = 0,
7676 };
7777 symbol.nlist_idx = nlist_idx;
......@@ -143,7 +143,7 @@ pub fn resolveSymbols(self: *InternalObject, macho_file: *MachO) !void {
143143 }
144144 global.* = gop.index;
145145
146 if (nlist.undf()) continue;
146 if (nlist.n_type.bits.type == .undf) continue;
147147 if (gop.ref.getFile(macho_file) == null) {
148148 gop.ref.* = .{ .index = @intCast(i), .file = self.index };
149149 continue;
......@@ -171,7 +171,7 @@ pub fn resolveBoundarySymbols(self: *InternalObject, macho_file: *MachO) !void {
171171 const object = macho_file.getFile(index).?.object;
172172 for (object.symbols.items, 0..) |sym, i| {
173173 const nlist = object.symtab.items(.nlist)[i];
174 if (!nlist.undf() or !nlist.ext()) continue;
174 if (nlist.n_type.bits.type != .undf or !nlist.n_type.bits.ext) continue;
175175 const ref = object.getSymbolRef(@intCast(i), macho_file);
176176 if (ref.getFile(macho_file) != null) continue;
177177 const name = sym.getName(macho_file);
......@@ -206,9 +206,9 @@ pub fn resolveBoundarySymbols(self: *InternalObject, macho_file: *MachO) !void {
206206 const nlist = self.symtab.addOneAssumeCapacity();
207207 nlist.* = .{
208208 .n_strx = name_str.pos,
209 .n_type = macho.N_SECT,
209 .n_type = .{ .bits = .{ .ext = false, .type = .sect, .pext = false, .is_stab = 0 } },
210210 .n_sect = 0,
211 .n_desc = 0,
211 .n_desc = @bitCast(@as(u16, 0)),
212212 .n_value = 0,
213213 };
214214 sym.nlist_idx = nlist_idx;
......@@ -226,7 +226,7 @@ pub fn markLive(self: *InternalObject, macho_file: *MachO) void {
226226
227227 for (0..self.symbols.items.len) |i| {
228228 const nlist = self.symtab.items[i];
229 if (!nlist.ext()) continue;
229 if (!nlist.n_type.bits.ext) continue;
230230
231231 const ref = self.getSymbolRef(@intCast(i), macho_file);
232232 const file = ref.getFile(macho_file) orelse continue;
......@@ -273,9 +273,9 @@ fn addObjcMethnameSection(self: *InternalObject, methname: []const u8, macho_fil
273273 const nlist = try self.symtab.addOne(gpa);
274274 nlist.* = .{
275275 .n_strx = name_str.pos,
276 .n_type = macho.N_SECT,
276 .n_type = .{ .bits = .{ .ext = false, .type = .sect, .pext = false, .is_stab = 0 } },
277277 .n_sect = @intCast(n_sect + 1),
278 .n_desc = 0,
278 .n_desc = @bitCast(@as(u16, 0)),
279279 .n_value = 0,
280280 };
281281 sym.nlist_idx = nlist_idx;
......@@ -326,9 +326,9 @@ fn addObjcSelrefsSection(self: *InternalObject, methname_sym_index: Symbol.Index
326326 const nlist = try self.symtab.addOne(gpa);
327327 nlist.* = .{
328328 .n_strx = 0,
329 .n_type = macho.N_SECT,
329 .n_type = .{ .bits = .{ .ext = false, .type = .sect, .pext = false, .is_stab = 0 } },
330330 .n_sect = @intCast(n_sect + 1),
331 .n_desc = 0,
331 .n_desc = @bitCast(@as(u16, 0)),
332332 .n_value = 0,
333333 };
334334 sym.nlist_idx = nlist_idx;
......@@ -352,8 +352,8 @@ pub fn resolveObjcMsgSendSymbols(self: *InternalObject, macho_file: *MachO) !voi
352352
353353 for (object.symbols.items, 0..) |sym, i| {
354354 const nlist = object.symtab.items(.nlist)[i];
355 if (!nlist.ext()) continue;
356 if (!nlist.undf()) continue;
355 if (!nlist.n_type.bits.ext) continue;
356 if (nlist.n_type.bits.type != .undf) continue;
357357
358358 const ref = object.getSymbolRef(@intCast(i), macho_file);
359359 if (ref.getFile(macho_file) != null) continue;
......@@ -381,9 +381,9 @@ pub fn resolveObjcMsgSendSymbols(self: *InternalObject, macho_file: *MachO) !voi
381381 const nlist = try self.symtab.addOne(gpa);
382382 nlist.* = .{
383383 .n_strx = name_str.pos,
384 .n_type = macho.N_SECT | macho.N_EXT | macho.N_PEXT,
384 .n_type = .{ .bits = .{ .ext = true, .type = .sect, .pext = true, .is_stab = 0 } },
385385 .n_sect = 0,
386 .n_desc = 0,
386 .n_desc = @bitCast(@as(u16, 0)),
387387 .n_value = 0,
388388 };
389389 sym.nlist_idx = nlist_idx;
src/link/MachO/Object.zig+74-72
......@@ -179,7 +179,7 @@ pub fn parse(self: *Object, macho_file: *MachO) !void {
179179 idx: usize,
180180
181181 fn rank(ctx: *const Object, nl: macho.nlist_64) u8 {
182 if (!nl.ext()) {
182 if (!nl.n_type.bits.ext) {
183183 const name = ctx.getNStrx(nl.n_strx);
184184 if (name.len == 0) return 5;
185185 if (name[0] == 'l' or name[0] == 'L') return 4;
......@@ -202,7 +202,7 @@ pub fn parse(self: *Object, macho_file: *MachO) !void {
202202 var nlists = try std.array_list.Managed(NlistIdx).initCapacity(gpa, self.symtab.items(.nlist).len);
203203 defer nlists.deinit();
204204 for (self.symtab.items(.nlist), 0..) |nlist, i| {
205 if (nlist.n_type.bits.is_stab != 0 or nlist.n_type.type != .sect) continue;
205 if (nlist.n_type.bits.is_stab != 0 or nlist.n_type.bits.type != .sect) continue;
206206 nlists.appendAssumeCapacity(.{ .nlist = nlist, .idx = i });
207207 }
208208 mem.sort(NlistIdx, nlists.items, self, NlistIdx.lessThan);
......@@ -488,9 +488,9 @@ fn initCstringLiterals(self: *Object, allocator: Allocator, file: File.Handle, m
488488 self.symtab.set(nlist_index, .{
489489 .nlist = .{
490490 .n_strx = name_str.pos,
491 .n_type = macho.N_SECT,
491 .n_type = .{ .bits = .{ .ext = false, .type = .sect, .pext = false, .is_stab = 0 } },
492492 .n_sect = @intCast(atom.n_sect + 1),
493 .n_desc = 0,
493 .n_desc = @bitCast(@as(u16, 0)),
494494 .n_value = atom.getInputAddress(macho_file),
495495 },
496496 .size = atom.size,
......@@ -555,9 +555,9 @@ fn initFixedSizeLiterals(self: *Object, allocator: Allocator, macho_file: *MachO
555555 self.symtab.set(nlist_index, .{
556556 .nlist = .{
557557 .n_strx = name_str.pos,
558 .n_type = macho.N_SECT,
558 .n_type = .{ .bits = .{ .ext = false, .type = .sect, .pext = false, .is_stab = 0 } },
559559 .n_sect = @intCast(atom.n_sect + 1),
560 .n_desc = 0,
560 .n_desc = @bitCast(@as(u16, 0)),
561561 .n_value = atom.getInputAddress(macho_file),
562562 },
563563 .size = atom.size,
......@@ -613,9 +613,9 @@ fn initPointerLiterals(self: *Object, allocator: Allocator, macho_file: *MachO)
613613 self.symtab.set(nlist_index, .{
614614 .nlist = .{
615615 .n_strx = name_str.pos,
616 .n_type = macho.N_SECT,
616 .n_type = .{ .bits = .{ .ext = false, .type = .sect, .pext = false, .is_stab = 0 } },
617617 .n_sect = @intCast(atom.n_sect + 1),
618 .n_desc = 0,
618 .n_desc = @bitCast(@as(u16, 0)),
619619 .n_value = atom.getInputAddress(macho_file),
620620 },
621621 .size = atom.size,
......@@ -805,7 +805,7 @@ fn linkNlistToAtom(self: *Object, macho_file: *MachO) !void {
805805 const tracy = trace(@src());
806806 defer tracy.end();
807807 for (self.symtab.items(.nlist), self.symtab.items(.atom)) |nlist, *atom| {
808 if (!nlist.n_type.bits.is_stab != 0 and nlist.n_type.type == .sect) {
808 if (nlist.n_type.bits.is_stab == 0 and nlist.n_type.bits.type == .sect) {
809809 const sect = self.sections.items(.header)[nlist.n_sect - 1];
810810 const subs = self.sections.items(.subsections)[nlist.n_sect - 1].items;
811811 if (nlist.n_value == sect.addr) {
......@@ -852,30 +852,30 @@ fn initSymbols(self: *Object, allocator: Allocator, macho_file: *MachO) !void {
852852 symbol.extra = self.addSymbolExtraAssumeCapacity(.{});
853853
854854 if (self.getAtom(atom_index)) |atom| {
855 assert(nlist.n_type.type != .abs);
855 assert(nlist.n_type.bits.type != .abs);
856856 symbol.value -= atom.getInputAddress(macho_file);
857857 symbol.atom_ref = .{ .index = atom_index, .file = self.index };
858858 }
859859
860860 symbol.flags.weak = nlist.n_desc.weak_def_or_ref_to_weak;
861 symbol.flags.abs = nlist.n_type.type == .abs;
861 symbol.flags.abs = nlist.n_type.bits.type == .abs;
862862 symbol.flags.tentative = nlist.tentative();
863863 symbol.flags.no_dead_strip = symbol.flags.no_dead_strip or nlist.n_desc.discarded_or_no_dead_strip;
864 symbol.flags.dyn_ref = nlist.n_desc & macho.REFERENCED_DYNAMICALLY != 0;
864 symbol.flags.dyn_ref = nlist.n_desc.referenced_dynamically;
865865 symbol.flags.interposable = false;
866866 // TODO
867 // symbol.flags.interposable = nlist.ext() and (nlist.n_type.type == .sect or nlist.n_type.type == .abs) and macho_file.base.isDynLib() and macho_file.options.namespace == .flat and !nlist.pext();
867 // symbol.flags.interposable = nlist.ext() and (nlist.n_type.bits.type == .sect or nlist.n_type.bits.type == .abs) and macho_file.base.isDynLib() and macho_file.options.namespace == .flat and !nlist.pext();
868868
869 if (nlist.n_type.type == .sect and
869 if (nlist.n_type.bits.type == .sect and
870870 self.sections.items(.header)[nlist.n_sect - 1].type() == macho.S_THREAD_LOCAL_VARIABLES)
871871 {
872872 symbol.flags.tlv = true;
873873 }
874874
875 if (nlist.ext()) {
876 if (nlist.n_type.type == .undf) {
875 if (nlist.n_type.bits.ext) {
876 if (nlist.n_type.bits.type == .undf) {
877877 symbol.flags.weak_ref = nlist.n_desc.weak_ref;
878 } else if (nlist.pext() or (nlist.n_desc.weak_def_or_ref_to_weak and nlist.n_desc.weak_ref) or self.hidden) {
878 } else if (nlist.n_type.bits.pext or (nlist.n_desc.weak_def_or_ref_to_weak and nlist.n_desc.weak_ref) or self.hidden) {
879879 symbol.visibility = .hidden;
880880 } else {
881881 symbol.visibility = .global;
......@@ -919,7 +919,7 @@ fn initSymbolStabs(self: *Object, allocator: Allocator, nlists: anytype, macho_f
919919 var addr_lookup = std.StringHashMap(u64).init(allocator);
920920 defer addr_lookup.deinit();
921921 for (syms) |sym| {
922 if (sym.n_type.type == .sect and (sym.ext() or sym.pext())) {
922 if (sym.n_type.bits.type == .sect and (sym.n_type.bits.ext or sym.n_type.bits.pext)) {
923923 try addr_lookup.putNoClobber(self.getNStrx(sym.n_strx), sym.n_value);
924924 }
925925 }
......@@ -927,41 +927,43 @@ fn initSymbolStabs(self: *Object, allocator: Allocator, nlists: anytype, macho_f
927927 var i: u32 = start;
928928 while (i < end) : (i += 1) {
929929 const open = syms[i];
930 if (open.n_type != macho.N_SO) {
930 if (open.n_type.stab != .so) {
931931 try macho_file.reportParseError2(self.index, "unexpected symbol stab type 0x{x} as the first entry", .{
932 open.n_type,
932 @intFromEnum(open.n_type.stab),
933933 });
934934 return error.MalformedObject;
935935 }
936936
937 while (i < end and syms[i].n_type == macho.N_SO and syms[i].n_sect != 0) : (i += 1) {}
937 while (i < end and syms[i].n_type.stab == .so and syms[i].n_sect != 0) : (i += 1) {}
938938
939939 var sf: StabFile = .{ .comp_dir = i };
940940 // TODO validate
941941 i += 3;
942942
943 while (i < end and syms[i].n_type != macho.N_SO) : (i += 1) {
943 while (i < end and syms[i].n_type.stab != .so) : (i += 1) {
944944 const nlist = syms[i];
945945 var stab: StabFile.Stab = .{};
946 switch (nlist.n_type) {
947 macho.N_BNSYM => {
946 switch (nlist.n_type.stab) {
947 .bnsym => {
948948 stab.is_func = true;
949949 stab.index = sym_lookup.find(nlist.n_value);
950950 // TODO validate
951951 i += 3;
952952 },
953 macho.N_GSYM => {
953 .gsym => {
954954 stab.is_func = false;
955955 stab.index = sym_lookup.find(addr_lookup.get(self.getNStrx(nlist.n_strx)).?);
956956 },
957 macho.N_STSYM => {
957 .stsym => {
958958 stab.is_func = false;
959959 stab.index = sym_lookup.find(nlist.n_value);
960960 },
961 _ => {
962 try macho_file.reportParseError2(self.index, "unhandled symbol stab type 0x{x}", .{@intFromEnum(nlist.n_type.stab)});
963 return error.MalformedObject;
964 },
961965 else => {
962 try macho_file.reportParseError2(self.index, "unhandled symbol stab type 0x{x}", .{
963 nlist.n_type,
964 });
966 try macho_file.reportParseError2(self.index, "unhandled symbol stab type '{t}'", .{nlist.n_type.stab});
965967 return error.MalformedObject;
966968 },
967969 }
......@@ -1132,7 +1134,7 @@ fn initUnwindRecords(self: *Object, allocator: Allocator, sect_id: u8, file: Fil
11321134 fn find(fs: @This(), addr: u64) ?Symbol.Index {
11331135 for (0..fs.ctx.symbols.items.len) |i| {
11341136 const nlist = fs.ctx.symtab.items(.nlist)[i];
1135 if (nlist.ext() and nlist.n_value == addr) return @intCast(i);
1137 if (nlist.n_type.bits.ext and nlist.n_value == addr) return @intCast(i);
11361138 }
11371139 return null;
11381140 }
......@@ -1242,7 +1244,7 @@ fn parseUnwindRecords(self: *Object, allocator: Allocator, cpu_arch: std.Target.
12421244 const slice = self.symtab.slice();
12431245 for (slice.items(.nlist), slice.items(.atom), slice.items(.size)) |nlist, atom, size| {
12441246 if (nlist.n_type.bits.is_stab != 0) continue;
1245 if (nlist.n_type.type != .sect) continue;
1247 if (nlist.n_type.bits.type != .sect) continue;
12461248 const sect = self.sections.items(.header)[nlist.n_sect - 1];
12471249 if (sect.isCode() and sect.size > 0) {
12481250 try superposition.ensureUnusedCapacity(1);
......@@ -1458,8 +1460,8 @@ pub fn resolveSymbols(self: *Object, macho_file: *MachO) !void {
14581460 const gpa = macho_file.base.comp.gpa;
14591461
14601462 for (self.symtab.items(.nlist), self.symtab.items(.atom), self.globals.items, 0..) |nlist, atom_index, *global, i| {
1461 if (!nlist.ext()) continue;
1462 if (nlist.n_type.type == .sect) {
1463 if (!nlist.n_type.bits.ext) continue;
1464 if (nlist.n_type.bits.type == .sect) {
14631465 const atom = self.getAtom(atom_index).?;
14641466 if (!atom.isAlive()) continue;
14651467 }
......@@ -1473,7 +1475,7 @@ pub fn resolveSymbols(self: *Object, macho_file: *MachO) !void {
14731475 }
14741476 global.* = gop.index;
14751477
1476 if (nlist.n_type.type == .undf and !nlist.tentative()) continue;
1478 if (nlist.n_type.bits.type == .undf and !nlist.tentative()) continue;
14771479 if (gop.ref.getFile(macho_file) == null) {
14781480 gop.ref.* = .{ .index = @intCast(i), .file = self.index };
14791481 continue;
......@@ -1495,12 +1497,12 @@ pub fn markLive(self: *Object, macho_file: *MachO) void {
14951497
14961498 for (0..self.symbols.items.len) |i| {
14971499 const nlist = self.symtab.items(.nlist)[i];
1498 if (!nlist.ext()) continue;
1500 if (!nlist.n_type.bits.ext) continue;
14991501
15001502 const ref = self.getSymbolRef(@intCast(i), macho_file);
15011503 const file = ref.getFile(macho_file) orelse continue;
15021504 const sym = ref.getSymbol(macho_file).?;
1503 const should_keep = nlist.n_type.type == .undf or (nlist.tentative() and !sym.flags.tentative);
1505 const should_keep = nlist.n_type.bits.type == .undf or (nlist.tentative() and !sym.flags.tentative);
15041506 if (should_keep and file == .object and !file.object.alive) {
15051507 file.object.alive = true;
15061508 file.object.markLive(macho_file);
......@@ -1565,7 +1567,7 @@ pub fn convertTentativeDefinitions(self: *Object, macho_file: *MachO) !void {
15651567 const name = try std.fmt.allocPrintSentinel(gpa, "__DATA$__common${s}", .{sym.getName(macho_file)}, 0);
15661568 defer gpa.free(name);
15671569
1568 const alignment = (nlist.n_desc >> 8) & 0x0f;
1570 const alignment = (@as(u16, @bitCast(nlist.n_desc)) >> 8) & 0x0f;
15691571 const n_sect = try self.addSection(gpa, "__DATA", "__common");
15701572 const atom_index = try self.addAtom(gpa, .{
15711573 .name = try self.addString(gpa, name),
......@@ -1589,9 +1591,9 @@ pub fn convertTentativeDefinitions(self: *Object, macho_file: *MachO) !void {
15891591 sym.visibility = .global;
15901592
15911593 nlist.n_value = 0;
1592 nlist.n_type = macho.N_EXT | macho.N_SECT;
1594 nlist.n_type = .{ .bits = .{ .ext = true, .type = .sect, .pext = false, .is_stab = 0 } };
15931595 nlist.n_sect = 0;
1594 nlist.n_desc = 0;
1596 nlist.n_desc = @bitCast(@as(u16, 0));
15951597 nlist_atom.* = atom_index;
15961598 }
15971599}
......@@ -1685,7 +1687,7 @@ pub fn parseAr(self: *Object, macho_file: *MachO) !void {
16851687pub fn updateArSymtab(self: Object, ar_symtab: *Archive.ArSymtab, macho_file: *MachO) error{OutOfMemory}!void {
16861688 const gpa = macho_file.base.comp.gpa;
16871689 for (self.symtab.items(.nlist)) |nlist| {
1688 if (!nlist.ext() or (nlist.n_type.type == .undf and !nlist.tentative())) continue;
1690 if (!nlist.n_type.bits.ext or (nlist.n_type.bits.type == .undf and !nlist.tentative())) continue;
16891691 const off = try ar_symtab.strtab.insert(gpa, self.getNStrx(nlist.n_strx));
16901692 try ar_symtab.entries.append(gpa, .{ .off = off, .file = self.index });
16911693 }
......@@ -2028,30 +2030,30 @@ pub fn writeStabs(self: Object, stroff: u32, macho_file: *MachO, ctx: anytype) v
20282030 ) void {
20292031 context.symtab.items[index] = .{
20302032 .n_strx = 0,
2031 .n_type = macho.N_BNSYM,
2033 .n_type = .{ .stab = .bnsym },
20322034 .n_sect = n_sect,
2033 .n_desc = 0,
2035 .n_desc = @bitCast(@as(u16, 0)),
20342036 .n_value = n_value,
20352037 };
20362038 context.symtab.items[index + 1] = .{
20372039 .n_strx = n_strx,
2038 .n_type = macho.N_FUN,
2040 .n_type = .{ .stab = .fun },
20392041 .n_sect = n_sect,
2040 .n_desc = 0,
2042 .n_desc = @bitCast(@as(u16, 0)),
20412043 .n_value = n_value,
20422044 };
20432045 context.symtab.items[index + 2] = .{
20442046 .n_strx = 0,
2045 .n_type = macho.N_FUN,
2047 .n_type = .{ .stab = .fun },
20462048 .n_sect = 0,
2047 .n_desc = 0,
2049 .n_desc = @bitCast(@as(u16, 0)),
20482050 .n_value = size,
20492051 };
20502052 context.symtab.items[index + 3] = .{
20512053 .n_strx = 0,
2052 .n_type = macho.N_ENSYM,
2054 .n_type = .{ .stab = .ensym },
20532055 .n_sect = n_sect,
2054 .n_desc = 0,
2056 .n_desc = @bitCast(@as(u16, 0)),
20552057 .n_value = size,
20562058 };
20572059 }
......@@ -2068,9 +2070,9 @@ pub fn writeStabs(self: Object, stroff: u32, macho_file: *MachO, ctx: anytype) v
20682070 // N_SO comp_dir
20692071 ctx.symtab.items[index] = .{
20702072 .n_strx = n_strx,
2071 .n_type = macho.N_SO,
2073 .n_type = .{ .stab = .so },
20722074 .n_sect = 0,
2073 .n_desc = 0,
2075 .n_desc = @bitCast(@as(u16, 0)),
20742076 .n_value = 0,
20752077 };
20762078 index += 1;
......@@ -2081,9 +2083,9 @@ pub fn writeStabs(self: Object, stroff: u32, macho_file: *MachO, ctx: anytype) v
20812083 // N_SO tu_name
20822084 macho_file.symtab.items[index] = .{
20832085 .n_strx = n_strx,
2084 .n_type = macho.N_SO,
2086 .n_type = .{ .stab = .so },
20852087 .n_sect = 0,
2086 .n_desc = 0,
2088 .n_desc = @bitCast(@as(u16, 0)),
20872089 .n_value = 0,
20882090 };
20892091 index += 1;
......@@ -2094,9 +2096,9 @@ pub fn writeStabs(self: Object, stroff: u32, macho_file: *MachO, ctx: anytype) v
20942096 // N_OSO path
20952097 ctx.symtab.items[index] = .{
20962098 .n_strx = n_strx,
2097 .n_type = macho.N_OSO,
2099 .n_type = .{ .stab = .oso },
20982100 .n_sect = 0,
2099 .n_desc = 1,
2101 .n_desc = @bitCast(@as(u16, 1)),
21002102 .n_value = self.mtime,
21012103 };
21022104 index += 1;
......@@ -2159,18 +2161,18 @@ pub fn writeStabs(self: Object, stroff: u32, macho_file: *MachO, ctx: anytype) v
21592161 } else if (sym.visibility == .global) {
21602162 ctx.symtab.items[index] = .{
21612163 .n_strx = sym_n_strx,
2162 .n_type = macho.N_GSYM,
2164 .n_type = .{ .stab = .gsym },
21632165 .n_sect = sym_n_sect,
2164 .n_desc = 0,
2166 .n_desc = @bitCast(@as(u16, 0)),
21652167 .n_value = 0,
21662168 };
21672169 index += 1;
21682170 } else {
21692171 ctx.symtab.items[index] = .{
21702172 .n_strx = sym_n_strx,
2171 .n_type = macho.N_STSYM,
2173 .n_type = .{ .stab = .stsym },
21722174 .n_sect = sym_n_sect,
2173 .n_desc = 0,
2175 .n_desc = @bitCast(@as(u16, 0)),
21742176 .n_value = sym_n_value,
21752177 };
21762178 index += 1;
......@@ -2181,9 +2183,9 @@ pub fn writeStabs(self: Object, stroff: u32, macho_file: *MachO, ctx: anytype) v
21812183 // N_SO
21822184 ctx.symtab.items[index] = .{
21832185 .n_strx = 0,
2184 .n_type = macho.N_SO,
2186 .n_type = .{ .stab = .so },
21852187 .n_sect = 0,
2186 .n_desc = 0,
2188 .n_desc = @bitCast(@as(u16, 0)),
21872189 .n_value = 0,
21882190 };
21892191 } else {
......@@ -2198,9 +2200,9 @@ pub fn writeStabs(self: Object, stroff: u32, macho_file: *MachO, ctx: anytype) v
21982200 // N_SO comp_dir
21992201 ctx.symtab.items[index] = .{
22002202 .n_strx = n_strx,
2201 .n_type = macho.N_SO,
2203 .n_type = .{ .stab = .so },
22022204 .n_sect = 0,
2203 .n_desc = 0,
2205 .n_desc = @bitCast(@as(u16, 0)),
22042206 .n_value = 0,
22052207 };
22062208 index += 1;
......@@ -2211,9 +2213,9 @@ pub fn writeStabs(self: Object, stroff: u32, macho_file: *MachO, ctx: anytype) v
22112213 // N_SO tu_name
22122214 ctx.symtab.items[index] = .{
22132215 .n_strx = n_strx,
2214 .n_type = macho.N_SO,
2216 .n_type = .{ .stab = .so },
22152217 .n_sect = 0,
2216 .n_desc = 0,
2218 .n_desc = @bitCast(@as(u16, 0)),
22172219 .n_value = 0,
22182220 };
22192221 index += 1;
......@@ -2224,9 +2226,9 @@ pub fn writeStabs(self: Object, stroff: u32, macho_file: *MachO, ctx: anytype) v
22242226 // N_OSO path
22252227 ctx.symtab.items[index] = .{
22262228 .n_strx = n_strx,
2227 .n_type = macho.N_OSO,
2229 .n_type = .{ .stab = .so },
22282230 .n_sect = 0,
2229 .n_desc = 1,
2231 .n_desc = @bitCast(@as(u16, 1)),
22302232 .n_value = sf.getOsoModTime(self),
22312233 };
22322234 index += 1;
......@@ -2254,18 +2256,18 @@ pub fn writeStabs(self: Object, stroff: u32, macho_file: *MachO, ctx: anytype) v
22542256 } else if (sym.visibility == .global) {
22552257 ctx.symtab.items[index] = .{
22562258 .n_strx = sym_n_strx,
2257 .n_type = macho.N_GSYM,
2259 .n_type = .{ .stab = .gsym },
22582260 .n_sect = sym_n_sect,
2259 .n_desc = 0,
2261 .n_desc = @bitCast(@as(u16, 0)),
22602262 .n_value = 0,
22612263 };
22622264 index += 1;
22632265 } else {
22642266 ctx.symtab.items[index] = .{
22652267 .n_strx = sym_n_strx,
2266 .n_type = macho.N_STSYM,
2268 .n_type = .{ .stab = .stsym },
22672269 .n_sect = sym_n_sect,
2268 .n_desc = 0,
2270 .n_desc = @bitCast(@as(u16, 0)),
22692271 .n_value = sym_n_value,
22702272 };
22712273 index += 1;
......@@ -2276,9 +2278,9 @@ pub fn writeStabs(self: Object, stroff: u32, macho_file: *MachO, ctx: anytype) v
22762278 // N_SO
22772279 ctx.symtab.items[index] = .{
22782280 .n_strx = 0,
2279 .n_type = macho.N_SO,
2281 .n_type = .{ .stab = .so },
22802282 .n_sect = 0,
2281 .n_desc = 0,
2283 .n_desc = @bitCast(@as(u16, 0)),
22822284 .n_value = 0,
22832285 };
22842286 index += 1;
src/link/MachO/Symbol.zig+28-14
......@@ -36,7 +36,7 @@ pub fn isLocal(symbol: Symbol) bool {
3636pub fn isSymbolStab(symbol: Symbol, macho_file: *MachO) bool {
3737 const file = symbol.getFile(macho_file) orelse return false;
3838 return switch (file) {
39 .object => symbol.getNlist(macho_file).stab(),
39 .object => symbol.getNlist(macho_file).n_type.bits.is_stab != 0,
4040 else => false,
4141 };
4242}
......@@ -233,35 +233,49 @@ pub inline fn setExtra(symbol: Symbol, extra: Extra, macho_file: *MachO) void {
233233
234234pub fn setOutputSym(symbol: Symbol, macho_file: *MachO, out: *macho.nlist_64) void {
235235 if (symbol.isLocal()) {
236 out.n_type = if (symbol.flags.abs) macho.N_ABS else macho.N_SECT;
236 out.n_type = .{ .bits = .{
237 .ext = false,
238 .type = if (symbol.flags.abs) .abs else .sect,
239 .pext = false,
240 .is_stab = 0,
241 } };
237242 out.n_sect = if (symbol.flags.abs) 0 else @intCast(symbol.getOutputSectionIndex(macho_file) + 1);
238 out.n_desc = 0;
243 out.n_desc = @bitCast(@as(u16, 0));
239244 out.n_value = symbol.getAddress(.{ .stubs = false }, macho_file);
240245
241246 switch (symbol.visibility) {
242 .hidden => out.n_type |= macho.N_PEXT,
247 .hidden => out.n_type.bits.pext = true,
243248 else => {},
244249 }
245250 } else if (symbol.flags.@"export") {
246251 assert(symbol.visibility == .global);
247 out.n_type = macho.N_EXT;
248 out.n_type |= if (symbol.flags.abs) macho.N_ABS else macho.N_SECT;
252 out.n_type = .{ .bits = .{
253 .ext = true,
254 .type = if (symbol.flags.abs) .abs else .sect,
255 .pext = false,
256 .is_stab = 0,
257 } };
249258 out.n_sect = if (symbol.flags.abs) 0 else @intCast(symbol.getOutputSectionIndex(macho_file) + 1);
250259 out.n_value = symbol.getAddress(.{ .stubs = false }, macho_file);
251 out.n_desc = 0;
260 out.n_desc = @bitCast(@as(u16, 0));
252261
253262 if (symbol.flags.weak) {
254 out.n_desc |= macho.N_WEAK_DEF;
263 out.n_desc.weak_def_or_ref_to_weak = true;
255264 }
256265 if (symbol.flags.dyn_ref) {
257 out.n_desc |= macho.REFERENCED_DYNAMICALLY;
266 out.n_desc.referenced_dynamically = true;
258267 }
259268 } else {
260269 assert(symbol.visibility == .global);
261 out.n_type = macho.N_EXT;
270 out.n_type = .{ .bits = .{
271 .ext = true,
272 .type = .undf,
273 .pext = false,
274 .is_stab = 0,
275 } };
262276 out.n_sect = 0;
263277 out.n_value = 0;
264 out.n_desc = 0;
278 out.n_desc = @bitCast(@as(u16, 0));
265279
266280 // TODO:
267281 // const ord: u16 = if (macho_file.options.namespace == .flat)
......@@ -274,14 +288,14 @@ pub fn setOutputSym(symbol: Symbol, macho_file: *MachO, out: *macho.nlist_64) vo
274288 ord
275289 else
276290 macho.BIND_SPECIAL_DYLIB_SELF;
277 out.n_desc = macho.N_SYMBOL_RESOLVER * ord;
291 out.n_desc = @bitCast(macho.N_SYMBOL_RESOLVER * ord);
278292
279293 if (symbol.flags.weak) {
280 out.n_desc |= macho.N_WEAK_DEF;
294 out.n_desc.weak_def_or_ref_to_weak = true;
281295 }
282296
283297 if (symbol.weakRef(macho_file)) {
284 out.n_desc |= macho.N_WEAK_REF;
298 out.n_desc.weak_ref = true;
285299 }
286300 }
287301}
src/link/MachO/Thunk.zig+2-2
......@@ -56,10 +56,10 @@ pub fn writeSymtab(thunk: Thunk, macho_file: *MachO, ctx: anytype) void {
5656 n_strx += @intCast("__thunk".len);
5757 ctx.strtab.items[n_strx] = 0;
5858 n_strx += 1;
59 out_sym.n_type = macho.N_SECT;
59 out_sym.n_type = .{ .bits = .{ .ext = false, .type = .sect, .pext = false, .is_stab = 0 } };
6060 out_sym.n_sect = @intCast(thunk.out_n_sect + 1);
6161 out_sym.n_value = @intCast(thunk.getTargetAddress(ref, macho_file));
62 out_sym.n_desc = 0;
62 out_sym.n_desc = @bitCast(@as(u16, 0));
6363 }
6464}
6565
src/link/MachO/ZigObject.zig+16-16
......@@ -123,9 +123,9 @@ fn newSymbol(self: *ZigObject, allocator: Allocator, name: MachO.String, args: s
123123 self.symtab.set(nlist_idx, .{
124124 .nlist = .{
125125 .n_strx = name.pos,
126 .n_type = args.type,
126 .n_type = @bitCast(args.type),
127127 .n_sect = 0,
128 .n_desc = args.desc,
128 .n_desc = @bitCast(args.desc),
129129 .n_value = 0,
130130 },
131131 .size = 0,
......@@ -206,8 +206,8 @@ pub fn resolveSymbols(self: *ZigObject, macho_file: *MachO) !void {
206206 const gpa = macho_file.base.comp.gpa;
207207
208208 for (self.symtab.items(.nlist), self.symtab.items(.atom), self.globals.items, 0..) |nlist, atom_index, *global, i| {
209 if (!nlist.ext()) continue;
210 if (nlist.sect()) {
209 if (!nlist.n_type.bits.ext) continue;
210 if (nlist.n_type.bits.type == .sect) {
211211 const atom = self.getAtom(atom_index).?;
212212 if (!atom.isAlive()) continue;
213213 }
......@@ -221,7 +221,7 @@ pub fn resolveSymbols(self: *ZigObject, macho_file: *MachO) !void {
221221 }
222222 global.* = gop.index;
223223
224 if (nlist.undf() and !nlist.tentative()) continue;
224 if (nlist.n_type.bits.type == .undf and !nlist.tentative()) continue;
225225 if (gop.ref.getFile(macho_file) == null) {
226226 gop.ref.* = .{ .index = @intCast(i), .file = self.index };
227227 continue;
......@@ -229,7 +229,7 @@ pub fn resolveSymbols(self: *ZigObject, macho_file: *MachO) !void {
229229
230230 if (self.asFile().getSymbolRank(.{
231231 .archive = false,
232 .weak = nlist.weakDef(),
232 .weak = nlist.n_desc.weak_def_or_ref_to_weak,
233233 .tentative = nlist.tentative(),
234234 }) < gop.ref.getSymbol(macho_file).?.getSymbolRank(macho_file)) {
235235 gop.ref.* = .{ .index = @intCast(i), .file = self.index };
......@@ -243,12 +243,12 @@ pub fn markLive(self: *ZigObject, macho_file: *MachO) void {
243243
244244 for (0..self.symbols.items.len) |i| {
245245 const nlist = self.symtab.items(.nlist)[i];
246 if (!nlist.ext()) continue;
246 if (!nlist.n_type.bits.ext) continue;
247247
248248 const ref = self.getSymbolRef(@intCast(i), macho_file);
249249 const file = ref.getFile(macho_file) orelse continue;
250250 const sym = ref.getSymbol(macho_file).?;
251 const should_keep = nlist.undf() or (nlist.tentative() and !sym.flags.tentative);
251 const should_keep = nlist.n_type.bits.type == .undf or (nlist.tentative() and !sym.flags.tentative);
252252 if (should_keep and file == .object and !file.object.alive) {
253253 file.object.alive = true;
254254 file.object.markLive(macho_file);
......@@ -331,8 +331,8 @@ pub fn claimUnresolved(self: *ZigObject, macho_file: *MachO) void {
331331
332332 for (self.symbols.items, 0..) |*sym, i| {
333333 const nlist = self.symtab.items(.nlist)[i];
334 if (!nlist.ext()) continue;
335 if (!nlist.undf()) continue;
334 if (!nlist.n_type.bits.ext) continue;
335 if (nlist.n_type.bits.type != .undf) continue;
336336
337337 if (self.getSymbolRef(@intCast(i), macho_file).getFile(macho_file) != null) continue;
338338
......@@ -974,7 +974,7 @@ fn updateNavCode(
974974 atom.setAlive(true);
975975 atom.name = sym.name;
976976 nlist.n_strx = sym.name.pos;
977 nlist.n_type = macho.N_SECT;
977 nlist.n_type = .{ .bits = .{ .ext = false, .type = .sect, .pext = false, .is_stab = 0 } };
978978 nlist.n_sect = sect_index + 1;
979979 self.symtab.items(.size)[sym.nlist_idx] = code.len;
980980
......@@ -1115,7 +1115,7 @@ fn createTlvDescriptor(
11151115 atom.name = sym.name;
11161116 nlist.n_strx = sym.name.pos;
11171117 nlist.n_sect = sect_index + 1;
1118 nlist.n_type = macho.N_SECT;
1118 nlist.n_type = .{ .bits = .{ .ext = false, .type = .sect, .pext = false, .is_stab = 0 } };
11191119 nlist.n_value = 0;
11201120 self.symtab.items(.size)[sym.nlist_idx] = size;
11211121
......@@ -1322,7 +1322,7 @@ pub fn updateExports(
13221322 const global_sym = &self.symbols.items[global_nlist_index];
13231323 global_nlist.n_value = nlist.n_value;
13241324 global_nlist.n_sect = nlist.n_sect;
1325 global_nlist.n_type = macho.N_EXT | macho.N_SECT;
1325 global_nlist.n_type = .{ .bits = .{ .ext = true, .type = .sect, .pext = false, .is_stab = 0 } };
13261326 self.symtab.items(.size)[global_nlist_index] = self.symtab.items(.size)[nlist_idx];
13271327 self.symtab.items(.atom)[global_nlist_index] = atom_index;
13281328 global_sym.atom_ref = .{ .index = atom_index, .file = self.index };
......@@ -1330,7 +1330,7 @@ pub fn updateExports(
13301330 switch (exp.opts.linkage) {
13311331 .internal => {
13321332 // Symbol should be hidden, or in MachO lingo, private extern.
1333 global_nlist.n_type |= macho.N_PEXT;
1333 global_nlist.n_type.bits.pext = true;
13341334 global_sym.visibility = .hidden;
13351335 },
13361336 .strong => {
......@@ -1339,7 +1339,7 @@ pub fn updateExports(
13391339 .weak => {
13401340 // Weak linkage is specified as part of n_desc field.
13411341 // Symbol's n_type is like for a symbol with strong linkage.
1342 global_nlist.n_desc |= macho.N_WEAK_DEF;
1342 global_nlist.n_desc.weak_def_or_ref_to_weak = true;
13431343 global_sym.visibility = .global;
13441344 global_sym.flags.weak = true;
13451345 },
......@@ -1394,7 +1394,7 @@ fn updateLazySymbol(
13941394
13951395 const nlist = &self.symtab.items(.nlist)[sym.nlist_idx];
13961396 nlist.n_strx = name_str.pos;
1397 nlist.n_type = macho.N_SECT;
1397 nlist.n_type = .{ .bits = .{ .ext = false, .type = .sect, .pext = false, .is_stab = 0 } };
13981398 nlist.n_sect = output_section_index + 1;
13991399 self.symtab.items(.size)[sym.nlist_idx] = code.len;
14001400
src/link/MachO/eh_frame.zig+10-10
......@@ -26,24 +26,24 @@ pub const Cie = struct {
2626
2727 for (aug[1..]) |ch| switch (ch) {
2828 'R' => {
29 const enc = try reader.takeByte();
30 if (enc != DW_EH_PE.pcrel | DW_EH_PE.absptr) {
29 const enc: DW.EH.PE = @bitCast(try reader.takeByte());
30 if (enc != @as(DW.EH.PE, .{ .type = .absptr, .rel = .pcrel })) {
3131 @panic("unexpected pointer encoding"); // TODO error
3232 }
3333 },
3434 'P' => {
35 const enc = try reader.takeByte();
36 if (enc != DW_EH_PE.pcrel | DW_EH_PE.indirect | DW_EH_PE.sdata4) {
35 const enc: DW.EH.PE = @bitCast(try reader.takeByte());
36 if (enc != @as(DW.EH.PE, .{ .type = .sdata4, .rel = .pcrel, .indirect = true })) {
3737 @panic("unexpected personality pointer encoding"); // TODO error
3838 }
3939 _ = try reader.takeInt(u32, .little); // personality pointer
4040 },
4141 'L' => {
42 const enc = try reader.takeByte();
43 switch (enc & DW_EH_PE.type_mask) {
44 DW_EH_PE.sdata4 => cie.lsda_size = .p32,
45 DW_EH_PE.absptr => cie.lsda_size = .p64,
46 else => unreachable, // TODO error
42 const enc: DW.EH.PE = @bitCast(try reader.takeByte());
43 switch (enc.type) {
44 .sdata4 => cie.lsda_size = .p32,
45 .absptr => cie.lsda_size = .p64,
46 else => @panic("unexpected lsda encoding"), // TODO error
4747 }
4848 },
4949 else => @panic("unexpected augmentation string"), // TODO error
......@@ -505,7 +505,7 @@ const Writer = std.Io.Writer;
505505
506506const Allocator = std.mem.Allocator;
507507const Atom = @import("Atom.zig");
508const DW_EH_PE = std.dwarf.EH.PE;
508const DW = std.dwarf;
509509const File = @import("file.zig").File;
510510const MachO = @import("../MachO.zig");
511511const Object = @import("Object.zig");
src/link/MachO/file.zig+8-8
......@@ -192,21 +192,21 @@ pub const File = union(enum) {
192192 assert(file == .object or file == .zig_object);
193193
194194 for (file.getSymbols(), file.getNlists(), 0..) |*sym, nlist, i| {
195 if (!nlist.ext()) continue;
196 if (!nlist.undf()) continue;
195 if (!nlist.n_type.bits.ext) continue;
196 if (nlist.n_type.bits.type != .undf) continue;
197197
198198 if (file.getSymbolRef(@intCast(i), macho_file).getFile(macho_file) != null) continue;
199199
200200 const is_import = switch (macho_file.undefined_treatment) {
201201 .@"error" => false,
202 .warn, .suppress => nlist.weakRef(),
202 .warn, .suppress => nlist.n_desc.weak_ref,
203203 .dynamic_lookup => true,
204204 };
205205 if (is_import) {
206206 sym.value = 0;
207207 sym.atom_ref = .{ .index = 0, .file = 0 };
208208 sym.flags.weak = false;
209 sym.flags.weak_ref = nlist.weakRef();
209 sym.flags.weak_ref = nlist.n_desc.weak_ref;
210210 sym.flags.import = is_import;
211211 sym.visibility = .global;
212212
......@@ -223,13 +223,13 @@ pub const File = union(enum) {
223223 assert(file == .object or file == .zig_object);
224224
225225 for (file.getSymbols(), file.getNlists(), 0..) |*sym, nlist, i| {
226 if (!nlist.ext()) continue;
227 if (!nlist.undf()) continue;
226 if (!nlist.n_type.bits.ext) continue;
227 if (nlist.n_type.bits.type != .undf) continue;
228228 if (file.getSymbolRef(@intCast(i), macho_file).getFile(macho_file) != null) continue;
229229
230230 sym.value = 0;
231231 sym.atom_ref = .{ .index = 0, .file = 0 };
232 sym.flags.weak_ref = nlist.weakRef();
232 sym.flags.weak_ref = nlist.n_desc.weak_ref;
233233 sym.flags.import = true;
234234 sym.visibility = .global;
235235
......@@ -247,7 +247,7 @@ pub const File = union(enum) {
247247 for (file.getSymbols(), file.getNlists(), 0..) |sym, nlist, i| {
248248 if (sym.visibility != .global) continue;
249249 if (sym.flags.weak) continue;
250 if (nlist.undf()) continue;
250 if (nlist.n_type.bits.type == .undf) continue;
251251 const ref = file.getSymbolRef(@intCast(i), macho_file);
252252 const ref_file = ref.getFile(macho_file) orelse continue;
253253 if (ref_file.getIndex() == file.getIndex()) continue;