diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-01-12 23:28:33 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-01-13 20:02:11 +0100 |
| commit | a8564df9ed510f572732b8179844299fc3d3c11b (patch) | |
| tree | b5f5db15e5cf233d9afce94f0a9afbad08f2c88e /src/link | |
| parent | 16c55b15cb227067bf8146226139608edddd8e8c (diff) | |
| download | zig-a8564df9ed510f572732b8179844299fc3d3c11b.tar.gz zig-a8564df9ed510f572732b8179844299fc3d3c11b.zip | |
zld: parse addend from BRANCH reloc on x86_64
As usual, MachO, full of surprises!
Diffstat (limited to 'src/link')
| -rw-r--r-- | src/link/MachO/Atom.zig | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/link/MachO/Atom.zig b/src/link/MachO/Atom.zig index a2f1b385dc..2b16bc8cb0 100644 --- a/src/link/MachO/Atom.zig +++ b/src/link/MachO/Atom.zig @@ -419,6 +419,7 @@ pub fn parseRelocs(self: *Atom, relocs: []macho.relocation_info, context: RelocC .X86_64_RELOC_BRANCH => { // TODO rewrite relocation try addStub(target, context); + addend = mem.readIntLittle(i32, self.code.items[offset..][0..4]); }, .X86_64_RELOC_GOT, .X86_64_RELOC_GOT_LOAD => { // TODO rewrite relocation @@ -1003,7 +1004,7 @@ pub fn resolveRelocs(self: *Atom, macho_file: *MachO) !void { .X86_64_RELOC_BRANCH => { const displacement = try math.cast( i32, - @intCast(i64, target_addr) - @intCast(i64, source_addr) - 4, + @intCast(i64, target_addr) - @intCast(i64, source_addr) - 4 + rel.addend, ); mem.writeIntLittle(u32, self.code.items[rel.offset..][0..4], @bitCast(u32, displacement)); }, |
