authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-08-23 10:41:21+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-08-25 10:20:15+02:00
log1af0f4cd00f7a6b9150346449d2e7dc14798bada
tree78928c0e55ca8a34a3c058a6d99e14ef690fe5dc
parent7173ea1a152e0b546f158cbfec017d81b3665047

elf: fix setting sh_info and sh_link for manually managed rela sections


1 files changed, 22 insertions(+), 22 deletions(-)

src/link/Elf.zig+22-22
...@@ -3367,6 +3367,28 @@ fn resetShdrIndexes(self: *Elf, backlinks: []const u32) void {...@@ -3367,6 +3367,28 @@ fn resetShdrIndexes(self: *Elf, backlinks: []const u32) void {
3367 }3367 }
3368 }3368 }
33693369
3370 for (self.merge_sections.items) |*msec| {
3371 msec.output_section_index = backlinks[msec.output_section_index];
3372 }
3373
3374 for (self.sections.items(.shdr)) |*shdr| {
3375 if (shdr.sh_type != elf.SHT_RELA) continue;
3376 shdr.sh_link = backlinks[shdr.sh_link];
3377 shdr.sh_info = backlinks[shdr.sh_info];
3378 }
3379
3380 if (self.zigObjectPtr()) |zo| {
3381 for (zo.atoms_indexes.items) |atom_index| {
3382 const atom_ptr = zo.atom(atom_index) orelse continue;
3383 atom_ptr.output_section_index = backlinks[atom_ptr.output_section_index];
3384 }
3385 if (zo.dwarf) |*dwarf| dwarf.reloadSectionMetadata();
3386 }
3387
3388 for (self.comdat_group_sections.items) |*cg| {
3389 cg.shndx = backlinks[cg.shndx];
3390 }
3391
3370 if (self.symtab_section_index) |index| {3392 if (self.symtab_section_index) |index| {
3371 const shdr = &self.sections.items(.shdr)[index];3393 const shdr = &self.sections.items(.shdr)[index];
3372 shdr.sh_link = self.strtab_section_index.?;3394 shdr.sh_link = self.strtab_section_index.?;
...@@ -3418,28 +3440,6 @@ fn resetShdrIndexes(self: *Elf, backlinks: []const u32) void {...@@ -3418,28 +3440,6 @@ fn resetShdrIndexes(self: *Elf, backlinks: []const u32) void {
3418 shdr.sh_link = self.symtab_section_index.?;3440 shdr.sh_link = self.symtab_section_index.?;
3419 shdr.sh_info = self.eh_frame_section_index.?;3441 shdr.sh_info = self.eh_frame_section_index.?;
3420 }3442 }
3421
3422 for (self.merge_sections.items) |*msec| {
3423 msec.output_section_index = backlinks[msec.output_section_index];
3424 }
3425
3426 for (self.sections.items(.shdr)) |*shdr| {
3427 if (shdr.sh_type != elf.SHT_RELA) continue;
3428 shdr.sh_link = backlinks[shdr.sh_link];
3429 shdr.sh_info = backlinks[shdr.sh_info];
3430 }
3431
3432 if (self.zigObjectPtr()) |zo| {
3433 for (zo.atoms_indexes.items) |atom_index| {
3434 const atom_ptr = zo.atom(atom_index) orelse continue;
3435 atom_ptr.output_section_index = backlinks[atom_ptr.output_section_index];
3436 }
3437 if (zo.dwarf) |*dwarf| dwarf.reloadSectionMetadata();
3438 }
3439
3440 for (self.comdat_group_sections.items) |*cg| {
3441 cg.shndx = backlinks[cg.shndx];
3442 }
3443}3443}
34443444
3445fn updateSectionSizes(self: *Elf) !void {3445fn updateSectionSizes(self: *Elf) !void {