Commit d4c1e85a13

Jakub Konka <kubkon@jakubkonka.com>
2023-09-13 21:51:13
elf: skip writing non-alloc and zerofill atoms
1 parent a9f1b99
Changed files (1)
src
link
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);