xref: /llvm-project/llvm/test/MC/ARM/macho-relocs-with-addend-invalid.s (revision a1bc3e63cc020aad75b55d8732ab7ae15ea1c973)
1// RUN: not llvm-mc -triple armv7-apple-darwin -filetype=obj %s 2>&1 | FileCheck %s
2
3// Check that the relocation size is valid.
4// Check lower bound of edge case.
5_foo1_valid:
6    // CHECK-NOT: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation out of range
7    b   _foo1_valid+0x2000004
8// Check outside of range of the largest accepted positive number
9_foo1:
10    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation out of range
11    b   _foo1+0x2000008
12
13// Check Same as above, for smallest negative value
14_foo2_valid:
15    // CHECK-NOT: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation out of range
16    b   _foo2_valid-0x1FFFFF8
17_foo2:
18    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation out of range
19    b   _foo2-0x1FFFFFC
20
21// Edge case - subtracting positive number
22_foo3:
23    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation out of range
24    b   _foo3-0x2000010
25
26// Edge case - adding negative number
27_foo4:
28    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation out of range
29    b   _foo4+0x2000008
30
31_foo5:
32    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation out of range
33    bl  _foo5+0x2000008
34
35_foo6:
36    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation out of range
37    blx _foo6+0x2000008
38
39// blx instruction is aligned to 16-bits.
40_foo7_blx:
41    // CHECK-NOT:[[@LINE+1]]:{{[0-9]+}}: error: Relocation not aligned
42    blx _foo7_blx+0x1FFFFFE
43
44// Other branch instructions require 32-bit alignment.
45_foo7:
46    // CHECK:[[@LINE+1]]:{{[0-9]+}}: error: Relocation not aligned
47    bl _foo7_blx+0x1FFFFFE
48
49_foo8:
50    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation out of range
51    ble _foo8+0x2000008
52
53_foo9:
54    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation out of range
55    beq _foo9+0x2000008
56
57    // Check that the relocation alignment is valid.
58    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation not aligned
59    bl  _foo1+0x101
60    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation not aligned
61    blx _foo1+0x101
62    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation not aligned
63    b   _foo1+0x101
64    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation not aligned
65    ble _foo1+0x101
66    // CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Relocation not aligned
67    beq _foo1+0x101
68