diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 41fe3de0e9174bf7c55800aa05822f7cf86cbbab..2d6bade67de7f33a3365d5b23ec07144c805070d 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -3367,58 +3367,6 @@ fn resetShdrIndexes(self: *Elf, backlinks: []const u32) void { } } - if (self.symtab_section_index) |index| { - const shdr = &self.sections.items(.shdr)[index]; - shdr.sh_link = self.strtab_section_index.?; - } - - if (self.dynamic_section_index) |index| { - const shdr = &self.sections.items(.shdr)[index]; - shdr.sh_link = self.dynstrtab_section_index.?; - } - - if (self.dynsymtab_section_index) |index| { - const shdr = &self.sections.items(.shdr)[index]; - shdr.sh_link = self.dynstrtab_section_index.?; - } - - if (self.hash_section_index) |index| { - const shdr = &self.sections.items(.shdr)[index]; - shdr.sh_link = self.dynsymtab_section_index.?; - } - - if (self.gnu_hash_section_index) |index| { - const shdr = &self.sections.items(.shdr)[index]; - shdr.sh_link = self.dynsymtab_section_index.?; - } - - if (self.versym_section_index) |index| { - const shdr = &self.sections.items(.shdr)[index]; - shdr.sh_link = self.dynsymtab_section_index.?; - } - - if (self.verneed_section_index) |index| { - const shdr = &self.sections.items(.shdr)[index]; - shdr.sh_link = self.dynstrtab_section_index.?; - } - - if (self.rela_dyn_section_index) |index| { - const shdr = &self.sections.items(.shdr)[index]; - shdr.sh_link = self.dynsymtab_section_index orelse 0; - } - - if (self.rela_plt_section_index) |index| { - const shdr = &self.sections.items(.shdr)[index]; - shdr.sh_link = self.dynsymtab_section_index.?; - shdr.sh_info = self.plt_section_index.?; - } - - if (self.eh_frame_rela_section_index) |index| { - const shdr = &self.sections.items(.shdr)[index]; - shdr.sh_link = self.symtab_section_index.?; - shdr.sh_info = self.eh_frame_section_index.?; - } - for (self.merge_sections.items) |*msec| { msec.output_section_index = backlinks[msec.output_section_index]; } @@ -3440,6 +3388,58 @@ fn resetShdrIndexes(self: *Elf, backlinks: []const u32) void { for (self.comdat_group_sections.items) |*cg| { cg.shndx = backlinks[cg.shndx]; } + + if (self.symtab_section_index) |index| { + const shdr = &self.sections.items(.shdr)[index]; + shdr.sh_link = self.strtab_section_index.?; + } + + if (self.dynamic_section_index) |index| { + const shdr = &self.sections.items(.shdr)[index]; + shdr.sh_link = self.dynstrtab_section_index.?; + } + + if (self.dynsymtab_section_index) |index| { + const shdr = &self.sections.items(.shdr)[index]; + shdr.sh_link = self.dynstrtab_section_index.?; + } + + if (self.hash_section_index) |index| { + const shdr = &self.sections.items(.shdr)[index]; + shdr.sh_link = self.dynsymtab_section_index.?; + } + + if (self.gnu_hash_section_index) |index| { + const shdr = &self.sections.items(.shdr)[index]; + shdr.sh_link = self.dynsymtab_section_index.?; + } + + if (self.versym_section_index) |index| { + const shdr = &self.sections.items(.shdr)[index]; + shdr.sh_link = self.dynsymtab_section_index.?; + } + + if (self.verneed_section_index) |index| { + const shdr = &self.sections.items(.shdr)[index]; + shdr.sh_link = self.dynstrtab_section_index.?; + } + + if (self.rela_dyn_section_index) |index| { + const shdr = &self.sections.items(.shdr)[index]; + shdr.sh_link = self.dynsymtab_section_index orelse 0; + } + + if (self.rela_plt_section_index) |index| { + const shdr = &self.sections.items(.shdr)[index]; + shdr.sh_link = self.dynsymtab_section_index.?; + shdr.sh_info = self.plt_section_index.?; + } + + if (self.eh_frame_rela_section_index) |index| { + const shdr = &self.sections.items(.shdr)[index]; + shdr.sh_link = self.symtab_section_index.?; + shdr.sh_info = self.eh_frame_section_index.?; + } } fn updateSectionSizes(self: *Elf) !void {