Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / arm64-32-reloc-got-load.s
blob85431b11e16fc967c7101f5ff488bd3e7bf6a8e2
1 # REQUIRES: aarch64
3 # RUN: rm -rf %t; split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-darwin %t/main.s -o %t/main.o
5 # RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-darwin %t/foobar.s -o %t/foobar.o
7 # RUN: %lld-watchos -lSystem -arch arm64_32 -o %t/static %t/main.o %t/foobar.o
8 # RUN: llvm-objdump --no-print-imm-hex --macho -d --no-show-raw-insn --syms %t/static | FileCheck %s --check-prefix=STATIC
10 # RUN: %lld-watchos -lSystem -arch arm64_32 -dylib -o %t/libfoo.dylib %t/foobar.o
11 # RUN: %lld-watchos -lSystem -arch arm64_32 -o %t/main %t/main.o %t/libfoo.dylib
12 # RUN: llvm-objdump --no-print-imm-hex --macho -d --no-show-raw-insn --section-headers %t/main | FileCheck %s --check-prefix=DYLIB
14 # STATIC-LABEL: _main:
15 # STATIC-NEXT: adrp x8, [[#]] ; 0x[[#%x,PAGE:]]
16 # STATIC-NEXT: add x8, x8, #[[#%u,FOO_OFF:]]
17 # STATIC-NEXT: adrp x8, [[#]] ; 0x[[#PAGE]]
18 # STATIC-NEXT: add x8, x8, #[[#%u,BAR_OFF:]]
19 # STATIC-NEXT: ret
21 # STATIC-LABEL: SYMBOL TABLE:
22 # STATIC-DAG: {{0*}}[[#%x,PAGE+FOO_OFF]] g F __TEXT,__text _foo
23 # STATIC-DAG: {{0*}}[[#%x,PAGE+BAR_OFF]] g F __TEXT,__text _bar
25 # DYLIB-LABEL: _main:
26 # DYLIB-NEXT: adrp x8, [[#]] ; 0x[[#%x,GOT:]]
27 # DYLIB-NEXT: ldr w8, [x8, #4]
28 # DYLIB-NEXT: adrp x8, [[#]] ; 0x[[#GOT]]
29 # DYLIB-NEXT: ldr w8, [x8]
30 # DYLIB-NEXT: ret
31 # DYLIB-EMPTY:
32 # DYLIB-NEXT: Sections:
33 # DYLIB-NEXT: Idx Name Size VMA Type
34 # DYLIB: [[#]] __got 00000008 [[#%.8x,GOT]] DATA
36 #--- main.s
37 .globl _main, _foo, _bar
38 .p2align 2
39 _main:
40 adrp x8, _foo@GOTPAGE
41 ldr w8, [x8, _foo@GOTPAGEOFF]
42 adrp x8, _bar@GOTPAGE
43 ldr w8, [x8, _bar@GOTPAGEOFF]
44 ret
46 #--- foobar.s
47 .globl _foo, _bar
48 _foo:
49 _bar: