authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-11-07 14:29:44+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-11-07 14:29:44+01:00
loge22b3595c1af232372ebf3c70922e86e6f9e9076
tree72f991c9f43f53d3d0fa0e01d48696e642cba01c
parentc7ed7c4690dfa297c15b94fe7acba77c52d89e68

elf: update .rela section sizes


1 files changed, 14 insertions(+), 3 deletions(-)

src/link/Elf/Object.zig+14-3
......@@ -664,13 +664,24 @@ pub fn initRelaSections(self: Object, elf_file: *Elf) !void {
664664 if (!atom.flags.alive) continue;
665665 const shndx = atom.relocsShndx() orelse continue;
666666 const shdr = self.shdrs.items[shndx];
667 _ = try self.initOutputSection(elf_file, shdr);
667 const out_shndx = try self.initOutputSection(elf_file, shdr);
668 const out_shdr = &elf_file.shdrs.items[out_shndx];
669 out_shdr.sh_addralign = @alignOf(elf.Elf64_Rela);
670 out_shdr.sh_entsize = @sizeOf(elf.Elf64_Rela);
668671 }
669672}
670673
671674pub fn updateRelaSectionsSizes(self: Object, elf_file: *Elf) void {
672 _ = self;
673 _ = elf_file;
675 for (self.atoms.items) |atom_index| {
676 const atom = elf_file.atom(atom_index) orelse continue;
677 if (!atom.flags.alive) continue;
678 const shndx = atom.relocsShndx() orelse continue;
679 const shdr = self.shdrs.items[shndx];
680 const out_shndx = self.initOutputSection(elf_file, shdr) catch unreachable;
681 const out_shdr = &elf_file.shdrs.items[out_shndx];
682 const relocs = atom.relocs(elf_file);
683 out_shdr.sh_size += out_shdr.sh_entsize * relocs.len;
684 }
674685}
675686
676687pub fn writeRelaSections(self: Object, elf_file: *Elf) !void {