1# REQUIRES: aarch64 2# RUN: rm -rf %t; split-file %s %t 3# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/foo.s -o %t/foo.o 4# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/bar.s -o %t/bar.o 5# RUN: %lld -dylib -arch arm64 -lSystem -o %t/out %t/foo.o %t/bar.o 6 7# RUN: llvm-objdump --macho --syms %t/out | FileCheck %s 8# CHECK: _bar.thunk.0 9 10## Regression test for PR59259. Previously, we neglected to check section 11## alignments when deciding when to create thunks. 12 13## If we ignore alignment, the total size of _spacer1 + _spacer2 below is just 14## under the limit at which we attempt to insert thunks between the spacers. 15## However, with alignment accounted for, their total size ends up being 16## 0x8000000, which is just above the max forward branch range, making thunk 17## insertion necessary. Thus, not accounting for alignment led to an error. 18 19#--- foo.s 20 21_foo: 22 b _bar 23 24## Size of a `b` instruction. 25.equ callSize, 4 26## Refer to `slop` in TextOutputSection::finalize(). 27.equ slopSize, 12 * 256 28 29_spacer1: 30 .space 0x4000000 - slopSize - 2 * callSize - 1 31 32.subsections_via_symbols 33 34#--- bar.s 35.globl _bar 36 37.p2align 14 38_spacer2: 39 .space 0x4000000 40 41_bar: 42 ret 43 44.subsections_via_symbols 45