Commit 96c20adeee

Jakub Konka <kubkon@jakubkonka.com>
2024-07-26 14:06:21
elf: remove obsolete flags from atom
1 parent c575e3d
src/link/Elf/Atom.zig
@@ -30,8 +30,11 @@ atom_index: Index = 0,
 prev_index: Index = 0,
 next_index: Index = 0,
 
-/// Flags we use for state tracking.
-flags: Flags = .{},
+/// Specifies whether this atom is alive or has been garbage collected.
+alive: bool = true,
+
+/// Specifies if the atom has been visited during garbage collection.
+visited: bool = false,
 
 extra_index: u32 = 0,
 
@@ -55,7 +58,7 @@ pub fn debugTombstoneValue(self: Atom, target: Symbol, elf_file: *Elf) ?u64 {
         if (msub.alive) return null;
     }
     if (target.atom(elf_file)) |atom_ptr| {
-        if (atom_ptr.flags.alive) return null;
+        if (atom_ptr.alive) return null;
     }
     const atom_name = self.name(elf_file);
     if (!mem.startsWith(u8, atom_name, ".debug")) return null;
@@ -67,7 +70,6 @@ pub fn file(self: Atom, elf_file: *Elf) ?File {
 }
 
 pub fn thunk(self: Atom, elf_file: *Elf) *Thunk {
-    assert(self.flags.thunk);
     const extras = self.extra(elf_file);
     return elf_file.thunk(extras.thunk);
 }
@@ -237,7 +239,7 @@ pub fn allocate(self: *Atom, elf_file: *Elf) !void {
         _ = free_list.swapRemove(i);
     }
 
-    self.flags.alive = true;
+    self.alive = true;
 }
 
 pub 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
 }
 
 pub fn fdes(self: Atom, elf_file: *Elf) []Fde {
-    if (!self.flags.fde) return &[0]Fde{};
     const extras = self.extra(elf_file);
-    const object = self.file(elf_file).?.object;
-    return object.fdes.items[extras.fde_start..][0..extras.fde_count];
+    return switch (self.file(elf_file).?) {
+        .shared_object => unreachable,
+        .linker_defined, .zig_object => &[0]Fde{},
+        .object => |x| x.fdes.items[extras.fde_start..][0..extras.fde_count],
+    };
 }
 
 pub fn markFdesDead(self: Atom, elf_file: *Elf) void {
@@ -1066,7 +1070,7 @@ fn format2(
         atom.atom_index,           atom.name(elf_file), atom.address(elf_file),
         atom.output_section_index, atom.alignment,      atom.size,
     });
-    if (atom.flags.fde) {
+    if (atom.fdes(elf_file).len > 0) {
         try writer.writeAll(" : fdes{ ");
         const extras = atom.extra(elf_file);
         for (atom.fdes(elf_file), extras.fde_start..) |fde, i| {
@@ -1076,27 +1080,13 @@ fn format2(
         }
         try writer.writeAll(" }");
     }
-    if (!atom.flags.alive) {
+    if (!atom.alive) {
         try writer.writeAll(" : [*]");
     }
 }
 
 pub const Index = u32;
 
-pub const Flags = packed struct {
-    /// Specifies whether this atom is alive or has been garbage collected.
-    alive: bool = true,
-
-    /// Specifies if the atom has been visited during garbage collection.
-    visited: bool = false,
-
-    /// Whether this atom has a range extension thunk.
-    thunk: bool = false,
-
-    /// Whether this atom has FDE records.
-    fde: bool = false,
-};
-
 const x86_64 = struct {
     fn scanReloc(
         atom: Atom,
src/link/Elf/gc.zig
@@ -36,7 +36,7 @@ fn collectRoots(roots: *std.ArrayList(*Atom), files: []const File.Index, elf_fil
 
         for (file.atoms()) |atom_index| {
             const atom = file.atom(atom_index) orelse continue;
-            if (!atom.flags.alive) continue;
+            if (!atom.alive) continue;
 
             const shdr = atom.inputShdr(elf_file);
             const name = atom.name(elf_file);
@@ -54,7 +54,7 @@ fn collectRoots(roots: *std.ArrayList(*Atom), files: []const File.Index, elf_fil
                 break :blk false;
             };
             if (is_gc_root and markAtom(atom)) try roots.append(atom);
-            if (shdr.sh_flags & elf.SHF_ALLOC == 0) atom.flags.visited = true;
+            if (shdr.sh_flags & elf.SHF_ALLOC == 0) atom.visited = true;
         }
 
         // Mark every atom referenced by CIE as alive.
@@ -77,22 +77,22 @@ fn markSymbol(sym: *Symbol, roots: *std.ArrayList(*Atom), elf_file: *Elf) !void
 }
 
 fn markAtom(atom: *Atom) bool {
-    const already_visited = atom.flags.visited;
-    atom.flags.visited = true;
-    return atom.flags.alive and !already_visited;
+    const already_visited = atom.visited;
+    atom.visited = true;
+    return atom.alive and !already_visited;
 }
 
 fn markLive(atom: *Atom, elf_file: *Elf) void {
     if (@import("build_options").enable_logging) track_live_level.incr();
 
-    assert(atom.flags.visited);
+    assert(atom.visited);
     const file = atom.file(elf_file).?;
 
     for (atom.fdes(elf_file)) |fde| {
         for (fde.relocs(elf_file)[1..]) |rel| {
             const target_sym = elf_file.symbol(file.symbol(rel.r_sym()));
             const target_atom = target_sym.atom(elf_file) orelse continue;
-            target_atom.flags.alive = true;
+            target_atom.alive = true;
             gc_track_live_log.debug("{}marking live atom({d})", .{ track_live_level, target_atom.atom_index });
             if (markAtom(target_atom)) markLive(target_atom, elf_file);
         }
@@ -105,7 +105,7 @@ fn markLive(atom: *Atom, elf_file: *Elf) void {
             continue;
         }
         const target_atom = target_sym.atom(elf_file) orelse continue;
-        target_atom.flags.alive = true;
+        target_atom.alive = true;
         gc_track_live_log.debug("{}marking live atom({d})", .{ track_live_level, target_atom.atom_index });
         if (markAtom(target_atom)) markLive(target_atom, elf_file);
     }
@@ -123,8 +123,8 @@ fn prune(files: []const File.Index, elf_file: *Elf) void {
         const file = elf_file.file(index).?;
         for (file.atoms()) |atom_index| {
             const atom = file.atom(atom_index) orelse continue;
-            if (atom.flags.alive and !atom.flags.visited) {
-                atom.flags.alive = false;
+            if (atom.alive and !atom.visited) {
+                atom.alive = false;
                 atom.markFdesDead(elf_file);
             }
         }
@@ -137,7 +137,7 @@ pub fn dumpPrunedAtoms(elf_file: *Elf) !void {
         const file = elf_file.file(index).?;
         for (file.atoms()) |atom_index| {
             const atom = file.atom(atom_index) orelse continue;
-            if (!atom.flags.alive)
+            if (!atom.alive)
                 // TODO should we simply print to stderr?
                 try stderr.print("link: removing unused section '{s}' in file '{}'\n", .{
                     atom.name(elf_file),
src/link/Elf/Object.zig
@@ -84,7 +84,7 @@ pub fn parse(self: *Object, elf_file: *Elf) !void {
 
     for (self.shdrs.items, 0..) |shdr, i| {
         const atom_ptr = self.atom(self.atoms_indexes.items[i]) orelse continue;
-        if (!atom_ptr.flags.alive) continue;
+        if (!atom_ptr.alive) continue;
         if ((cpu_arch == .x86_64 and shdr.sh_type == elf.SHT_X86_64_UNWIND) or
             mem.eql(u8, atom_ptr.name(elf_file), ".eh_frame"))
         {
@@ -484,7 +484,6 @@ fn parseEhFrame(self: *Object, allocator: Allocator, handle: std.fs.File, shndx:
             if (atom_ptr.atom_index != next_fde.atom(elf_file).atom_index) break;
         }
         atom_ptr.addExtra(.{ .fde_start = start, .fde_count = i - start }, elf_file);
-        atom_ptr.flags.fde = true;
     }
 }
 
@@ -529,7 +528,7 @@ pub fn scanRelocs(self: *Object, elf_file: *Elf, undefs: anytype) !void {
     const gpa = comp.gpa;
     for (self.atoms_indexes.items) |atom_index| {
         const atom_ptr = self.atom(atom_index) orelse continue;
-        if (!atom_ptr.flags.alive) continue;
+        if (!atom_ptr.alive) continue;
         const shdr = atom_ptr.inputShdr(elf_file);
         if (shdr.sh_flags & elf.SHF_ALLOC == 0) continue;
         if (shdr.sh_type == elf.SHT_NOBITS) continue;
@@ -569,7 +568,7 @@ pub fn resolveSymbols(self: *Object, elf_file: *Elf) void {
         if (esym.st_shndx != elf.SHN_ABS and esym.st_shndx != elf.SHN_COMMON) {
             const atom_index = self.atoms_indexes.items[esym.st_shndx];
             const atom_ptr = self.atom(atom_index) orelse continue;
-            if (!atom_ptr.flags.alive) continue;
+            if (!atom_ptr.alive) continue;
         }
 
         const global = elf_file.symbol(index);
@@ -661,7 +660,7 @@ pub fn markEhFrameAtomsDead(self: *Object, elf_file: *Elf) void {
         const atom_ptr = self.atom(atom_index) orelse continue;
         const is_eh_frame = (cpu_arch == .x86_64 and atom_ptr.inputShdr(elf_file).sh_type == elf.SHT_X86_64_UNWIND) or
             mem.eql(u8, atom_ptr.name(elf_file), ".eh_frame");
-        if (atom_ptr.flags.alive and is_eh_frame) atom_ptr.flags.alive = false;
+        if (atom_ptr.alive and is_eh_frame) atom_ptr.alive = false;
     }
 }
 
@@ -681,7 +680,7 @@ pub fn checkDuplicates(self: *Object, dupes: anytype, elf_file: *Elf) error{OutO
         if (sym.st_shndx != elf.SHN_ABS) {
             const atom_index = self.atoms_indexes.items[sym.st_shndx];
             const atom_ptr = self.atom(atom_index) orelse continue;
-            if (!atom_ptr.flags.alive) continue;
+            if (!atom_ptr.alive) continue;
         }
 
         const gop = try dupes.getOrPut(index);
@@ -704,7 +703,7 @@ pub fn initMergeSections(self: *Object, elf_file: *Elf) !void {
 
         const atom_index = self.atoms_indexes.items[shndx];
         const atom_ptr = self.atom(atom_index) orelse continue;
-        if (!atom_ptr.flags.alive) continue;
+        if (!atom_ptr.alive) continue;
         if (atom_ptr.relocs(elf_file).len > 0) continue;
 
         const imsec_idx = try self.addInputMergeSection(gpa);
@@ -766,7 +765,7 @@ pub fn initMergeSections(self: *Object, elf_file: *Elf) !void {
             }
         }
 
-        atom_ptr.flags.alive = false;
+        atom_ptr.alive = false;
     }
 }
 
@@ -826,7 +825,7 @@ pub fn resolveMergeSubsections(self: *Object, elf_file: *Elf) !void {
 
     for (self.atoms_indexes.items) |atom_index| {
         const atom_ptr = self.atom(atom_index) orelse continue;
-        if (!atom_ptr.flags.alive) continue;
+        if (!atom_ptr.alive) continue;
         const extras = atom_ptr.extra(elf_file);
         const relocs = self.relocs.items[extras.rel_index..][0..extras.rel_count];
         for (relocs) |*rel| {
@@ -950,7 +949,7 @@ pub fn markComdatGroupsDead(self: *Object, elf_file: *Elf) void {
         for (cg.comdatGroupMembers(elf_file)) |shndx| {
             const atom_index = self.atoms_indexes.items[shndx];
             if (self.atom(atom_index)) |atom_ptr| {
-                atom_ptr.flags.alive = false;
+                atom_ptr.alive = false;
                 atom_ptr.markFdesDead(elf_file);
             }
         }
@@ -960,7 +959,7 @@ pub fn markComdatGroupsDead(self: *Object, elf_file: *Elf) void {
 pub fn initOutputSections(self: *Object, elf_file: *Elf) !void {
     for (self.atoms_indexes.items) |atom_index| {
         const atom_ptr = self.atom(atom_index) orelse continue;
-        if (!atom_ptr.flags.alive) continue;
+        if (!atom_ptr.alive) continue;
         const shdr = atom_ptr.inputShdr(elf_file);
         _ = try self.initOutputSection(elf_file, shdr);
     }
@@ -969,7 +968,7 @@ pub fn initOutputSections(self: *Object, elf_file: *Elf) !void {
 pub fn addAtomsToOutputSections(self: *Object, elf_file: *Elf) !void {
     for (self.atoms_indexes.items) |atom_index| {
         const atom_ptr = self.atom(atom_index) orelse continue;
-        if (!atom_ptr.flags.alive) continue;
+        if (!atom_ptr.alive) continue;
         const shdr = atom_ptr.inputShdr(elf_file);
         atom_ptr.output_section_index = self.initOutputSection(elf_file, shdr) catch unreachable;
 
@@ -988,7 +987,7 @@ pub fn addAtomsToOutputSections(self: *Object, elf_file: *Elf) !void {
             continue;
         }
         const atom_ptr = local.atom(elf_file) orelse continue;
-        if (!atom_ptr.flags.alive) continue;
+        if (!atom_ptr.alive) continue;
         local.output_section_index = atom_ptr.output_section_index;
     }
 
@@ -1001,7 +1000,7 @@ pub fn addAtomsToOutputSections(self: *Object, elf_file: *Elf) !void {
             continue;
         }
         const atom_ptr = global.atom(elf_file) orelse continue;
-        if (!atom_ptr.flags.alive) continue;
+        if (!atom_ptr.alive) continue;
         global.output_section_index = atom_ptr.output_section_index;
     }
 
@@ -1016,7 +1015,7 @@ pub fn addAtomsToOutputSections(self: *Object, elf_file: *Elf) !void {
 pub fn initRelaSections(self: *Object, elf_file: *Elf) !void {
     for (self.atoms_indexes.items) |atom_index| {
         const atom_ptr = self.atom(atom_index) orelse continue;
-        if (!atom_ptr.flags.alive) continue;
+        if (!atom_ptr.alive) continue;
         const shndx = atom_ptr.relocsShndx() orelse continue;
         const shdr = self.shdrs.items[shndx];
         const out_shndx = try self.initOutputSection(elf_file, shdr);
@@ -1030,7 +1029,7 @@ pub fn initRelaSections(self: *Object, elf_file: *Elf) !void {
 pub fn addAtomsToRelaSections(self: *Object, elf_file: *Elf) !void {
     for (self.atoms_indexes.items) |atom_index| {
         const atom_ptr = self.atom(atom_index) orelse continue;
-        if (!atom_ptr.flags.alive) continue;
+        if (!atom_ptr.alive) continue;
         const shndx = blk: {
             const shndx = atom_ptr.relocsShndx() orelse continue;
             const shdr = self.shdrs.items[shndx];
@@ -1100,7 +1099,7 @@ pub fn updateSymtabSize(self: *Object, elf_file: *Elf) !void {
     const isAlive = struct {
         fn isAlive(sym: *const Symbol, ctx: *Elf) bool {
             if (sym.mergeSubsection(ctx)) |msub| return msub.alive;
-            if (sym.atom(ctx)) |atom_ptr| return atom_ptr.flags.alive;
+            if (sym.atom(ctx)) |atom_ptr| return atom_ptr.alive;
             return true;
         }
     }.isAlive;
src/link/Elf/relocatable.zig
@@ -340,7 +340,7 @@ fn updateSectionSizes(elf_file: *Elf) !void {
         const shdr = &elf_file.shdrs.items[shndx];
         for (atom_list.items) |ref| {
             const atom_ptr = elf_file.atom(ref) orelse continue;
-            if (!atom_ptr.flags.alive) continue;
+            if (!atom_ptr.alive) continue;
             const offset = atom_ptr.alignment.forward(shdr.sh_size);
             const padding = offset - shdr.sh_size;
             atom_ptr.value = @intCast(offset);
@@ -353,7 +353,7 @@ fn updateSectionSizes(elf_file: *Elf) !void {
         const shdr = &elf_file.shdrs.items[sec.shndx];
         for (sec.atom_list.items) |ref| {
             const atom_ptr = elf_file.atom(ref) orelse continue;
-            if (!atom_ptr.flags.alive) continue;
+            if (!atom_ptr.alive) continue;
             const relocs = atom_ptr.relocs(elf_file);
             shdr.sh_size += shdr.sh_entsize * relocs.len;
         }
@@ -447,7 +447,7 @@ fn writeAtoms(elf_file: *Elf) !void {
 
         for (atom_list.items) |ref| {
             const atom_ptr = elf_file.atom(ref).?;
-            assert(atom_ptr.flags.alive);
+            assert(atom_ptr.alive);
 
             const offset = math.cast(usize, atom_ptr.value - @as(i64, @intCast(shdr.sh_addr - base_offset))) orelse
                 return error.Overflow;
@@ -489,7 +489,7 @@ fn writeSyntheticSections(elf_file: *Elf) !void {
 
         for (sec.atom_list.items) |ref| {
             const atom_ptr = elf_file.atom(ref) orelse continue;
-            if (!atom_ptr.flags.alive) continue;
+            if (!atom_ptr.alive) continue;
             try atom_ptr.writeRelocs(elf_file, &relocs);
         }
         assert(relocs.items.len == num_relocs);
src/link/Elf/Symbol.zig
@@ -116,7 +116,7 @@ pub fn address(symbol: Symbol, opts: struct { plt: bool = true }, elf_file: *Elf
         return symbol.pltAddress(elf_file);
     }
     if (symbol.atom(elf_file)) |atom_ptr| {
-        if (!atom_ptr.flags.alive) {
+        if (!atom_ptr.alive) {
             if (mem.eql(u8, atom_ptr.name(elf_file), ".eh_frame")) {
                 const sym_name = symbol.name(elf_file);
                 const sh_addr, const sh_size = blk: {
src/link/Elf/thunks.zig
@@ -14,13 +14,13 @@ pub fn createThunks(shndx: u32, elf_file: *Elf) !void {
     while (i < atoms.len) {
         const start = i;
         const start_atom = elf_file.atom(atoms[start]).?;
-        assert(start_atom.flags.alive);
+        assert(start_atom.alive);
         start_atom.value = try advance(shdr, start_atom.size, start_atom.alignment);
         i += 1;
 
         while (i < atoms.len) : (i += 1) {
             const atom = elf_file.atom(atoms[i]).?;
-            assert(atom.flags.alive);
+            assert(atom.alive);
             if (@as(i64, @intCast(atom.alignment.forward(shdr.sh_size))) - start_atom.value >= max_distance)
                 break;
             atom.value = try advance(shdr, atom.size, atom.alignment);
@@ -51,7 +51,6 @@ pub fn createThunks(shndx: u32, elf_file: *Elf) !void {
                 try thunk.symbols.put(gpa, target, {});
             }
             atom.addExtra(.{ .thunk = thunk_index }, elf_file);
-            atom.flags.thunk = true;
         }
 
         thunk.value = try advance(shdr, thunk.size(elf_file), Atom.Alignment.fromNonzeroByteUnits(2));
src/link/Elf/ZigObject.zig
@@ -331,7 +331,7 @@ pub fn resolveSymbols(self: *ZigObject, elf_file: *Elf) void {
         if (esym.st_shndx != elf.SHN_ABS and esym.st_shndx != elf.SHN_COMMON) {
             assert(esym.st_shndx == SHN_ATOM);
             const atom_ptr = self.atom(shndx) orelse continue;
-            if (!atom_ptr.flags.alive) continue;
+            if (!atom_ptr.alive) continue;
         }
 
         const global = elf_file.symbol(index);
@@ -407,7 +407,7 @@ pub fn scanRelocs(self: *ZigObject, elf_file: *Elf, undefs: anytype) !void {
     const gpa = elf_file.base.comp.gpa;
     for (self.atoms_indexes.items) |atom_index| {
         const atom_ptr = self.atom(atom_index) orelse continue;
-        if (!atom_ptr.flags.alive) continue;
+        if (!atom_ptr.alive) continue;
         const shdr = atom_ptr.inputShdr(elf_file);
         if (shdr.sh_type == elf.SHT_NOBITS) continue;
         if (atom_ptr.scanRelocsRequiresCode(elf_file)) {
@@ -451,7 +451,7 @@ pub fn checkDuplicates(self: *ZigObject, dupes: anytype, elf_file: *Elf) error{O
 
         if (esym.st_shndx == SHN_ATOM) {
             const atom_ptr = self.atom(shndx) orelse continue;
-            if (!atom_ptr.flags.alive) continue;
+            if (!atom_ptr.alive) continue;
         }
 
         const gop = try dupes.getOrPut(index);
@@ -519,7 +519,7 @@ pub fn writeAr(self: ZigObject, writer: anytype) !void {
 pub fn addAtomsToRelaSections(self: *ZigObject, elf_file: *Elf) !void {
     for (self.atoms_indexes.items) |atom_index| {
         const atom_ptr = self.atom(atom_index) orelse continue;
-        if (!atom_ptr.flags.alive) continue;
+        if (!atom_ptr.alive) continue;
         const rela_shndx = atom_ptr.relocsShndx() orelse continue;
         // TODO this check will become obsolete when we rework our relocs mechanism at the ZigObject level
         if (self.relocs.items[rela_shndx].items.len == 0) continue;
@@ -560,7 +560,7 @@ pub fn globals(self: ZigObject) []const Symbol.Index {
 pub fn updateSymtabSize(self: *ZigObject, elf_file: *Elf) !void {
     for (self.locals()) |local_index| {
         const local = elf_file.symbol(local_index);
-        if (local.atom(elf_file)) |atom_ptr| if (!atom_ptr.flags.alive) continue;
+        if (local.atom(elf_file)) |atom_ptr| if (!atom_ptr.alive) continue;
         const esym = local.elfSym(elf_file);
         switch (esym.st_type()) {
             elf.STT_SECTION, elf.STT_NOTYPE => continue,
@@ -576,7 +576,7 @@ pub fn updateSymtabSize(self: *ZigObject, elf_file: *Elf) !void {
         const global = elf_file.symbol(global_index);
         const file_ptr = global.file(elf_file) orelse continue;
         if (file_ptr.index() != self.index) continue;
-        if (global.atom(elf_file)) |atom_ptr| if (!atom_ptr.flags.alive) continue;
+        if (global.atom(elf_file)) |atom_ptr| if (!atom_ptr.alive) continue;
         global.flags.output_symtab = true;
         if (global.isLocal(elf_file)) {
             try global.addExtra(.{ .symtab = self.output_symtab_ctx.nlocals }, elf_file);
@@ -922,7 +922,7 @@ fn updateDeclCode(
     atom_ptr.output_section_index = shdr_index;
 
     sym.name_offset = try self.strtab.insert(gpa, decl.fqn.toSlice(ip));
-    atom_ptr.flags.alive = true;
+    atom_ptr.alive = true;
     atom_ptr.name_offset = sym.name_offset;
     esym.st_name = sym.name_offset;
     esym.st_info |= stt_bits;
@@ -1022,7 +1022,7 @@ fn updateTlv(
     atom_ptr.output_section_index = shndx;
 
     sym.name_offset = try self.strtab.insert(gpa, decl.fqn.toSlice(ip));
-    atom_ptr.flags.alive = true;
+    atom_ptr.alive = true;
     atom_ptr.name_offset = sym.name_offset;
     esym.st_value = 0;
     esym.st_name = sym.name_offset;
@@ -1246,7 +1246,7 @@ fn updateLazySymbol(
     local_esym.st_info |= elf.STT_OBJECT;
     local_esym.st_size = code.len;
     const atom_ptr = local_sym.atom(elf_file).?;
-    atom_ptr.flags.alive = true;
+    atom_ptr.alive = true;
     atom_ptr.name_offset = name_str_index;
     atom_ptr.alignment = required_alignment;
     atom_ptr.size = code.len;
@@ -1354,7 +1354,7 @@ fn lowerConst(
     local_esym.st_info |= elf.STT_OBJECT;
     local_esym.st_size = code.len;
     const atom_ptr = local_sym.atom(elf_file).?;
-    atom_ptr.flags.alive = true;
+    atom_ptr.alive = true;
     atom_ptr.name_offset = name_str_index;
     atom_ptr.alignment = required_alignment;
     atom_ptr.size = code.len;
src/link/Elf.zig
@@ -1371,7 +1371,7 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod
         var has_reloc_errors = false;
         for (zo.atoms_indexes.items) |atom_index| {
             const atom_ptr = zo.atom(atom_index) orelse continue;
-            if (!atom_ptr.flags.alive) continue;
+            if (!atom_ptr.alive) continue;
             const out_shndx = atom_ptr.outputShndx() orelse continue;
             const shdr = &self.shdrs.items[out_shndx];
             if (shdr.sh_type == elf.SHT_NOBITS) continue;
@@ -4130,7 +4130,7 @@ fn resetShdrIndexes(self: *Elf, backlinks: []const u32) !void {
         for (zo.globals()) |global_index| {
             const global = self.symbol(global_index);
             const atom_ptr = global.atom(self) orelse continue;
-            if (!atom_ptr.flags.alive) continue;
+            if (!atom_ptr.alive) continue;
             // TODO claim unresolved for objects
             if (global.file(self).?.index() != zo.index) continue;
             const out_shndx = global.outputShndx() orelse continue;
@@ -4157,7 +4157,7 @@ fn updateSectionSizes(self: *Elf) !void {
         if (self.requiresThunks() and shdr.sh_flags & elf.SHF_EXECINSTR != 0) continue;
         for (atom_list.items) |ref| {
             const atom_ptr = self.atom(ref) orelse continue;
-            if (!atom_ptr.flags.alive) continue;
+            if (!atom_ptr.alive) continue;
             const offset = atom_ptr.alignment.forward(shdr.sh_size);
             const padding = offset - shdr.sh_size;
             atom_ptr.value = @intCast(offset);
@@ -4641,7 +4641,7 @@ fn writeAtoms(self: *Elf) !void {
 
         for (atom_list.items) |ref| {
             const atom_ptr = self.atom(ref).?;
-            assert(atom_ptr.flags.alive);
+            assert(atom_ptr.alive);
 
             const offset = math.cast(usize, atom_ptr.value - @as(i64, @intCast(base_offset))) orelse
                 return error.Overflow;