1# RUN: rm -rf %t && mkdir -p %t
2# RUN: llvm-mc -triple=armv7s-apple-ios7.0.0 -filetype=obj -o %t/foo.o %s
3# RUN: llvm-rtdyld -triple=armv7s-apple-ios7.0.0 -verify -check=%s %t/foo.o
4
5        .syntax unified
6        .section        __TEXT,__text,regular,pure_instructions
7        .globl  bar
8        .align  2
9bar:
10# Check lower 16-bits of section difference relocation
11# rtdyld-check: decode_operand(insn1, 1) = (foo$non_lazy_ptr-(nextPC+8))[15:0]
12insn1:
13        movw    r0, :lower16:(foo$non_lazy_ptr-(nextPC+8))
14# Check upper 16-bits of section difference relocation
15# rtdyld-check: decode_operand(insn2, 2) = (foo$non_lazy_ptr-(nextPC+8))[31:16]
16insn2:
17        movt    r0, :upper16:(foo$non_lazy_ptr-(nextPC+8))
18nextPC:
19        add     r1, r0, r0
20
21# Check stub generation for external symbols by referencing a common symbol, 'baz'.
22# Check both the content of the stub, and the reference to the stub.
23# Stub should contain '0xe51ff004' (ldr pc, [pc, #-4]), followed by the target.
24#
25# rtdyld-check: *{4}(stub_addr(foo.o/__text, baz)) = 0xe51ff004
26# rtdyld-check: *{4}(stub_addr(foo.o/__text, baz) + 4) = baz
27#
28# rtdyld-check: decode_operand(insn3, 0) = stub_addr(foo.o/__text, baz) - (insn3 + 8)
29insn3:
30        bl      baz
31
32# Check stub generation for internal symbols by referencing 'bar'.
33# rtdyld-check: *{4}(stub_addr(foo.o/__text, bar) + 4) = bar
34insn4:
35        bl      bar
36        bx	lr
37
38# Add 'aaa' to the common symbols to make sure 'baz' isn't at the start of the
39# section. This ensures that we test VANILLA relocation addends correctly.
40        .comm   aaa, 4, 2
41        .comm   baz, 4, 2
42        .comm   foo, 4, 2
43
44	.section        __DATA,__data
45	.globl  _a
46	.align  2
47# rtdyld-check: *{4}bar_ofs = bar + 4
48bar_ofs:
49	.long   bar + 4
50
51# Check that the symbol pointer section entries are fixed up properly:
52# rtdyld-check: *{4}foo$non_lazy_ptr = foo
53        .section	__DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
54  	.align	2
55foo$non_lazy_ptr:
56	.indirect_symbol	foo
57	.long	0
58
59.subsections_via_symbols
60