authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-07-26 14:06:21+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-07-30 10:00:50+02:00
log96c20adeee84dbd86a7036cce49ef0c58870bdce
tree47dc611108a5b29db163554ac90104b65d027b73
parentc575e3daa4cdb39e38cc0b32fc8fe4a917947d34

elf: remove obsolete flags from atom


8 files changed, 62 insertions(+), 74 deletions(-)

src/link/Elf.zig+4-4
......@@ -1371,7 +1371,7 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod
13711371 var has_reloc_errors = false;
13721372 for (zo.atoms_indexes.items) |atom_index| {
13731373 const atom_ptr = zo.atom(atom_index) orelse continue;
1374 if (!atom_ptr.flags.alive) continue;
1374 if (!atom_ptr.alive) continue;
13751375 const out_shndx = atom_ptr.outputShndx() orelse continue;
13761376 const shdr = &self.shdrs.items[out_shndx];
13771377 if (shdr.sh_type == elf.SHT_NOBITS) continue;
......@@ -4130,7 +4130,7 @@ fn resetShdrIndexes(self: *Elf, backlinks: []const u32) !void {
41304130 for (zo.globals()) |global_index| {
41314131 const global = self.symbol(global_index);
41324132 const atom_ptr = global.atom(self) orelse continue;
4133 if (!atom_ptr.flags.alive) continue;
4133 if (!atom_ptr.alive) continue;
41344134 // TODO claim unresolved for objects
41354135 if (global.file(self).?.index() != zo.index) continue;
41364136 const out_shndx = global.outputShndx() orelse continue;
......@@ -4157,7 +4157,7 @@ fn updateSectionSizes(self: *Elf) !void {
41574157 if (self.requiresThunks() and shdr.sh_flags & elf.SHF_EXECINSTR != 0) continue;
41584158 for (atom_list.items) |ref| {
41594159 const atom_ptr = self.atom(ref) orelse continue;
4160 if (!atom_ptr.flags.alive) continue;
4160 if (!atom_ptr.alive) continue;
41614161 const offset = atom_ptr.alignment.forward(shdr.sh_size);
41624162 const padding = offset - shdr.sh_size;
41634163 atom_ptr.value = @intCast(offset);
......@@ -4641,7 +4641,7 @@ fn writeAtoms(self: *Elf) !void {
46414641
46424642 for (atom_list.items) |ref| {
46434643 const atom_ptr = self.atom(ref).?;
4644 assert(atom_ptr.flags.alive);
4644 assert(atom_ptr.alive);
46454645
46464646 const offset = math.cast(usize, atom_ptr.value - @as(i64, @intCast(base_offset))) orelse
46474647 return error.Overflow;
src/link/Elf/Atom.zig+14-24
......@@ -30,8 +30,11 @@ atom_index: Index = 0,
3030prev_index: Index = 0,
3131next_index: Index = 0,
3232
33/// Flags we use for state tracking.
34flags: Flags = .{},
33/// Specifies whether this atom is alive or has been garbage collected.
34alive: bool = true,
35
36/// Specifies if the atom has been visited during garbage collection.
37visited: bool = false,
3538
3639extra_index: u32 = 0,
3740
......@@ -55,7 +58,7 @@ pub fn debugTombstoneValue(self: Atom, target: Symbol, elf_file: *Elf) ?u64 {
5558 if (msub.alive) return null;
5659 }
5760 if (target.atom(elf_file)) |atom_ptr| {
58 if (atom_ptr.flags.alive) return null;
61 if (atom_ptr.alive) return null;
5962 }
6063 const atom_name = self.name(elf_file);
6164 if (!mem.startsWith(u8, atom_name, ".debug")) return null;
......@@ -67,7 +70,6 @@ pub fn file(self: Atom, elf_file: *Elf) ?File {
6770}
6871
6972pub fn thunk(self: Atom, elf_file: *Elf) *Thunk {
70 assert(self.flags.thunk);
7173 const extras = self.extra(elf_file);
7274 return elf_file.thunk(extras.thunk);
7375}
......@@ -237,7 +239,7 @@ pub fn allocate(self: *Atom, elf_file: *Elf) !void {
237239 _ = free_list.swapRemove(i);
238240 }
239241
240 self.flags.alive = true;
242 self.alive = true;
241243}
242244
243245pub fn shrink(self: *Atom, elf_file: *Elf) void {
......@@ -373,10 +375,12 @@ pub fn writeRelocs(self: Atom, elf_file: *Elf, out_relocs: *std.ArrayList(elf.El
373375}
374376
375377pub fn fdes(self: Atom, elf_file: *Elf) []Fde {
376 if (!self.flags.fde) return &[0]Fde{};
377378 const extras = self.extra(elf_file);
378 const object = self.file(elf_file).?.object;
379 return object.fdes.items[extras.fde_start..][0..extras.fde_count];
379 return switch (self.file(elf_file).?) {
380 .shared_object => unreachable,
381 .linker_defined, .zig_object => &[0]Fde{},
382 .object => |x| x.fdes.items[extras.fde_start..][0..extras.fde_count],
383 };
380384}
381385
382386pub fn markFdesDead(self: Atom, elf_file: *Elf) void {
......@@ -1066,7 +1070,7 @@ fn format2(
10661070 atom.atom_index, atom.name(elf_file), atom.address(elf_file),
10671071 atom.output_section_index, atom.alignment, atom.size,
10681072 });
1069 if (atom.flags.fde) {
1073 if (atom.fdes(elf_file).len > 0) {
10701074 try writer.writeAll(" : fdes{ ");
10711075 const extras = atom.extra(elf_file);
10721076 for (atom.fdes(elf_file), extras.fde_start..) |fde, i| {
......@@ -1076,27 +1080,13 @@ fn format2(
10761080 }
10771081 try writer.writeAll(" }");
10781082 }
1079 if (!atom.flags.alive) {
1083 if (!atom.alive) {
10801084 try writer.writeAll(" : [*]");
10811085 }
10821086}
10831087
10841088pub const Index = u32;
10851089
1086pub const Flags = packed struct {
1087 /// Specifies whether this atom is alive or has been garbage collected.
1088 alive: bool = true,
1089
1090 /// Specifies if the atom has been visited during garbage collection.
1091 visited: bool = false,
1092
1093 /// Whether this atom has a range extension thunk.
1094 thunk: bool = false,
1095
1096 /// Whether this atom has FDE records.
1097 fde: bool = false,
1098};
1099
11001090const x86_64 = struct {
11011091 fn scanReloc(
11021092 atom: Atom,
src/link/Elf/Object.zig+16-17
......@@ -84,7 +84,7 @@ pub fn parse(self: *Object, elf_file: *Elf) !void {
8484
8585 for (self.shdrs.items, 0..) |shdr, i| {
8686 const atom_ptr = self.atom(self.atoms_indexes.items[i]) orelse continue;
87 if (!atom_ptr.flags.alive) continue;
87 if (!atom_ptr.alive) continue;
8888 if ((cpu_arch == .x86_64 and shdr.sh_type == elf.SHT_X86_64_UNWIND) or
8989 mem.eql(u8, atom_ptr.name(elf_file), ".eh_frame"))
9090 {
......@@ -484,7 +484,6 @@ fn parseEhFrame(self: *Object, allocator: Allocator, handle: std.fs.File, shndx:
484484 if (atom_ptr.atom_index != next_fde.atom(elf_file).atom_index) break;
485485 }
486486 atom_ptr.addExtra(.{ .fde_start = start, .fde_count = i - start }, elf_file);
487 atom_ptr.flags.fde = true;
488487 }
489488}
490489
......@@ -529,7 +528,7 @@ pub fn scanRelocs(self: *Object, elf_file: *Elf, undefs: anytype) !void {
529528 const gpa = comp.gpa;
530529 for (self.atoms_indexes.items) |atom_index| {
531530 const atom_ptr = self.atom(atom_index) orelse continue;
532 if (!atom_ptr.flags.alive) continue;
531 if (!atom_ptr.alive) continue;
533532 const shdr = atom_ptr.inputShdr(elf_file);
534533 if (shdr.sh_flags & elf.SHF_ALLOC == 0) continue;
535534 if (shdr.sh_type == elf.SHT_NOBITS) continue;
......@@ -569,7 +568,7 @@ pub fn resolveSymbols(self: *Object, elf_file: *Elf) void {
569568 if (esym.st_shndx != elf.SHN_ABS and esym.st_shndx != elf.SHN_COMMON) {
570569 const atom_index = self.atoms_indexes.items[esym.st_shndx];
571570 const atom_ptr = self.atom(atom_index) orelse continue;
572 if (!atom_ptr.flags.alive) continue;
571 if (!atom_ptr.alive) continue;
573572 }
574573
575574 const global = elf_file.symbol(index);
......@@ -661,7 +660,7 @@ pub fn markEhFrameAtomsDead(self: *Object, elf_file: *Elf) void {
661660 const atom_ptr = self.atom(atom_index) orelse continue;
662661 const is_eh_frame = (cpu_arch == .x86_64 and atom_ptr.inputShdr(elf_file).sh_type == elf.SHT_X86_64_UNWIND) or
663662 mem.eql(u8, atom_ptr.name(elf_file), ".eh_frame");
664 if (atom_ptr.flags.alive and is_eh_frame) atom_ptr.flags.alive = false;
663 if (atom_ptr.alive and is_eh_frame) atom_ptr.alive = false;
665664 }
666665}
667666
......@@ -681,7 +680,7 @@ pub fn checkDuplicates(self: *Object, dupes: anytype, elf_file: *Elf) error{OutO
681680 if (sym.st_shndx != elf.SHN_ABS) {
682681 const atom_index = self.atoms_indexes.items[sym.st_shndx];
683682 const atom_ptr = self.atom(atom_index) orelse continue;
684 if (!atom_ptr.flags.alive) continue;
683 if (!atom_ptr.alive) continue;
685684 }
686685
687686 const gop = try dupes.getOrPut(index);
......@@ -704,7 +703,7 @@ pub fn initMergeSections(self: *Object, elf_file: *Elf) !void {
704703
705704 const atom_index = self.atoms_indexes.items[shndx];
706705 const atom_ptr = self.atom(atom_index) orelse continue;
707 if (!atom_ptr.flags.alive) continue;
706 if (!atom_ptr.alive) continue;
708707 if (atom_ptr.relocs(elf_file).len > 0) continue;
709708
710709 const imsec_idx = try self.addInputMergeSection(gpa);
......@@ -766,7 +765,7 @@ pub fn initMergeSections(self: *Object, elf_file: *Elf) !void {
766765 }
767766 }
768767
769 atom_ptr.flags.alive = false;
768 atom_ptr.alive = false;
770769 }
771770}
772771
......@@ -826,7 +825,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) !void {
826825
827826 for (self.atoms_indexes.items) |atom_index| {
828827 const atom_ptr = self.atom(atom_index) orelse continue;
829 if (!atom_ptr.flags.alive) continue;
828 if (!atom_ptr.alive) continue;
830829 const extras = atom_ptr.extra(elf_file);
831830 const relocs = self.relocs.items[extras.rel_index..][0..extras.rel_count];
832831 for (relocs) |*rel| {
......@@ -950,7 +949,7 @@ pub fn markComdatGroupsDead(self: *Object, elf_file: *Elf) void {
950949 for (cg.comdatGroupMembers(elf_file)) |shndx| {
951950 const atom_index = self.atoms_indexes.items[shndx];
952951 if (self.atom(atom_index)) |atom_ptr| {
953 atom_ptr.flags.alive = false;
952 atom_ptr.alive = false;
954953 atom_ptr.markFdesDead(elf_file);
955954 }
956955 }
......@@ -960,7 +959,7 @@ pub fn markComdatGroupsDead(self: *Object, elf_file: *Elf) void {
960959pub fn initOutputSections(self: *Object, elf_file: *Elf) !void {
961960 for (self.atoms_indexes.items) |atom_index| {
962961 const atom_ptr = self.atom(atom_index) orelse continue;
963 if (!atom_ptr.flags.alive) continue;
962 if (!atom_ptr.alive) continue;
964963 const shdr = atom_ptr.inputShdr(elf_file);
965964 _ = try self.initOutputSection(elf_file, shdr);
966965 }
......@@ -969,7 +968,7 @@ pub fn initOutputSections(self: *Object, elf_file: *Elf) !void {
969968pub fn addAtomsToOutputSections(self: *Object, elf_file: *Elf) !void {
970969 for (self.atoms_indexes.items) |atom_index| {
971970 const atom_ptr = self.atom(atom_index) orelse continue;
972 if (!atom_ptr.flags.alive) continue;
971 if (!atom_ptr.alive) continue;
973972 const shdr = atom_ptr.inputShdr(elf_file);
974973 atom_ptr.output_section_index = self.initOutputSection(elf_file, shdr) catch unreachable;
975974
......@@ -988,7 +987,7 @@ pub fn addAtomsToOutputSections(self: *Object, elf_file: *Elf) !void {
988987 continue;
989988 }
990989 const atom_ptr = local.atom(elf_file) orelse continue;
991 if (!atom_ptr.flags.alive) continue;
990 if (!atom_ptr.alive) continue;
992991 local.output_section_index = atom_ptr.output_section_index;
993992 }
994993
......@@ -1001,7 +1000,7 @@ pub fn addAtomsToOutputSections(self: *Object, elf_file: *Elf) !void {
10011000 continue;
10021001 }
10031002 const atom_ptr = global.atom(elf_file) orelse continue;
1004 if (!atom_ptr.flags.alive) continue;
1003 if (!atom_ptr.alive) continue;
10051004 global.output_section_index = atom_ptr.output_section_index;
10061005 }
10071006
......@@ -1016,7 +1015,7 @@ pub fn addAtomsToOutputSections(self: *Object, elf_file: *Elf) !void {
10161015pub fn initRelaSections(self: *Object, elf_file: *Elf) !void {
10171016 for (self.atoms_indexes.items) |atom_index| {
10181017 const atom_ptr = self.atom(atom_index) orelse continue;
1019 if (!atom_ptr.flags.alive) continue;
1018 if (!atom_ptr.alive) continue;
10201019 const shndx = atom_ptr.relocsShndx() orelse continue;
10211020 const shdr = self.shdrs.items[shndx];
10221021 const out_shndx = try self.initOutputSection(elf_file, shdr);
......@@ -1030,7 +1029,7 @@ pub fn initRelaSections(self: *Object, elf_file: *Elf) !void {
10301029pub fn addAtomsToRelaSections(self: *Object, elf_file: *Elf) !void {
10311030 for (self.atoms_indexes.items) |atom_index| {
10321031 const atom_ptr = self.atom(atom_index) orelse continue;
1033 if (!atom_ptr.flags.alive) continue;
1032 if (!atom_ptr.alive) continue;
10341033 const shndx = blk: {
10351034 const shndx = atom_ptr.relocsShndx() orelse continue;
10361035 const shdr = self.shdrs.items[shndx];
......@@ -1100,7 +1099,7 @@ pub fn updateSymtabSize(self: *Object, elf_file: *Elf) !void {
11001099 const isAlive = struct {
11011100 fn isAlive(sym: *const Symbol, ctx: *Elf) bool {
11021101 if (sym.mergeSubsection(ctx)) |msub| return msub.alive;
1103 if (sym.atom(ctx)) |atom_ptr| return atom_ptr.flags.alive;
1102 if (sym.atom(ctx)) |atom_ptr| return atom_ptr.alive;
11041103 return true;
11051104 }
11061105 }.isAlive;
src/link/Elf/Symbol.zig+1-1
......@@ -116,7 +116,7 @@ pub fn address(symbol: Symbol, opts: struct { plt: bool = true }, elf_file: *Elf
116116 return symbol.pltAddress(elf_file);
117117 }
118118 if (symbol.atom(elf_file)) |atom_ptr| {
119 if (!atom_ptr.flags.alive) {
119 if (!atom_ptr.alive) {
120120 if (mem.eql(u8, atom_ptr.name(elf_file), ".eh_frame")) {
121121 const sym_name = symbol.name(elf_file);
122122 const sh_addr, const sh_size = blk: {
src/link/Elf/ZigObject.zig+10-10
......@@ -331,7 +331,7 @@ pub fn resolveSymbols(self: *ZigObject, elf_file: *Elf) void {
331331 if (esym.st_shndx != elf.SHN_ABS and esym.st_shndx != elf.SHN_COMMON) {
332332 assert(esym.st_shndx == SHN_ATOM);
333333 const atom_ptr = self.atom(shndx) orelse continue;
334 if (!atom_ptr.flags.alive) continue;
334 if (!atom_ptr.alive) continue;
335335 }
336336
337337 const global = elf_file.symbol(index);
......@@ -407,7 +407,7 @@ pub fn scanRelocs(self: *ZigObject, elf_file: *Elf, undefs: anytype) !void {
407407 const gpa = elf_file.base.comp.gpa;
408408 for (self.atoms_indexes.items) |atom_index| {
409409 const atom_ptr = self.atom(atom_index) orelse continue;
410 if (!atom_ptr.flags.alive) continue;
410 if (!atom_ptr.alive) continue;
411411 const shdr = atom_ptr.inputShdr(elf_file);
412412 if (shdr.sh_type == elf.SHT_NOBITS) continue;
413413 if (atom_ptr.scanRelocsRequiresCode(elf_file)) {
......@@ -451,7 +451,7 @@ pub fn checkDuplicates(self: *ZigObject, dupes: anytype, elf_file: *Elf) error{O
451451
452452 if (esym.st_shndx == SHN_ATOM) {
453453 const atom_ptr = self.atom(shndx) orelse continue;
454 if (!atom_ptr.flags.alive) continue;
454 if (!atom_ptr.alive) continue;
455455 }
456456
457457 const gop = try dupes.getOrPut(index);
......@@ -519,7 +519,7 @@ pub fn writeAr(self: ZigObject, writer: anytype) !void {
519519pub fn addAtomsToRelaSections(self: *ZigObject, elf_file: *Elf) !void {
520520 for (self.atoms_indexes.items) |atom_index| {
521521 const atom_ptr = self.atom(atom_index) orelse continue;
522 if (!atom_ptr.flags.alive) continue;
522 if (!atom_ptr.alive) continue;
523523 const rela_shndx = atom_ptr.relocsShndx() orelse continue;
524524 // TODO this check will become obsolete when we rework our relocs mechanism at the ZigObject level
525525 if (self.relocs.items[rela_shndx].items.len == 0) continue;
......@@ -560,7 +560,7 @@ pub fn globals(self: ZigObject) []const Symbol.Index {
560560pub fn updateSymtabSize(self: *ZigObject, elf_file: *Elf) !void {
561561 for (self.locals()) |local_index| {
562562 const local = elf_file.symbol(local_index);
563 if (local.atom(elf_file)) |atom_ptr| if (!atom_ptr.flags.alive) continue;
563 if (local.atom(elf_file)) |atom_ptr| if (!atom_ptr.alive) continue;
564564 const esym = local.elfSym(elf_file);
565565 switch (esym.st_type()) {
566566 elf.STT_SECTION, elf.STT_NOTYPE => continue,
......@@ -576,7 +576,7 @@ pub fn updateSymtabSize(self: *ZigObject, elf_file: *Elf) !void {
576576 const global = elf_file.symbol(global_index);
577577 const file_ptr = global.file(elf_file) orelse continue;
578578 if (file_ptr.index() != self.index) continue;
579 if (global.atom(elf_file)) |atom_ptr| if (!atom_ptr.flags.alive) continue;
579 if (global.atom(elf_file)) |atom_ptr| if (!atom_ptr.alive) continue;
580580 global.flags.output_symtab = true;
581581 if (global.isLocal(elf_file)) {
582582 try global.addExtra(.{ .symtab = self.output_symtab_ctx.nlocals }, elf_file);
......@@ -922,7 +922,7 @@ fn updateDeclCode(
922922 atom_ptr.output_section_index = shdr_index;
923923
924924 sym.name_offset = try self.strtab.insert(gpa, decl.fqn.toSlice(ip));
925 atom_ptr.flags.alive = true;
925 atom_ptr.alive = true;
926926 atom_ptr.name_offset = sym.name_offset;
927927 esym.st_name = sym.name_offset;
928928 esym.st_info |= stt_bits;
......@@ -1022,7 +1022,7 @@ fn updateTlv(
10221022 atom_ptr.output_section_index = shndx;
10231023
10241024 sym.name_offset = try self.strtab.insert(gpa, decl.fqn.toSlice(ip));
1025 atom_ptr.flags.alive = true;
1025 atom_ptr.alive = true;
10261026 atom_ptr.name_offset = sym.name_offset;
10271027 esym.st_value = 0;
10281028 esym.st_name = sym.name_offset;
......@@ -1246,7 +1246,7 @@ fn updateLazySymbol(
12461246 local_esym.st_info |= elf.STT_OBJECT;
12471247 local_esym.st_size = code.len;
12481248 const atom_ptr = local_sym.atom(elf_file).?;
1249 atom_ptr.flags.alive = true;
1249 atom_ptr.alive = true;
12501250 atom_ptr.name_offset = name_str_index;
12511251 atom_ptr.alignment = required_alignment;
12521252 atom_ptr.size = code.len;
......@@ -1354,7 +1354,7 @@ fn lowerConst(
13541354 local_esym.st_info |= elf.STT_OBJECT;
13551355 local_esym.st_size = code.len;
13561356 const atom_ptr = local_sym.atom(elf_file).?;
1357 atom_ptr.flags.alive = true;
1357 atom_ptr.alive = true;
13581358 atom_ptr.name_offset = name_str_index;
13591359 atom_ptr.alignment = required_alignment;
13601360 atom_ptr.size = code.len;
src/link/Elf/gc.zig+11-11
......@@ -36,7 +36,7 @@ fn collectRoots(roots: *std.ArrayList(*Atom), files: []const File.Index, elf_fil
3636
3737 for (file.atoms()) |atom_index| {
3838 const atom = file.atom(atom_index) orelse continue;
39 if (!atom.flags.alive) continue;
39 if (!atom.alive) continue;
4040
4141 const shdr = atom.inputShdr(elf_file);
4242 const name = atom.name(elf_file);
......@@ -54,7 +54,7 @@ fn collectRoots(roots: *std.ArrayList(*Atom), files: []const File.Index, elf_fil
5454 break :blk false;
5555 };
5656 if (is_gc_root and markAtom(atom)) try roots.append(atom);
57 if (shdr.sh_flags & elf.SHF_ALLOC == 0) atom.flags.visited = true;
57 if (shdr.sh_flags & elf.SHF_ALLOC == 0) atom.visited = true;
5858 }
5959
6060 // Mark every atom referenced by CIE as alive.
......@@ -77,22 +77,22 @@ fn markSymbol(sym: *Symbol, roots: *std.ArrayList(*Atom), elf_file: *Elf) !void
7777}
7878
7979fn markAtom(atom: *Atom) bool {
80 const already_visited = atom.flags.visited;
81 atom.flags.visited = true;
82 return atom.flags.alive and !already_visited;
80 const already_visited = atom.visited;
81 atom.visited = true;
82 return atom.alive and !already_visited;
8383}
8484
8585fn markLive(atom: *Atom, elf_file: *Elf) void {
8686 if (@import("build_options").enable_logging) track_live_level.incr();
8787
88 assert(atom.flags.visited);
88 assert(atom.visited);
8989 const file = atom.file(elf_file).?;
9090
9191 for (atom.fdes(elf_file)) |fde| {
9292 for (fde.relocs(elf_file)[1..]) |rel| {
9393 const target_sym = elf_file.symbol(file.symbol(rel.r_sym()));
9494 const target_atom = target_sym.atom(elf_file) orelse continue;
95 target_atom.flags.alive = true;
95 target_atom.alive = true;
9696 gc_track_live_log.debug("{}marking live atom({d})", .{ track_live_level, target_atom.atom_index });
9797 if (markAtom(target_atom)) markLive(target_atom, elf_file);
9898 }
......@@ -105,7 +105,7 @@ fn markLive(atom: *Atom, elf_file: *Elf) void {
105105 continue;
106106 }
107107 const target_atom = target_sym.atom(elf_file) orelse continue;
108 target_atom.flags.alive = true;
108 target_atom.alive = true;
109109 gc_track_live_log.debug("{}marking live atom({d})", .{ track_live_level, target_atom.atom_index });
110110 if (markAtom(target_atom)) markLive(target_atom, elf_file);
111111 }
......@@ -123,8 +123,8 @@ fn prune(files: []const File.Index, elf_file: *Elf) void {
123123 const file = elf_file.file(index).?;
124124 for (file.atoms()) |atom_index| {
125125 const atom = file.atom(atom_index) orelse continue;
126 if (atom.flags.alive and !atom.flags.visited) {
127 atom.flags.alive = false;
126 if (atom.alive and !atom.visited) {
127 atom.alive = false;
128128 atom.markFdesDead(elf_file);
129129 }
130130 }
......@@ -137,7 +137,7 @@ pub fn dumpPrunedAtoms(elf_file: *Elf) !void {
137137 const file = elf_file.file(index).?;
138138 for (file.atoms()) |atom_index| {
139139 const atom = file.atom(atom_index) orelse continue;
140 if (!atom.flags.alive)
140 if (!atom.alive)
141141 // TODO should we simply print to stderr?
142142 try stderr.print("link: removing unused section '{s}' in file '{}'\n", .{
143143 atom.name(elf_file),
src/link/Elf/relocatable.zig+4-4
......@@ -340,7 +340,7 @@ fn updateSectionSizes(elf_file: *Elf) !void {
340340 const shdr = &elf_file.shdrs.items[shndx];
341341 for (atom_list.items) |ref| {
342342 const atom_ptr = elf_file.atom(ref) orelse continue;
343 if (!atom_ptr.flags.alive) continue;
343 if (!atom_ptr.alive) continue;
344344 const offset = atom_ptr.alignment.forward(shdr.sh_size);
345345 const padding = offset - shdr.sh_size;
346346 atom_ptr.value = @intCast(offset);
......@@ -353,7 +353,7 @@ fn updateSectionSizes(elf_file: *Elf) !void {
353353 const shdr = &elf_file.shdrs.items[sec.shndx];
354354 for (sec.atom_list.items) |ref| {
355355 const atom_ptr = elf_file.atom(ref) orelse continue;
356 if (!atom_ptr.flags.alive) continue;
356 if (!atom_ptr.alive) continue;
357357 const relocs = atom_ptr.relocs(elf_file);
358358 shdr.sh_size += shdr.sh_entsize * relocs.len;
359359 }
......@@ -447,7 +447,7 @@ fn writeAtoms(elf_file: *Elf) !void {
447447
448448 for (atom_list.items) |ref| {
449449 const atom_ptr = elf_file.atom(ref).?;
450 assert(atom_ptr.flags.alive);
450 assert(atom_ptr.alive);
451451
452452 const offset = math.cast(usize, atom_ptr.value - @as(i64, @intCast(shdr.sh_addr - base_offset))) orelse
453453 return error.Overflow;
......@@ -489,7 +489,7 @@ fn writeSyntheticSections(elf_file: *Elf) !void {
489489
490490 for (sec.atom_list.items) |ref| {
491491 const atom_ptr = elf_file.atom(ref) orelse continue;
492 if (!atom_ptr.flags.alive) continue;
492 if (!atom_ptr.alive) continue;
493493 try atom_ptr.writeRelocs(elf_file, &relocs);
494494 }
495495 assert(relocs.items.len == num_relocs);
src/link/Elf/thunks.zig+2-3
......@@ -14,13 +14,13 @@ pub fn createThunks(shndx: u32, elf_file: *Elf) !void {
1414 while (i < atoms.len) {
1515 const start = i;
1616 const start_atom = elf_file.atom(atoms[start]).?;
17 assert(start_atom.flags.alive);
17 assert(start_atom.alive);
1818 start_atom.value = try advance(shdr, start_atom.size, start_atom.alignment);
1919 i += 1;
2020
2121 while (i < atoms.len) : (i += 1) {
2222 const atom = elf_file.atom(atoms[i]).?;
23 assert(atom.flags.alive);
23 assert(atom.alive);
2424 if (@as(i64, @intCast(atom.alignment.forward(shdr.sh_size))) - start_atom.value >= max_distance)
2525 break;
2626 atom.value = try advance(shdr, atom.size, atom.alignment);
......@@ -51,7 +51,6 @@ pub fn createThunks(shndx: u32, elf_file: *Elf) !void {
5151 try thunk.symbols.put(gpa, target, {});
5252 }
5353 atom.addExtra(.{ .thunk = thunk_index }, elf_file);
54 atom.flags.thunk = true;
5554 }
5655
5756 thunk.value = try advance(shdr, thunk.size(elf_file), Atom.Alignment.fromNonzeroByteUnits(2));