| ... | @@ -419,6 +419,7 @@ pub fn parseRelocs(self: *Atom, relocs: []macho.relocation_info, context: RelocC | ... | @@ -419,6 +419,7 @@ pub fn parseRelocs(self: *Atom, relocs: []macho.relocation_info, context: RelocC |
| 419 | .X86_64_RELOC_BRANCH => { | 419 | .X86_64_RELOC_BRANCH => { |
| 420 | // TODO rewrite relocation | 420 | // TODO rewrite relocation |
| 421 | try addStub(target, context); | 421 | try addStub(target, context); |
| | 422 | addend = mem.readIntLittle(i32, self.code.items[offset..][0..4]); |
| 422 | }, | 423 | }, |
| 423 | .X86_64_RELOC_GOT, .X86_64_RELOC_GOT_LOAD => { | 424 | .X86_64_RELOC_GOT, .X86_64_RELOC_GOT_LOAD => { |
| 424 | // TODO rewrite relocation | 425 | // TODO rewrite relocation |
| ... | @@ -1003,7 +1004,7 @@ pub fn resolveRelocs(self: *Atom, macho_file: *MachO) !void { | ... | @@ -1003,7 +1004,7 @@ pub fn resolveRelocs(self: *Atom, macho_file: *MachO) !void { |
| 1003 | .X86_64_RELOC_BRANCH => { | 1004 | .X86_64_RELOC_BRANCH => { |
| 1004 | const displacement = try math.cast( | 1005 | const displacement = try math.cast( |
| 1005 | i32, | 1006 | i32, |
| 1006 | @intCast(i64, target_addr) - @intCast(i64, source_addr) - 4, | 1007 | @intCast(i64, target_addr) - @intCast(i64, source_addr) - 4 + rel.addend, |
| 1007 | ); | 1008 | ); |
| 1008 | mem.writeIntLittle(u32, self.code.items[rel.offset..][0..4], @bitCast(u32, displacement)); | 1009 | mem.writeIntLittle(u32, self.code.items[rel.offset..][0..4], @bitCast(u32, displacement)); |
| 1009 | }, | 1010 | }, |