diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-11-07 14:29:44 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-11-07 14:29:44 +0100 |
| commit | e22b3595c1af232372ebf3c70922e86e6f9e9076 (patch) | |
| tree | 72f991c9f43f53d3d0fa0e01d48696e642cba01c /src/link/Elf/Object.zig | |
| parent | c7ed7c4690dfa297c15b94fe7acba77c52d89e68 (diff) | |
| download | zig-e22b3595c1af232372ebf3c70922e86e6f9e9076.tar.gz zig-e22b3595c1af232372ebf3c70922e86e6f9e9076.zip | |
elf: update .rela section sizes
Diffstat (limited to 'src/link/Elf/Object.zig')
| -rw-r--r-- | src/link/Elf/Object.zig | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/link/Elf/Object.zig b/src/link/Elf/Object.zig index 73bd3a7fb3..a2a551ed6a 100644 --- a/src/link/Elf/Object.zig +++ b/src/link/Elf/Object.zig @@ -664,13 +664,24 @@ pub fn initRelaSections(self: Object, elf_file: *Elf) !void { if (!atom.flags.alive) continue; const shndx = atom.relocsShndx() orelse continue; const shdr = self.shdrs.items[shndx]; - _ = try self.initOutputSection(elf_file, shdr); + const out_shndx = try self.initOutputSection(elf_file, shdr); + const out_shdr = &elf_file.shdrs.items[out_shndx]; + out_shdr.sh_addralign = @alignOf(elf.Elf64_Rela); + out_shdr.sh_entsize = @sizeOf(elf.Elf64_Rela); } } pub fn updateRelaSectionsSizes(self: Object, elf_file: *Elf) void { - _ = self; - _ = elf_file; + for (self.atoms.items) |atom_index| { + const atom = elf_file.atom(atom_index) orelse continue; + if (!atom.flags.alive) continue; + const shndx = atom.relocsShndx() orelse continue; + const shdr = self.shdrs.items[shndx]; + const out_shndx = self.initOutputSection(elf_file, shdr) catch unreachable; + const out_shdr = &elf_file.shdrs.items[out_shndx]; + const relocs = atom.relocs(elf_file); + out_shdr.sh_size += out_shdr.sh_entsize * relocs.len; + } } pub fn writeRelaSections(self: Object, elf_file: *Elf) !void { |
