diff options
| author | Mark Rowe <mark@vector35.com> | 2026-02-27 18:31:39 -0800 |
|---|---|---|
| committer | Mark Rowe <mark@vector35.com> | 2026-02-27 19:17:53 -0800 |
| commit | 4bf13779d75176b6fba0c37fe3b614842bffa193 (patch) | |
| tree | d04ef5e7df8e143bab9125ea1d959842ccdd0676 /arch/x86/arch_x86.cpp | |
| parent | 2b1fc96ebb746ee95c12b5a35cd4ffbe9a83d73e (diff) | |
[MachO] Fix relocations from chained fixups not respecting addends
The addends were correctly stored in the relocation info and displayed
as offsets in linear view, but the relocation handlers never applied
them. Reading from an address containing such a relocation would give an
incorrect value.
Diffstat (limited to 'arch/x86/arch_x86.cpp')
| -rw-r--r-- | arch/x86/arch_x86.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/x86/arch_x86.cpp b/arch/x86/arch_x86.cpp index a79163da..f639040e 100644 --- a/arch/x86/arch_x86.cpp +++ b/arch/x86/arch_x86.cpp @@ -4117,10 +4117,10 @@ public: case (uint64_t)-1: // Magic number defined in MachOView.cpp // We need to write a jump absolute `jmp target` dest[0] = '\xe9'; - ((uint32_t*)&dest[1])[0] = target - (uint32_t)reloc->GetAddress() - 5; + ((uint32_t*)&dest[1])[0] = target + (uint32_t)info.addend - (uint32_t)reloc->GetAddress() - 5; break; case (uint64_t)-2: // Magic number defined in MachOView.cpp - dest32[0] = target; + dest32[0] = target + (uint32_t)info.addend; break; case GENERIC_RELOC_VANILLA: switch (info.size) @@ -4307,7 +4307,7 @@ public: dest64[0] = dest64[0] + info.next->target - target; break; case (uint64_t) -2: - dest64[0] = reloc->GetTarget(); + dest64[0] = info.target + info.addend; break; } return true; |
