Commit 82cf762b02

Jakub Konka <kubkon@jakubkonka.com>
2024-09-24 11:09:17
elf: reset (merge) sections sizes before updating
1 parent db3db11
Changed files (2)
src/link/Elf/AtomList.zig
@@ -19,6 +19,9 @@ pub fn offset(list: AtomList, elf_file: *Elf) u64 {
 }
 
 pub fn updateSize(list: *AtomList, elf_file: *Elf) void {
+    // TODO perhaps a 'stale' flag would be better here?
+    list.size = 0;
+    list.alignment = .@"1";
     for (list.atoms.items) |ref| {
         const atom_ptr = elf_file.atom(ref).?;
         assert(atom_ptr.alive);
src/link/Elf/merge_section.zig
@@ -95,6 +95,10 @@ pub const MergeSection = struct {
     }
 
     pub fn updateSize(msec: *MergeSection) void {
+        // TODO a 'stale' flag would be better here perhaps?
+        msec.size = 0;
+        msec.alignment = .@"1";
+        msec.entsize = 0;
         for (msec.finalized_subsections.items) |msub_index| {
             const msub = msec.mergeSubsection(msub_index);
             assert(msub.alive);