| author | |
| committer | |
| log | aa0fbbcb3917ac988757263e064540e1be3402eb |
| tree | 6757624b997cbdfcb7e6a143bcdd71895c70c3bc |
| parent | f34247c4bc3a400d23b99c8921c9b358bf5a3250 |
2 files changed, 9 insertions(+), 3 deletions(-)
src/link/Elf.zig+5-2| ... | ... | @@ -4783,7 +4783,6 @@ fn writeAtomsObject(self: *Elf) !void { |
| 4783 | 4783 | const atom_ptr = self.atom(atom_index).?; |
| 4784 | 4784 | assert(atom_ptr.flags.alive); |
| 4785 | 4785 | |
| 4786 | const object = atom_ptr.file(self).?.object; | |
| 4787 | 4786 | const offset = math.cast(usize, atom_ptr.value - shdr.sh_addr - base_offset) orelse |
| 4788 | 4787 | return error.Overflow; |
| 4789 | 4788 | const size = math.cast(usize, atom_ptr.size) orelse return error.Overflow; |
| ... | ... | @@ -4796,7 +4795,11 @@ fn writeAtomsObject(self: *Elf) !void { |
| 4796 | 4795 | |
| 4797 | 4796 | // TODO decompress directly into provided buffer |
| 4798 | 4797 | const out_code = buffer[offset..][0..size]; |
| 4799 | const in_code = try object.codeDecompressAlloc(self, atom_index); | |
| 4798 | const in_code = switch (atom_ptr.file(self).?) { | |
| 4799 | .object => |x| try x.codeDecompressAlloc(self, atom_index), | |
| 4800 | .zig_object => |x| try x.codeAlloc(self, atom_index), | |
| 4801 | else => unreachable, | |
| 4802 | }; | |
| 4800 | 4803 | defer gpa.free(in_code); |
| 4801 | 4804 | @memcpy(out_code, in_code); |
| 4802 | 4805 | } |
src/link/Elf/ZigObject.zig+4-1| ... | ... | @@ -286,6 +286,7 @@ pub fn addAtom(self: *ZigObject, elf_file: *Elf) !Symbol.Index { |
| 286 | 286 | self.local_esyms.items(.elf_sym)[esym_index].st_shndx = SHN_ATOM; |
| 287 | 287 | symbol_ptr.esym_index = esym_index; |
| 288 | 288 | |
| 289 | // TODO I'm thinking that maybe we shouldn' set this value unless it's actually needed? | |
| 289 | 290 | const relocs_index = @as(u32, @intCast(self.relocs.items.len)); |
| 290 | 291 | const relocs = try self.relocs.addOne(gpa); |
| 291 | 292 | relocs.* = .{}; |
| ... | ... | @@ -490,7 +491,9 @@ pub fn addAtomsToRelaSections(self: ZigObject, elf_file: *Elf) !void { |
| 490 | 491 | for (self.atoms.items) |atom_index| { |
| 491 | 492 | const atom = elf_file.atom(atom_index) orelse continue; |
| 492 | 493 | if (!atom.flags.alive) continue; |
| 493 | _ = atom.relocsShndx() orelse continue; | |
| 494 | const rela_shndx = atom.relocsShndx() orelse continue; | |
| 495 | // TODO this check will become obsolete when we rework our relocs mechanism at the ZigObject level | |
| 496 | if (self.relocs.items[rela_shndx].items.len == 0) continue; | |
| 494 | 497 | const out_shndx = atom.outputShndx().?; |
| 495 | 498 | const out_shdr = elf_file.shdrs.items[out_shndx]; |
| 496 | 499 | if (out_shdr.sh_type == elf.SHT_NOBITS) continue; |