diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-11-09 14:46:28 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-11-09 14:46:28 +0100 |
| commit | 1f8dd27e40bb455da85bfb1ae655ad63bc05ea08 (patch) | |
| tree | 618b69cfa2785761e3846cad801bb3c31a0068e9 /src/link/Elf/Object.zig | |
| parent | b1fcf0ed8f435b834f21a3d57c03f5c0333c6fd9 (diff) | |
| download | zig-1f8dd27e40bb455da85bfb1ae655ad63bc05ea08.tar.gz zig-1f8dd27e40bb455da85bfb1ae655ad63bc05ea08.zip | |
elf: correctly format output .eh_frame when emitting relocatable
Diffstat (limited to 'src/link/Elf/Object.zig')
| -rw-r--r-- | src/link/Elf/Object.zig | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/link/Elf/Object.zig b/src/link/Elf/Object.zig index 0a4232d3b1..ce9b83c9bb 100644 --- a/src/link/Elf/Object.zig +++ b/src/link/Elf/Object.zig @@ -687,7 +687,6 @@ 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; } } @@ -695,13 +694,18 @@ pub fn addAtomsToRelaSections(self: Object, elf_file: *Elf) !void { 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 shndx = blk: { + const shndx = atom.relocsShndx() orelse continue; + const shdr = self.shdrs.items[shndx]; + break :blk self.initOutputSection(elf_file, shdr) catch unreachable; + }; + const shdr = &elf_file.shdrs.items[shndx]; + shdr.sh_info = atom.outputShndx().?; + shdr.sh_link = elf_file.symtab_section_index.?; const gpa = elf_file.base.allocator; const gop = try elf_file.output_rela_sections.getOrPut(gpa, atom.outputShndx().?); - if (!gop.found_existing) gop.value_ptr.* = .{ .shndx = out_shndx }; + if (!gop.found_existing) gop.value_ptr.* = .{ .shndx = shndx }; try gop.value_ptr.atom_list.append(gpa, atom_index); } } |
