elf: reset (merge) sections sizes before updating

This commit is contained in:
Jakub Konka 2024-09-24 11:09:17 +02:00
parent db3db1150e
commit 82cf762b02
2 changed files with 7 additions and 0 deletions

View File

@ -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);

View File

@ -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);