authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-09-13 21:51:13+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-09-13 21:51:43+02:00
logd4c1e85a13ba83a7a36245bd988adbc4cf894f9c
tree54a27c013e0b52e786c5834a709d3e3875877b37
parenta9f1b994bd143b24aad69b79b10fca43388b05ed

elf: skip writing non-alloc and zerofill atoms


1 files changed, 4 insertions(+), 0 deletions(-)

src/link/Elf.zig+4
...@@ -1690,7 +1690,11 @@ fn writeObjects(self: *Elf) !void {...@@ -1690,7 +1690,11 @@ fn writeObjects(self: *Elf) !void {
1690 if (!atom_ptr.alive) continue;1690 if (!atom_ptr.alive) continue;
16911691
1692 const shdr = &self.shdrs.items[atom_ptr.output_section_index];1692 const shdr = &self.shdrs.items[atom_ptr.output_section_index];
1693 if (shdr.sh_type == elf.SHT_NOBITS) continue;
1694 if (shdr.sh_flags & elf.SHF_ALLOC == 0) continue; // TODO we don't yet know how to handle non-alloc sections
1695
1693 const file_offset = shdr.sh_offset + atom_ptr.value - shdr.sh_addr;1696 const file_offset = shdr.sh_offset + atom_ptr.value - shdr.sh_addr;
1697 log.debug("writing atom({d}) at 0x{x}", .{ atom_ptr.atom_index, file_offset });
1694 const code = try atom_ptr.codeInObjectUncompressAlloc(self);1698 const code = try atom_ptr.codeInObjectUncompressAlloc(self);
1695 defer gpa.free(code);1699 defer gpa.free(code);
16961700