3 # foo.s and bar.s both contain TU-local symbols (think static function)
4 # with the same name, and both need a thunk. This tests that ld64.lld doesn't
5 # create a duplicate symbol for the two functions.
7 # Test this both when the TU-local symbol is the branch source or target,
8 # and for both forward and backwards jumps.
10 # RUN: rm -rf %t; split-file %s %t
11 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/foo.s -o %t/foo.o
12 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/bar.s -o %t/bar.o
13 # RUN: %lld -arch arm64 -lSystem -o %t.out %t/foo.o %t/bar.o
17 .subsections_via_symbols
19 # Note: No .globl, since these are TU-local symbols.
21 _early_jumping_local_fn
: b _some_late_external
23 _early_landing_local_fn
: ret
25 .globl _some_early_external
27 _some_early_external
: b _late_landing_local_fn
29 ## 0x8000000 is 128 MiB, one more than the forward branch limit.
30 ## Distribute that over two functions since our thunk insertion algorithm
31 ## can't deal with a single function that's 128 MiB.
32 .global _spacer1, _spacer2
38 # Note: No .globl, since these are TU-local symbols.
40 _late_jumping_local_fn
: b _some_early_external
42 _late_landing_local_fn
: ret
44 .globl _some_late_external
46 _some_late_external
: b _early_landing_local_fn
50 .subsections_via_symbols
52 # Note: No .globl, since these are TU-local symbols.
54 _early_jumping_local_fn
: b _some_other_late_external
56 _early_landing_local_fn
: ret
58 .globl _some_other_early_external
60 _some_other_early_external
: b _late_landing_local_fn
62 ## 0x8000000 is 128 MiB, one more than the forward branch limit.
63 ## Distribute that over two functions since our thunk insertion algorithm
64 ## can't deal with a single function that's 128 MiB.
65 .global _other_spacer1, _other_spacer1
71 # Note: No .globl, since these are TU-local symbols.
73 _late_jumping_local_fn
: b _some_other_early_external
75 _late_landing_local_fn
: ret
77 .globl _some_other_late_external
79 _some_other_late_external
: b _early_landing_local_fn