commit d4c1e85a13ba83a7a36245bd988adbc4cf894f9c (tree)
parent a9f1b994bd143b24aad69b79b10fca43388b05ed
Author: Jakub Konka <kubkon@jakubkonka.com>
Date: Wed, 13 Sep 2023 21:51:13 +0200
elf: skip writing non-alloc and zerofill atoms
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
@@ -1690,7 +1690,11 @@ fn writeObjects(self: *Elf) !void {
if (!atom_ptr.alive) continue;
const shdr = &self.shdrs.items[atom_ptr.output_section_index];
+ if (shdr.sh_type == elf.SHT_NOBITS) continue;
+ if (shdr.sh_flags & elf.SHF_ALLOC == 0) continue; // TODO we don't yet know how to handle non-alloc sections
+
const file_offset = shdr.sh_offset + atom_ptr.value - shdr.sh_addr;
+ log.debug("writing atom({d}) at 0x{x}", .{ atom_ptr.atom_index, file_offset });
const code = try atom_ptr.codeInObjectUncompressAlloc(self);
defer gpa.free(code);