Fixed some bugs.
[llvm/zpu.git] / test / MC / ELF / relocation-386.s
blobc3903236187a539093b45c56c407e6dd4fc77e35
1 // RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu %s -o - | elf-dump | FileCheck %s
3 // Test that we produce the correct relocation types and that the relocation
4 // to .Lfoo uses the symbol and not the section.
6 // Section 3 is bss
7 // CHECK: # Section 0x00000003
8 // CHECK-NEXT: (('sh_name', 0x0000000d) # '.bss'
10 // CHECK: # Symbol 0x00000001
11 // CHECK-NEXT: (('st_name', 0x00000005) # '.Lfoo'
13 // Symbol 6 is section 3
14 // CHECK: # Symbol 0x00000006
15 // CHECK-NEXT: (('st_name', 0x00000000) # ''
16 // CHECK-NEXT: ('st_value', 0x00000000)
17 // CHECK-NEXT: ('st_size', 0x00000000)
18 // CHECK-NEXT: ('st_bind', 0x00000000)
19 // CHECK-NEXT: ('st_type', 0x00000003)
20 // CHECK-NEXT: ('st_other', 0x00000000)
21 // CHECK-NEXT: ('st_shndx', 0x00000003)
23 // CHECK: # Relocation 0x00000000
24 // CHECK-NEXT: (('r_offset', 0x00000002)
25 // CHECK-NEXT: ('r_sym', 0x00000001)
26 // CHECK-NEXT: ('r_type', 0x00000009)
27 // CHECK-NEXT: ),
28 // CHECK-NEXT: # Relocation 0x00000001
29 // CHECK-NEXT: (('r_offset',
30 // CHECK-NEXT: ('r_sym',
31 // CHECK-NEXT: ('r_type', 0x00000004)
32 // CHECK-NEXT: ),
33 // CHECK-NEXT: # Relocation 0x00000002
34 // CHECK-NEXT: (('r_offset',
35 // CHECK-NEXT: ('r_sym',
36 // CHECK-NEXT: ('r_type', 0x0000000a)
37 // CHECK-NEXT: ),
39 // Relocation 3 (bar3@GOTOFF) is done with symbol 6 (bss)
40 // CHECK-NEXT: # Relocation 0x00000003
41 // CHECK-NEXT: (('r_offset',
42 // CHECK-NEXT: ('r_sym', 0x00000006
43 // CHECK-NEXT: ('r_type',
44 // CHECK-NEXT: ),
46 // Relocation 4 (bar2@GOT) is of type R_386_GOT32
47 // CHECK-NEXT: # Relocation 0x00000004
48 // CHECK-NEXT: (('r_offset',
49 // CHECK-NEXT: ('r_sym',
50 // CHECK-NEXT: ('r_type', 0x00000003
51 // CHECK-NEXT: ),
53 // Relocation 5 (foo@TLSGD) is of type R_386_TLS_GD
54 // CHECK-NEXT: # Relocation 0x00000005
55 // CHECK-NEXT: (('r_offset', 0x00000020)
56 // CHECK-NEXT: ('r_sym', 0x0000000b)
57 // CHECK-NEXT: ('r_type', 0x00000012)
58 // CHECK-NEXT: ),
60 // Relocation 6 ($foo@TPOFF) is of type R_386_TLS_LE_32
61 // CHECK-NEXT: # Relocation 0x00000006
62 // CHECK-NEXT: (('r_offset', 0x00000025)
63 // CHECK-NEXT: ('r_sym', 0x0000000b)
64 // CHECK-NEXT: ('r_type', 0x00000022)
65 // CHECK-NEXT: ),
67 // Relocation 7 (foo@INDNTPOFF) is of type R_386_TLS_IE
68 // CHECK-NEXT: # Relocation 0x00000007
69 // CHECK-NEXT: (('r_offset', 0x0000002b)
70 // CHECK-NEXT: ('r_sym', 0x0000000b)
71 // CHECK-NEXT: ('r_type', 0x0000000f)
72 // CHECK-NEXT: ),
74 // Relocation 8 (foo@NTPOFF) is of type R_386_TLS_LE
75 // CHECK-NEXT: # Relocation 0x00000008
76 // CHECK-NEXT: (('r_offset', 0x00000031)
77 // CHECK-NEXT: ('r_sym', 0x0000000b)
78 // CHECK-NEXT: ('r_type', 0x00000011)
79 // CHECK-NEXT: ),
81 // Relocation 9 (foo@GOTNTPOFF) is of type R_386_TLS_GOTIE
82 // CHECK-NEXT: # Relocation 0x00000009
83 // CHECK-NEXT: (('r_offset', 0x00000037)
84 // CHECK-NEXT: ('r_sym', 0x0000000b)
85 // CHECK-NEXT: ('r_type', 0x00000010)
86 // CHECK-NEXT: ),
88 // Relocation 10 (foo@TLSLDM) is of type R_386_TLS_LDM
89 // CHECK-NEXT: # Relocation 0x0000000a
90 // CHECK-NEXT: (('r_offset', 0x0000003d)
91 // CHECK-NEXT: ('r_sym', 0x0000000b)
92 // CHECK-NEXT: ('r_type', 0x00000013)
93 // CHECK-NEXT: ),
95 // Relocation 11 (foo@DTPOFF) is of type R_386_TLS_LDO_32
96 // CHECK-NEXT: # Relocation 0x0000000b
97 // CHECK-NEXT: (('r_offset', 0x00000043)
98 // CHECK-NEXT: ('r_sym', 0x0000000b)
99 // CHECK-NEXT: ('r_type', 0x00000020)
100 // CHECK-NEXT: ),
102 .text
103 bar:
104 leal .Lfoo@GOTOFF(%ebx), %eax
106 .global bar2
107 bar2:
108 calll bar2@PLT
109 addl $_GLOBAL_OFFSET_TABLE_, %ebx
110 movb bar3@GOTOFF(%ebx), %al
112 .type bar3,@object
113 .local bar3
114 .comm bar3,1,1
116 movl bar2j@GOT(%eax), %eax
118 leal foo@TLSGD(, %ebx,1), %eax
119 movl $foo@TPOFF, %edx
120 movl foo@INDNTPOFF, %ecx
121 addl foo@NTPOFF(%eax), %eax
122 addl foo@GOTNTPOFF(%ebx), %ecx
123 leal foo@TLSLDM(%ebx), %eax
124 leal foo@DTPOFF(%eax), %edx
126 .section .rodata.str1.16,"aMS",@progbits,1
127 .Lfoo:
128 .asciz "bool llvm::llvm_start_multithreaded()"