OSDN Git Service

[JITLink][MachO] Fix handling of non-extern UNSIGNED pair of SUBTRACTOR relocs.
authorLang Hames <lhames@gmail.com>
Sun, 19 Jul 2020 03:43:13 +0000 (20:43 -0700)
committerLang Hames <lhames@gmail.com>
Sun, 19 Jul 2020 17:22:55 +0000 (10:22 -0700)
commitf7a571537a14da83e5701864471b99b61cdcca54
tree45069739df32e135a8c3446aab5bfc5c95ad6bf2
parentef66e3d086308800d7947a385c2ae09d3f55a695
[JITLink][MachO] Fix handling of non-extern UNSIGNED pair of SUBTRACTOR relocs.

When processing a MachO SUBTRACTOR/UNSIGNED pair, if the UNSIGNED target
is non-extern then check the r_symbolnum field of the relocation to find
the targeted section and use the section's address to find 'ToSymbol'.

Previously 'ToSymbol' was found by loading the initial value stored at
the fixup location and treating this as an address to search for. This
is incorrect, however: the initial value includes the addend and will
point to the wrong block if the addend is less than zero or greater than
the block size.

rdar://65756694
llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
llvm/test/ExecutionEngine/JITLink/X86/MachO_x86-64_relocations.s