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