| ... | @@ -664,13 +664,24 @@ pub fn initRelaSections(self: Object, elf_file: *Elf) !void { | ... | @@ -664,13 +664,24 @@ pub fn initRelaSections(self: Object, elf_file: *Elf) !void { |
| 664 | if (!atom.flags.alive) continue; | 664 | if (!atom.flags.alive) continue; |
| 665 | const shndx = atom.relocsShndx() orelse continue; | 665 | const shndx = atom.relocsShndx() orelse continue; |
| 666 | const shdr = self.shdrs.items[shndx]; | 666 | const shdr = self.shdrs.items[shndx]; |
| 667 | _ = try self.initOutputSection(elf_file, shdr); | 667 | const out_shndx = try self.initOutputSection(elf_file, shdr); |
| | 668 | const out_shdr = &elf_file.shdrs.items[out_shndx]; |
| | 669 | out_shdr.sh_addralign = @alignOf(elf.Elf64_Rela); |
| | 670 | out_shdr.sh_entsize = @sizeOf(elf.Elf64_Rela); |
| 668 | } | 671 | } |
| 669 | } | 672 | } |
| 670 | | 673 | |
| 671 | pub fn updateRelaSectionsSizes(self: Object, elf_file: *Elf) void { | 674 | pub fn updateRelaSectionsSizes(self: Object, elf_file: *Elf) void { |
| 672 | _ = self; | 675 | for (self.atoms.items) |atom_index| { |
| 673 | _ = elf_file; | 676 | const atom = elf_file.atom(atom_index) orelse continue; |
| | 677 | if (!atom.flags.alive) continue; |
| | 678 | const shndx = atom.relocsShndx() orelse continue; |
| | 679 | const shdr = self.shdrs.items[shndx]; |
| | 680 | const out_shndx = self.initOutputSection(elf_file, shdr) catch unreachable; |
| | 681 | const out_shdr = &elf_file.shdrs.items[out_shndx]; |
| | 682 | const relocs = atom.relocs(elf_file); |
| | 683 | out_shdr.sh_size += out_shdr.sh_entsize * relocs.len; |
| | 684 | } |
| 674 | } | 685 | } |
| 675 | | 686 | |
| 676 | pub fn writeRelaSections(self: Object, elf_file: *Elf) !void { | 687 | pub fn writeRelaSections(self: Object, elf_file: *Elf) !void { |