45 lines · plain
1# REQUIRES: aarch642# RUN: rm -rf %t; split-file %s %t3# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/foo.s -o %t/foo.o4# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/bar.s -o %t/bar.o5# RUN: %lld -dylib -arch arm64 -lSystem -o %t/out %t/foo.o %t/bar.o6 7# RUN: llvm-objdump --macho --syms %t/out | FileCheck %s8# CHECK: _bar.thunk.09 10## Regression test for PR59259. Previously, we neglected to check section11## alignments when deciding when to create thunks.12 13## If we ignore alignment, the total size of _spacer1 + _spacer2 below is just14## under the limit at which we attempt to insert thunks between the spacers.15## However, with alignment accounted for, their total size ends up being16## 0x8000000, which is just above the max forward branch range, making thunk17## insertion necessary. Thus, not accounting for alignment led to an error.18 19#--- foo.s20 21_foo:22 b _bar23 24## Size of a `b` instruction.25.equ callSize, 426## Refer to `slop` in TextOutputSection::finalize().27.equ slopSize, 12 * 25628 29_spacer1:30 .space 0x4000000 - slopSize - 2 * callSize - 131 32.subsections_via_symbols33 34#--- bar.s35.globl _bar36 37.p2align 1438_spacer2:39 .space 0x400000040 41_bar:42 ret43 44.subsections_via_symbols45