HomePhabricator

[lld-macho] Implement branch-range-extension thunks

Authored by gkm on Mar 29 2021, 5:33 PM.

Description

[lld-macho] Implement branch-range-extension thunks

Extend the range of calls beyond an architecture's limited branch range by first calling a thunk, which loads the far address into a scratch register (x16 on ARM64) and branches through it.

Other ports (COFF, ELF) use multiple passes with successively-refined guesses regarding the expansion of text-space imposed by thunk-space overhead. This MachO algorithm places thunks during MergedOutputSection::finalize() in a single pass using exact thunk-space overheads. Thunks are kept in a separate vector to avoid the overhead of inserting into the inputs vector of MergedOutputSection.

FIXME:

  • arm64-stubs.s test is broken
  • add thunk tests
  • Handle thunks to DylibSymbol in MergedOutputSection::finalize()

Differential Revision: https://reviews.llvm.org/D100818

Details

Committed
gkmMay 12 2021, 9:44 AM
Differential Revision
D100818: [lld-macho] Implement branch-range-extension thunks
Parents
rG9934571eab9c: [libomptarget][amdgpu][nfc] Expand errorcheck macros
Branches
Unknown
Tags
Unknown