Skip to content

Commit

Permalink
Feat: use accumulate address on sections with SHT_ALLOC
Browse files Browse the repository at this point in the history
  • Loading branch information
aokblast committed Feb 3, 2024
1 parent 2535137 commit 8c99dd0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion elf/passes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2457,6 +2457,8 @@ static i64 set_file_offsets(Context<E> &ctx) {
}

if (first.shdr.sh_type == SHT_NOBITS) {
fileoff = align_to(fileoff, first.shdr.sh_addralign);
first.shdr.sh_offset = fileoff;
i++;
continue;
}
Expand Down Expand Up @@ -2497,8 +2499,11 @@ static i64 set_file_offsets(Context<E> &ctx) {

while (i < chunks.size() &&
(chunks[i]->shdr.sh_flags & SHF_ALLOC) &&
chunks[i]->shdr.sh_type == SHT_NOBITS)
chunks[i]->shdr.sh_type == SHT_NOBITS) {
fileoff = align_to(fileoff, chunks[i]->shdr.sh_addralign);
chunks[i]->shdr.sh_offset = fileoff;
i++;
}
}

return fileoff;
Expand Down

0 comments on commit 8c99dd0

Please sign in to comment.