| author | |
| committer | |
| log | 20240e9cd5a796b63bc2571aa70bb77144e8860c |
| tree | 3e10a5ab15fa4228bb724d1da584ce70b96ecc29 |
| parent | 1af0f4cd00f7a6b9150346449d2e7dc14798bada |
4 files changed, 15 insertions(+), 8 deletions(-)
src/link/Elf.zig+4-1| ... | ... | @@ -3373,7 +3373,10 @@ fn resetShdrIndexes(self: *Elf, backlinks: []const u32) void { |
| 3373 | 3373 | |
| 3374 | 3374 | for (self.sections.items(.shdr)) |*shdr| { |
| 3375 | 3375 | if (shdr.sh_type != elf.SHT_RELA) continue; |
| 3376 | shdr.sh_link = backlinks[shdr.sh_link]; | |
| 3376 | // FIXME:JK we should spin up .symtab potentially earlier, or set all non-dynamic RELA sections | |
| 3377 | // to point at symtab | |
| 3378 | // shdr.sh_link = backlinks[shdr.sh_link]; | |
| 3379 | shdr.sh_link = self.symtab_section_index.?; | |
| 3377 | 3380 | shdr.sh_info = backlinks[shdr.sh_info]; |
| 3378 | 3381 | } |
| 3379 | 3382 |
src/link/Elf/Object.zig+4-1| ... | ... | @@ -1018,7 +1018,7 @@ pub fn initRelaSections(self: *Object, elf_file: *Elf) !void { |
| 1018 | 1018 | } |
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | pub fn addAtomsToRelaSections(self: *Object, elf_file: *Elf) void { | |
| 1021 | pub fn addAtomsToRelaSections(self: *Object, elf_file: *Elf) !void { | |
| 1022 | 1022 | for (self.atoms_indexes.items) |atom_index| { |
| 1023 | 1023 | const atom_ptr = self.atom(atom_index) orelse continue; |
| 1024 | 1024 | if (!atom_ptr.alive) continue; |
| ... | ... | @@ -1031,6 +1031,9 @@ pub fn addAtomsToRelaSections(self: *Object, elf_file: *Elf) void { |
| 1031 | 1031 | const shdr = &slice.items(.shdr)[shndx]; |
| 1032 | 1032 | shdr.sh_info = atom_ptr.output_section_index; |
| 1033 | 1033 | shdr.sh_link = elf_file.symtab_section_index.?; |
| 1034 | const gpa = elf_file.base.comp.gpa; | |
| 1035 | const atom_list = &elf_file.sections.items(.atom_list)[shndx]; | |
| 1036 | try atom_list.append(gpa, .{ .index = atom_index, .file = self.index }); | |
| 1034 | 1037 | } |
| 1035 | 1038 | } |
| 1036 | 1039 |
src/link/Elf/ZigObject.zig+4-1| ... | ... | @@ -967,7 +967,10 @@ pub fn addAtomsToRelaSections(self: *ZigObject, elf_file: *Elf) !void { |
| 967 | 967 | const out_shndx = atom_ptr.output_section_index; |
| 968 | 968 | const out_shdr = elf_file.sections.items(.shdr)[out_shndx]; |
| 969 | 969 | if (out_shdr.sh_type == elf.SHT_NOBITS) continue; |
| 970 | const atom_list = &elf_file.sections.items(.atom_list)[out_shndx]; | |
| 970 | const out_rela_shndx = for (elf_file.sections.items(.shdr), 0..) |out_rela_shdr, out_rela_shndx| { | |
| 971 | if (out_rela_shdr.sh_type == elf.SHT_RELA and out_rela_shdr.sh_info == out_shndx) break out_rela_shndx; | |
| 972 | } else unreachable; | |
| 973 | const atom_list = &elf_file.sections.items(.atom_list)[out_rela_shndx]; | |
| 971 | 974 | const gpa = elf_file.base.comp.gpa; |
| 972 | 975 | try atom_list.append(gpa, .{ .index = atom_index, .file = self.index }); |
| 973 | 976 | } |
src/link/Elf/relocatable.zig+3-5| ... | ... | @@ -209,7 +209,7 @@ pub fn flushObject(elf_file: *Elf, comp: *Compilation, module_obj_path: ?[]const |
| 209 | 209 | for (elf_file.objects.items) |index| { |
| 210 | 210 | const object = elf_file.file(index).?.object; |
| 211 | 211 | try object.addAtomsToOutputSections(elf_file); |
| 212 | object.addAtomsToRelaSections(elf_file); | |
| 212 | try object.addAtomsToRelaSections(elf_file); | |
| 213 | 213 | } |
| 214 | 214 | try elf_file.updateMergeSectionSizes(); |
| 215 | 215 | try updateSectionSizes(elf_file); |
| ... | ... | @@ -349,8 +349,8 @@ fn initComdatGroups(elf_file: *Elf) !void { |
| 349 | 349 | fn updateSectionSizes(elf_file: *Elf) !void { |
| 350 | 350 | const slice = elf_file.sections.slice(); |
| 351 | 351 | for (slice.items(.shdr), 0..) |*shdr, shndx| { |
| 352 | const atom_list = slice.items(.atom_list)[shndx]; | |
| 352 | 353 | if (shdr.sh_type != elf.SHT_RELA) { |
| 353 | const atom_list = slice.items(.atom_list)[shndx]; | |
| 354 | 354 | for (atom_list.items) |ref| { |
| 355 | 355 | const atom_ptr = elf_file.atom(ref) orelse continue; |
| 356 | 356 | if (!atom_ptr.alive) continue; |
| ... | ... | @@ -361,7 +361,6 @@ fn updateSectionSizes(elf_file: *Elf) !void { |
| 361 | 361 | shdr.sh_addralign = @max(shdr.sh_addralign, atom_ptr.alignment.toByteUnits() orelse 1); |
| 362 | 362 | } |
| 363 | 363 | } else { |
| 364 | const atom_list = slice.items(.atom_list)[shdr.sh_info]; | |
| 365 | 364 | for (atom_list.items) |ref| { |
| 366 | 365 | const atom_ptr = elf_file.atom(ref) orelse continue; |
| 367 | 366 | if (!atom_ptr.alive) continue; |
| ... | ... | @@ -492,9 +491,8 @@ fn writeSyntheticSections(elf_file: *Elf) !void { |
| 492 | 491 | const gpa = elf_file.base.comp.gpa; |
| 493 | 492 | const slice = elf_file.sections.slice(); |
| 494 | 493 | |
| 495 | for (slice.items(.shdr)) |shdr| { | |
| 494 | for (slice.items(.shdr), slice.items(.atom_list)) |shdr, atom_list| { | |
| 496 | 495 | if (shdr.sh_type != elf.SHT_RELA) continue; |
| 497 | const atom_list = slice.items(.atom_list)[shdr.sh_info]; | |
| 498 | 496 | if (atom_list.items.len == 0) continue; |
| 499 | 497 | |
| 500 | 498 | const num_relocs = math.cast(usize, @divExact(shdr.sh_size, shdr.sh_entsize)) orelse |