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