elf: create link between .rela and output section

This commit is contained in:
Jakub Konka 2023-11-07 14:42:27 +01:00
parent e22b3595c1
commit 0211d6bf4f
2 changed files with 6 additions and 9 deletions

View File

@ -3904,15 +3904,11 @@ fn sortShdrs(self: *Elf) !void {
shdr.sh_info = self.plt_section_index.?;
}
for (&[_]?u16{
self.zig_text_rela_section_index,
self.zig_data_rel_ro_rela_section_index,
self.zig_data_rela_section_index,
}) |maybe_index| {
const index = maybe_index orelse continue;
const shdr = &self.shdrs.items[index];
shdr.sh_link = self.symtab_section_index.?;
shdr.sh_info = backlinks[shdr.sh_info];
for (self.shdrs.items) |*shdr| {
if (shdr.sh_type == elf.SHT_RELA and shdr.sh_flags & elf.SHF_INFO_LINK != 0) {
shdr.sh_link = self.symtab_section_index.?;
shdr.sh_info = backlinks[shdr.sh_info];
}
}
{

View File

@ -668,6 +668,7 @@ pub fn initRelaSections(self: Object, elf_file: *Elf) !void {
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);
out_shdr.sh_info = self.initOutputSection(elf_file, atom.inputShdr(elf_file)) catch unreachable;
}
}