Mach-O AArch64 relocation addend improvements #581
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
macho: fix PC relative relocation offset for AArch64
For PC relative relocations on some architectures, the implicit addend does not include the offset required due to the PC being different from the place of the relocation.
Previously we always used an offset of 4, since this is commonly required by x86-64. However, this is not correct for AArch64 or for some x8-64 relocations, and probably not correct for other architectures either. For example, the ARM offset may vary depending on the instruction used.
For now, disable this handling for all non x86 targets. This fixes AArch64. Support for other architectures is left as a TODO.
write/macho: fix ARM64_RELOC_ADDEND handling
Closes #580
read/macho: handle ARM64_RELOC_ADDEND
Closes #466
cc @nathanwhit If you're still working in this area, can you review and ensure that your changes from #465 still work? I'll look into adding some tests for this too.