Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / reloc-subtractor.s
blob215593c22b7137be28925bf6bbff03a0df66d268
1 # REQUIRES: x86, aarch64
2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/x86_64.o
4 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/test.s -o %t/arm64.o
5 # RUN: %lld -lSystem %t/x86_64.o -o %t/x86_64 -order_file %t/order-file
6 # RUN: llvm-objdump --syms --full-contents --rebase %t/x86_64 | FileCheck %s
7 # RUN: %lld -arch arm64 -lSystem %t/arm64.o -o %t/arm64 -order_file %t/order-file
8 # RUN: llvm-objdump --syms --full-contents --rebase %t/arm64 | FileCheck %s
10 # CHECK-LABEL: SYMBOL TABLE:
11 # CHECK: {{0*}}[[#%x, SUB1ADDR:]] l {{.*}} __DATA,bar _sub1
12 # CHECK: {{0*}}[[#%x, SUB2ADDR:]] l {{.*}} __DATA,bar _sub2
13 # CHECK: {{0*}}[[#%x, SUB3ADDR:]] l {{.*}} __DATA,bar _sub3
14 # CHECK: {{0*}}[[#%x, SUB4ADDR:]] l {{.*}} __DATA,bar _sub4
15 # CHECK: {{0*}}[[#%x, SUB5ADDR:]] l {{.*}} __DATA,bar _sub5
16 # CHECK-LABEL: Contents of section __DATA,bar:
17 # CHECK: [[#SUB1ADDR]] 10000000
18 # CHECK-NEXT: [[#SUB2ADDR]] f2ffffff
19 # CHECK-NEXT: [[#SUB3ADDR]] 14000000 00000000
20 # CHECK-NEXT: [[#SUB4ADDR]] f6ffffff ffffffff
21 # CHECK-NEXT: [[#SUB5ADDR]] f1ffffff ffffffff
22 # CHECK: Rebase table:
23 # CHECK-NEXT: segment section address type
24 # CHECK-EMPTY:
26 #--- test.s
28 .globl _main, _subtrahend_1, _subtrahend_2, _minuend1, _minuend2
30 .section __DATA,foo
31 .space 16
32 L_.minuend:
33 .space 16
35 .section __DATA,bar
36 _sub1:
37 .long _minuend_1 - _subtrahend_1
38 .space 12
39 _sub2:
40 .long _minuend_2 - _subtrahend_2 + 2
41 .space 12
42 _sub3:
43 .quad _minuend_1 - _subtrahend_1 + 4
44 .space 8
45 _sub4:
46 .quad _minuend_2 - _subtrahend_2 + 6
47 .space 8
48 _sub5:
49 .quad L_.minuend - _subtrahend_1 + 1
50 .space 8
52 _minuend_1:
53 .space 16
54 _minuend_2:
55 .space 16
56 _subtrahend_1:
57 .space 16
58 _subtrahend_2:
59 .space 16
61 .text
62 .p2align 2
63 _main:
64 ret
66 .subsections_via_symbols
68 #--- order-file
69 ## Reorder the symbols to make sure that the addends are being associated with
70 ## the minuend (and not the subtrahend) relocation.
71 _subtrahend_1
72 _minuend_1
73 _minuend_2
74 _subtrahend_2