| ... | ... | @@ -1319,9 +1319,10 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node |
| 1319 | 1319 | for (zig_module.atoms.keys()) |atom_index| { |
| 1320 | 1320 | const atom_ptr = self.atom(atom_index).?; |
| 1321 | 1321 | if (!atom_ptr.flags.alive) continue; |
| 1322 | const shdr = &self.shdrs.items[atom_ptr.outputShndx().?]; |
| 1323 | if (shdr.sh_type == elf.SHT_NOBITS) continue; |
| 1322 | 1324 | const code = try zig_module.codeAlloc(self, atom_index); |
| 1323 | 1325 | defer gpa.free(code); |
| 1324 | | const shdr = &self.shdrs.items[atom_ptr.outputShndx().?]; |
| 1325 | 1326 | const file_offset = shdr.sh_offset + atom_ptr.value - shdr.sh_addr; |
| 1326 | 1327 | try atom_ptr.resolveRelocs(self, code); |
| 1327 | 1328 | try self.base.file.?.pwriteAll(code, file_offset); |
| ... | ... | @@ -2862,10 +2863,6 @@ fn updateDeclCode( |
| 2862 | 2863 | try self.got.writeEntry(self, gop.index); |
| 2863 | 2864 | } |
| 2864 | 2865 | |
| 2865 | | const phdr_index = self.phdr_to_shdr_table.get(shdr_index).?; |
| 2866 | | const section_offset = sym.value - self.phdrs.items[phdr_index].p_vaddr; |
| 2867 | | const file_offset = self.shdrs.items[shdr_index].sh_offset + section_offset; |
| 2868 | | |
| 2869 | 2866 | if (self.base.child_pid) |pid| { |
| 2870 | 2867 | switch (builtin.os.tag) { |
| 2871 | 2868 | .linux => { |
| ... | ... | @@ -2887,7 +2884,13 @@ fn updateDeclCode( |
| 2887 | 2884 | } |
| 2888 | 2885 | } |
| 2889 | 2886 | |
| 2890 | | try self.base.file.?.pwriteAll(code, file_offset); |
| 2887 | const shdr = self.shdrs.items[shdr_index]; |
| 2888 | if (shdr.sh_type != elf.SHT_NOBITS) { |
| 2889 | const phdr_index = self.phdr_to_shdr_table.get(shdr_index).?; |
| 2890 | const section_offset = sym.value - self.phdrs.items[phdr_index].p_vaddr; |
| 2891 | const file_offset = shdr.sh_offset + section_offset; |
| 2892 | try self.base.file.?.pwriteAll(code, file_offset); |
| 2893 | } |
| 2891 | 2894 | } |
| 2892 | 2895 | |
| 2893 | 2896 | pub fn updateFunc(self: *Elf, mod: *Module, func_index: InternPool.Index, air: Air, liveness: Liveness) !void { |