1# RUN: rm -rf %t && mkdir -p %t && cd %t
2# RUN: llvm-mc -triple=x86_64-unknown-freebsd -filetype=obj -o t.o %s
3# RUN: llvm-rtdyld -triple=x86_64-unknown-linux -verify -check=%s t.o -dummy-extern=extern_data=0x4200000000
4
5# Generated from this C source:
6#
7# static int static_data[10];
8# int global_data[10] = {1, 2};
9# extern int extern_data[10];
10#
11# int *lea_static_data() { return &static_data[0]; }
12# int *lea_global_data() { return &global_data[0]; }
13# int *lea_extern_data() { return &extern_data[0]; }
14
15        .text
16        .file   "model.c"
17        .globl  lea_static_data         # -- Begin function lea_static_data
18        .p2align        4, 0x90
19        .type   lea_static_data,@function
20lea_static_data:                        # @lea_static_data
21        .cfi_startproc
22# %bb.0:
23.Ltmp0:
24        leaq    .Ltmp0(%rip), %rcx
25# rtdyld-check: decode_operand(lea_static_got, 1) = section_addr(t.o, .got) - lea_static_data
26lea_static_got:
27        movabsq $_GLOBAL_OFFSET_TABLE_-.Ltmp0, %rax
28        addq    %rax, %rcx
29# rtdyld-check: decode_operand(lea_static_gotoff, 1) = static_data - section_addr(t.o, .got)
30lea_static_gotoff:
31        movabsq $static_data@GOTOFF, %rax
32        addq    %rcx, %rax
33        retq
34.Lfunc_end0:
35        .size   lea_static_data, .Lfunc_end0-lea_static_data
36        .cfi_endproc
37
38
39        .globl  lea_global_data         # -- Begin function lea_global_data
40        .p2align        4, 0x90
41        .type   lea_global_data,@function
42lea_global_data:                        # @lea_global_data
43        .cfi_startproc
44# %bb.0:
45.Ltmp1:
46        leaq    .Ltmp1(%rip), %rcx
47# rtdyld-check: decode_operand(lea_global_got, 1) = section_addr(t.o, .got) - lea_global_data
48lea_global_got:
49        movabsq $_GLOBAL_OFFSET_TABLE_-.Ltmp1, %rax
50        addq    %rax, %rcx
51# rtdyld-check: decode_operand(lea_global_gotoff, 1) = global_data - section_addr(t.o, .got)
52lea_global_gotoff:
53        movabsq $global_data@GOTOFF, %rax
54        addq    %rcx, %rax
55        retq
56.Lfunc_end1:
57        .size   lea_global_data, .Lfunc_end1-lea_global_data
58        .cfi_endproc
59
60
61        .globl  lea_extern_data         # -- Begin function lea_extern_data
62        .p2align        4, 0x90
63        .type   lea_extern_data,@function
64lea_extern_data:                        # @lea_extern_data
65        .cfi_startproc
66# %bb.0:
67.Ltmp2:
68        leaq    .Ltmp2(%rip), %rax
69# rtdyld-check: decode_operand(lea_extern_got, 1) = section_addr(t.o, .got) - lea_extern_data
70lea_extern_got:
71        movabsq $_GLOBAL_OFFSET_TABLE_-.Ltmp2, %rcx
72        addq    %rcx, %rax
73# extern_data is the only thing in the GOT, so it'll be slot 0.
74# rtdyld-check: decode_operand(lea_extern_gotslot, 1) = 0
75lea_extern_gotslot:
76        movabsq $extern_data@GOT, %rcx
77        movq    (%rax,%rcx), %rax
78        retq
79.Lfunc_end2:
80        .size   lea_extern_data, .Lfunc_end2-lea_extern_data
81        .cfi_endproc
82
83
84        .type   global_data,@object     # @global_data
85        .data
86        .globl  global_data
87        .p2align        4
88global_data:
89        .long   1                       # 0x1
90        .long   2                       # 0x2
91        .long   0                       # 0x0
92        .long   0                       # 0x0
93        .long   0                       # 0x0
94        .long   0                       # 0x0
95        .long   0                       # 0x0
96        .long   0                       # 0x0
97        .long   0                       # 0x0
98        .long   0                       # 0x0
99        .size   global_data, 40
100
101        .type   static_data,@object     # @static_data
102        .local  static_data
103        .comm   static_data,40,16
104
105