1! RUN: llvm-mc %s -arch=sparcv9 --relocation-model=pic -filetype=obj | llvm-readobj -r | FileCheck --check-prefix=PIC %s
2! RUN: llvm-mc %s -arch=sparcv9 --relocation-model=static -filetype=obj | llvm-readobj -r | FileCheck --check-prefix=NOPIC %s
3
4
5! PIC:      Relocations [
6! PIC-NOT:    0x{{[0-9,A-F]+}} R_SPARC_WPLT30 .text 0xC
7! PIC:        0x{{[0-9,A-F]+}} R_SPARC_PC22 _GLOBAL_OFFSET_TABLE_ 0x4
8! PIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_PC10 _GLOBAL_OFFSET_TABLE_ 0x8
9! PIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_PC22 _GLOBAL_OFFSET_TABLE_ 0x0
10! PIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_PC10 _GLOBAL_OFFSET_TABLE_ 0x0
11! PIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_GOT22 AGlobalVar 0x0
12! PIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_GOT10 AGlobalVar 0x0
13! PIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_GOT22 AGlobalVar 0x0
14! PIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_GOT10 AGlobalVar 0x0
15! PIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_GOT22 .LC0 0x0
16! PIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_GOT10 .LC0 0x0
17! PIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_WPLT30 bar 0x0
18! PIC:      ]
19
20! NOPIC:      Relocations [
21! NOPIC-NOT:    0x{{[0-9,A-F]+}} R_SPARC_WPLT30 .text 0xC
22! NOPIC:        0x{{[0-9,A-F]+}} R_SPARC_HI22 _GLOBAL_OFFSET_TABLE_ 0x4
23! NOPIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_LO10 _GLOBAL_OFFSET_TABLE_ 0x8
24! NOPIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_HI22 _GLOBAL_OFFSET_TABLE_ 0x0
25! NOPIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_LO10 _GLOBAL_OFFSET_TABLE_ 0x0
26! NOPIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_HI22 AGlobalVar 0x0
27! NOPIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_LO10 AGlobalVar 0x0
28! NOPIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_HI22 AGlobalVar 0x0
29! NOPIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_LO10 AGlobalVar 0x0
30! NOPIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_HI22 .rodata 0x0
31! NOPIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_LO10 .rodata 0x0
32! NOPIC-NEXT:   0x{{[0-9,A-F]+}} R_SPARC_WDISP30 bar 0x0
33! NOPIC:      ]
34
35        .section        ".rodata"
36        .align 8
37.LC0:
38        .asciz   "string"
39        .section ".text"
40        .text
41        .globl  foo
42        .align  4
43        .type   foo,@function
44foo:
45        .cfi_startproc
46        save %sp, -176, %sp
47        .cfi_def_cfa_register %fp
48        .cfi_window_save
49        .cfi_register 15, 31
50.Ltmp4:
51        call .Ltmp5
52.Ltmp6:
53        sethi %hi(_GLOBAL_OFFSET_TABLE_+(.Ltmp6-.Ltmp4)), %i1
54.Ltmp5:
55        or %i1, %lo(_GLOBAL_OFFSET_TABLE_+(.Ltmp5-.Ltmp4)), %i1
56        set _GLOBAL_OFFSET_TABLE_, %i1
57        add %i1, %o7, %i1
58        sethi %hi(AGlobalVar), %i2
59        add %i2, %lo(AGlobalVar), %i2
60        set AGlobalVar, %i2
61        ldx [%i1+%i2], %i3
62        ldx [%i3], %i3
63        sethi %hi(.LC0), %i2
64        add %i2, %lo(.LC0), %i2
65        ldx [%i1+%i2], %i4
66        call bar
67        add %i0, %i1, %o0
68        ret
69        restore %g0, %o0, %o0
70.Ltmp7:
71        .size   foo, .Ltmp7-foo
72        .cfi_endproc
73
74        .type   AGlobalVar,@object      ! @AGlobalVar
75        .section        .bss,#alloc,#write
76        .globl  AGlobalVar
77        .align  8
78AGlobalVar:
79        .xword  0                       ! 0x0
80        .size   AGlobalVar, 8
81