| ... | ... | @@ -987,6 +987,9 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod |
| 987 | 987 | for (self.objects.items) |index| { |
| 988 | 988 | self.file(index).?.object.dirty = false; |
| 989 | 989 | } |
| 990 | // TODO: would state tracking be more appropriate here? perhaps even custom relocation type? |
| 991 | self.rela_dyn.clearRetainingCapacity(); |
| 992 | self.rela_plt.clearRetainingCapacity(); |
| 990 | 993 | |
| 991 | 994 | if (self.zigObjectPtr()) |zo| { |
| 992 | 995 | var has_reloc_errors = false; |
| ... | ... | @@ -1017,6 +1020,7 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod |
| 1017 | 1020 | try self.writeShdrTable(); |
| 1018 | 1021 | try self.writeAtoms(); |
| 1019 | 1022 | try self.writeMergeSections(); |
| 1023 | |
| 1020 | 1024 | self.writeSyntheticSections() catch |err| switch (err) { |
| 1021 | 1025 | error.RelocFailure => return error.FlushFailure, |
| 1022 | 1026 | error.UnsupportedCpuArch => { |
| ... | ... | @@ -4236,8 +4240,6 @@ fn writeSyntheticSections(self: *Elf) !void { |
| 4236 | 4240 | } |
| 4237 | 4241 | |
| 4238 | 4242 | if (self.rela_dyn_section_index) |shndx| { |
| 4239 | | // TODO: would state tracking be more appropriate here? perhaps even custom relocation type? |
| 4240 | | self.rela_dyn.clearRetainingCapacity(); |
| 4241 | 4243 | const shdr = slice.items(.shdr)[shndx]; |
| 4242 | 4244 | try self.got.addRela(self); |
| 4243 | 4245 | try self.copy_rel.addRela(self); |
| ... | ... | @@ -4270,8 +4272,6 @@ fn writeSyntheticSections(self: *Elf) !void { |
| 4270 | 4272 | } |
| 4271 | 4273 | |
| 4272 | 4274 | if (self.rela_plt_section_index) |shndx| { |
| 4273 | | // TODO: would state tracking be more appropriate here? perhaps even custom relocation type? |
| 4274 | | self.rela_plt.clearRetainingCapacity(); |
| 4275 | 4275 | const shdr = slice.items(.shdr)[shndx]; |
| 4276 | 4276 | try self.plt.addRela(self); |
| 4277 | 4277 | try self.base.file.?.pwriteAll(mem.sliceAsBytes(self.rela_plt.items), shdr.sh_offset); |