Bring r240130 back.
[oota-llvm.git] / test / MC / ELF / relocation.s
1 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr  | FileCheck  %s
2
3 // Test that we produce the correct relocation.
4
5
6         .section        .pr23272,"aGw",@progbits,pr23272,comdat
7         .globl pr23272
8 pr23272:
9 pr23272_2:
10 pr23272_3 = pr23272_2
11
12         .text
13 bar:
14         movl    $bar, %edx        # R_X86_64_32
15         movq    $bar, %rdx        # R_X86_64_32S
16         movq    $bar, bar(%rip)   # R_X86_64_32S
17         movl    bar, %edx         # R_X86_64_32S
18         movq    bar, %rdx         # R_X86_64_32S
19 .long bar                         # R_X86_64_32
20         leaq    foo@GOTTPOFF(%rip), %rax # R_X86_64_GOTTPOFF
21         leaq    foo@TLSGD(%rip), %rax    # R_X86_64_TLSGD
22         leaq    foo@TPOFF(%rax), %rax    # R_X86_64_TPOFF32
23         leaq    foo@TLSLD(%rip), %rdi    # R_X86_64_TLSLD
24         leaq    foo@dtpoff(%rax), %rcx   # R_X86_64_DTPOFF32
25         movabs  foo@GOT, %rax            # R_X86_64_GOT64
26         movabs  foo@GOTOFF, %rax         # R_X86_64_GOTOFF64
27         pushq    $bar
28         movq    foo(%rip), %rdx
29         leaq    foo-bar(%r14),%r14
30         addq    $bar,%rax         # R_X86_64_32S
31         .quad   foo@DTPOFF
32         movabsq $baz@TPOFF, %rax
33         .word   foo-bar
34         .byte   foo-bar
35
36         # this should probably be an error...
37         zed = foo +2
38         call zed@PLT
39
40         leaq    -1+foo(%rip), %r11
41
42         movl  $_GLOBAL_OFFSET_TABLE_, %eax
43         movabs  $_GLOBAL_OFFSET_TABLE_, %rax
44
45         .quad    blah@SIZE                        # R_X86_64_SIZE64
46         .quad    blah@SIZE + 32                   # R_X86_64_SIZE64
47         .quad    blah@SIZE - 32                   # R_X86_64_SIZE64
48          movl    blah@SIZE, %eax                  # R_X86_64_SIZE32
49          movl    blah@SIZE + 32, %eax             # R_X86_64_SIZE32
50          movl    blah@SIZE - 32, %eax             # R_X86_64_SIZE32
51
52         .long   foo@gotpcrel
53         .long foo@plt
54
55         .quad   pr23272_2 - pr23272
56         .quad   pr23272_3 - pr23272
57
58         .code16
59         call pr23771
60
61 // CHECK:        Section {
62 // CHECK:          Name: .rela.text
63 // CHECK:          Relocations [
64 // CHECK-NEXT:       0x1 R_X86_64_32        .text
65 // CHECK-NEXT:       0x8 R_X86_64_32S       .text
66 // CHECK-NEXT:       0x13 R_X86_64_32S      .text
67 // CHECK-NEXT:       0x1A R_X86_64_32S      .text
68 // CHECK-NEXT:       0x22 R_X86_64_32S      .text
69 // CHECK-NEXT:       0x26 R_X86_64_32       .text
70 // CHECK-NEXT:       0x2D R_X86_64_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC
71 // CHECK-NEXT:       0x34 R_X86_64_TLSGD    foo 0xFFFFFFFFFFFFFFFC
72 // CHECK-NEXT:       0x3B R_X86_64_TPOFF32  foo 0x0
73 // CHECK-NEXT:       0x42 R_X86_64_TLSLD    foo 0xFFFFFFFFFFFFFFFC
74 // CHECK-NEXT:       0x49 R_X86_64_DTPOFF32 foo 0x0
75 // CHECK-NEXT:       0x4F R_X86_64_GOT64 foo 0x0
76 // CHECK-NEXT:       0x59 R_X86_64_GOTOFF64 foo 0x0
77 // CHECK-NEXT:       0x62 R_X86_64_32S .text 0x0
78 // CHECK-NEXT:       0x69 R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFC
79 // CHECK-NEXT:       0x70 R_X86_64_PC32 foo 0x70
80 // CHECK-NEXT:       0x77 R_X86_64_32S .text 0x0
81 // CHECK-NEXT:       0x7B R_X86_64_DTPOFF64 foo 0x0
82 // CHECK-NEXT:       0x85 R_X86_64_TPOFF64 baz 0x0
83 // CHECK-NEXT:       0x8D R_X86_64_PC16 foo 0x8D
84 // CHECK-NEXT:       0x8F R_X86_64_PC8 foo 0x8F
85 // CHECK-NEXT:       0x91 R_X86_64_PLT32 zed 0xFFFFFFFFFFFFFFFC
86 // CHECK-NEXT:       0x98 R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFB
87 // CHECK-NEXT:       0x9D R_X86_64_GOTPC32 _GLOBAL_OFFSET_TABLE_ 0x1
88 // CHECK-NEXT:       0xA3 R_X86_64_GOTPC64 _GLOBAL_OFFSET_TABLE_ 0x2
89 // CHECK-NEXT:       0xAB R_X86_64_SIZE64 blah 0x0
90 // CHECK-NEXT:       0xB3 R_X86_64_SIZE64 blah 0x20
91 // CHECK-NEXT:       0xBB R_X86_64_SIZE64 blah 0xFFFFFFFFFFFFFFE0
92 // CHECK-NEXT:       0xC6 R_X86_64_SIZE32 blah 0x0
93 // CHECK-NEXT:       0xCD R_X86_64_SIZE32 blah 0x20
94 // CHECK-NEXT:       0xD4 R_X86_64_SIZE32 blah 0xFFFFFFFFFFFFFFE0
95 // CHECK-NEXT:       0xD8 R_X86_64_GOTPCREL foo 0x0
96 // CHECK-NEXT:       0xDC R_X86_64_PLT32 foo 0x0
97 // CHECK-NEXT:       0xF1 R_X86_64_PC16 pr23771 0xFFFFFFFFFFFFFFFE
98 // CHECK-NEXT:     ]
99 // CHECK-NEXT:   }