Home | History | Annotate | Download | only in ELF
      1 // RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu %s -o - | elf-dump | FileCheck  %s
      2 
      3 // Test that we produce the correct relocation types and that the relocations
      4 // correctly point to the section or the symbol.
      5 
      6 // CHECK:      # Relocation 0x00000000
      7 // CHECK-NEXT: (('r_offset', 0x00000002)
      8 // CHECK-NEXT:  ('r_sym', 0x00000001)
      9 // CHECK-NEXT:  ('r_type', 0x00000009)
     10 // CHECK-NEXT: ),
     11 // CHECK-NEXT:  # Relocation 0x00000001
     12 // CHECK-NEXT: (('r_offset',
     13 // CHECK-NEXT:  ('r_sym',
     14 // CHECK-NEXT:  ('r_type', 0x00000004)
     15 // CHECK-NEXT: ),
     16 // CHECK-NEXT:  # Relocation 0x00000002
     17 // CHECK-NEXT: (('r_offset',
     18 // CHECK-NEXT:  ('r_sym',
     19 // CHECK-NEXT:  ('r_type', 0x0000000a)
     20 // CHECK-NEXT: ),
     21 
     22 // Relocation 3 (bar3@GOTOFF) is done with symbol 7 (bss)
     23 // CHECK-NEXT:  # Relocation 0x00000003
     24 // CHECK-NEXT: (('r_offset',
     25 // CHECK-NEXT:  ('r_sym', 0x00000007
     26 // CHECK-NEXT:  ('r_type',
     27 // CHECK-NEXT: ),
     28 
     29 // Relocation 4 (bar2@GOT) is of type R_386_GOT32
     30 // CHECK-NEXT:  # Relocation 0x00000004
     31 // CHECK-NEXT: (('r_offset',
     32 // CHECK-NEXT:  ('r_sym',
     33 // CHECK-NEXT:  ('r_type', 0x00000003
     34 // CHECK-NEXT: ),
     35 
     36 // Relocation 5 (foo@TLSGD) is of type R_386_TLS_GD
     37 // CHECK-NEXT: # Relocation 0x00000005
     38 // CHECK-NEXT: (('r_offset', 0x00000020)
     39 // CHECK-NEXT:  ('r_sym', 0x0000000d)
     40 // CHECK-NEXT:  ('r_type', 0x00000012)
     41 // CHECK-NEXT: ),
     42 
     43 // Relocation 6 ($foo@TPOFF) is of type R_386_TLS_LE_32
     44 // CHECK-NEXT: # Relocation 0x00000006
     45 // CHECK-NEXT: (('r_offset', 0x00000025)
     46 // CHECK-NEXT:  ('r_sym', 0x0000000d)
     47 // CHECK-NEXT:  ('r_type', 0x00000022)
     48 // CHECK-NEXT: ),
     49 
     50 // Relocation 7 (foo@INDNTPOFF) is of type R_386_TLS_IE
     51 // CHECK-NEXT: # Relocation 0x00000007
     52 // CHECK-NEXT: (('r_offset', 0x0000002b)
     53 // CHECK-NEXT:  ('r_sym', 0x0000000d)
     54 // CHECK-NEXT:  ('r_type', 0x0000000f)
     55 // CHECK-NEXT: ),
     56 
     57 // Relocation 8 (foo@NTPOFF) is of type R_386_TLS_LE
     58 // CHECK-NEXT: # Relocation 0x00000008
     59 // CHECK-NEXT: (('r_offset', 0x00000031)
     60 // CHECK-NEXT:  ('r_sym', 0x0000000d)
     61 // CHECK-NEXT:  ('r_type', 0x00000011)
     62 // CHECK-NEXT: ),
     63 
     64 // Relocation 9 (foo@GOTNTPOFF) is of type R_386_TLS_GOTIE
     65 // CHECK-NEXT: # Relocation 0x00000009
     66 // CHECK-NEXT: (('r_offset', 0x00000037)
     67 // CHECK-NEXT:  ('r_sym', 0x0000000d)
     68 // CHECK-NEXT:  ('r_type', 0x00000010)
     69 // CHECK-NEXT: ),
     70 
     71 // Relocation 10 (foo@TLSLDM) is of type R_386_TLS_LDM
     72 // CHECK-NEXT: # Relocation 0x0000000a
     73 // CHECK-NEXT: (('r_offset', 0x0000003d)
     74 // CHECK-NEXT:  ('r_sym', 0x0000000d)
     75 // CHECK-NEXT:  ('r_type', 0x00000013)
     76 // CHECK-NEXT: ),
     77 
     78 // Relocation 11 (foo@DTPOFF) is of type R_386_TLS_LDO_32
     79 // CHECK-NEXT: # Relocation 0x0000000b
     80 // CHECK-NEXT: (('r_offset', 0x00000043)
     81 // CHECK-NEXT:  ('r_sym', 0x0000000d)
     82 // CHECK-NEXT:  ('r_type', 0x00000020)
     83 // CHECK-NEXT: ),
     84 // Relocation 12 (calll 4096) is of type R_386_PC32
     85 // CHECK-NEXT: # Relocation 0x0000000c
     86 // CHECK-NEXT: (('r_offset', 0x00000048)
     87 // CHECK-NEXT:  ('r_sym', 0x00000000)
     88 // CHECK-NEXT:  ('r_type', 0x00000002)
     89 // CHECK-NEXT: ),
     90 // Relocation 13 (zed@GOT) is of type R_386_GOT32 and uses the symbol
     91 // CHECK-NEXT: # Relocation 0x0000000d
     92 // CHECK-NEXT: (('r_offset', 0x0000004e)
     93 // CHECK-NEXT:  ('r_sym', 0x00000004)
     94 // CHECK-NEXT:  ('r_type', 0x00000003)
     95 // CHECK-NEXT: ),
     96 // Relocation 14 (zed@GOTOFF) is of type R_386_GOTOFF and uses the symbol
     97 // CHECK-NEXT: # Relocation 0x0000000e
     98 // CHECK-NEXT: (('r_offset', 0x00000054)
     99 // CHECK-NEXT:  ('r_sym', 0x00000004)
    100 // CHECK-NEXT:  ('r_type', 0x00000009)
    101 // CHECK-NEXT: ),
    102 // Relocation 15 (zed@INDNTPOFF) is of type R_386_TLS_IE and uses the symbol
    103 // CHECK-NEXT: # Relocation 0x0000000f
    104 // CHECK-NEXT: (('r_offset', 0x0000005a)
    105 // CHECK-NEXT:  ('r_sym', 0x00000004)
    106 // CHECK-NEXT:  ('r_type', 0x0000000f)
    107 // CHECK-NEXT: ),
    108 // Relocation 16 (zed@NTPOFF) is of type R_386_TLS_LE and uses the symbol
    109 // CHECK-NEXT: # Relocation 0x00000010
    110 // CHECK-NEXT: (('r_offset', 0x00000060)
    111 // CHECK-NEXT:  ('r_sym', 0x00000004)
    112 // CHECK-NEXT:  ('r_type', 0x00000011)
    113 // CHECK-NEXT: ),
    114 // Relocation 17 (zed@GOTNTPOFF) is of type R_386_TLS_GOTIE and uses the symbol
    115 // CHECK-NEXT: # Relocation 0x00000011
    116 // CHECK-NEXT: (('r_offset', 0x00000066)
    117 // CHECK-NEXT:  ('r_sym', 0x00000004)
    118 // CHECK-NEXT:  ('r_type', 0x00000010)
    119 // CHECK-NEXT: ),
    120 // Relocation 18 (zed@PLT) is of type R_386_PLT32 and uses the symbol
    121 // CHECK-NEXT: # Relocation 0x00000012
    122 // CHECK-NEXT: (('r_offset', 0x0000006b)
    123 // CHECK-NEXT:  ('r_sym', 0x00000004)
    124 // CHECK-NEXT:  ('r_type', 0x00000004)
    125 // CHECK-NEXT: ),
    126 // Relocation 19 (zed@TLSGD) is of type R_386_TLS_GD and uses the symbol
    127 // CHECK-NEXT: # Relocation 0x00000013
    128 // CHECK-NEXT: (('r_offset', 0x00000071)
    129 // CHECK-NEXT:  ('r_sym', 0x00000004)
    130 // CHECK-NEXT:  ('r_type', 0x00000012)
    131 // CHECK-NEXT: ),
    132 // Relocation 20 (zed@TLSLDM) is of type R_386_TLS_LDM and uses the symbol
    133 // CHECK-NEXT: # Relocation 0x00000014
    134 // CHECK-NEXT: (('r_offset', 0x00000077)
    135 // CHECK-NEXT:  ('r_sym', 0x00000004)
    136 // CHECK-NEXT:  ('r_type', 0x00000013)
    137 // CHECK-NEXT: ),
    138 // Relocation 21 (zed@TPOFF) is of type R_386_TLS_LE_32 and uses the symbol
    139 // CHECK-NEXT:# Relocation 0x00000015
    140 // CHECK-NEXT: (('r_offset', 0x0000007d)
    141 // CHECK-NEXT:  ('r_sym', 0x00000004)
    142 // CHECK-NEXT:  ('r_type', 0x00000022)
    143 // CHECK-NEXT: ),
    144 // Relocation 22 (zed@DTPOFF) is of type R_386_TLS_LDO_32 and uses the symbol
    145 // CHECK-NEXT: Relocation 0x00000016
    146 // CHECK-NEXT: (('r_offset', 0x00000083)
    147 // CHECK-NEXT:  ('r_sym', 0x00000004)
    148 // CHECK-NEXT:  ('r_type', 0x00000020)
    149 // CHECK-NEXT: ),
    150 // Relocation 23 ($bar) is of type R_386_32 and uses the section
    151 // CHECK-NEXT: Relocation 0x00000017
    152 // CHECK-NEXT: (('r_offset',
    153 // CHECK-NEXT:  ('r_sym',
    154 // CHECK-NEXT:  ('r_type', 0x00000001)
    155 // CHECK-NEXT: ),
    156 // Relocation 24 (foo@GOTTPOFF(%edx)) is of type R_386_TLS_IE_32 and uses the
    157 // symbol
    158 // CHECK-NEXT: Relocation 0x00000018
    159 // CHECK-NEXT: (('r_offset', 0x0000008e)
    160 // CHECK-NEXT:  ('r_sym', 0x0000000d)
    161 // CHECK-NEXT:  ('r_type', 0x00000021)
    162 // CHECK-NEXT: ),
    163 
    164 // Section 4 is bss
    165 // CHECK:      # Section 0x00000004
    166 // CHECK-NEXT: (('sh_name', 0x0000000b) # '.bss'
    167 
    168 // CHECK:      # Symbol 0x00000001
    169 // CHECK-NEXT: (('st_name', 0x00000005) # '.Lfoo'
    170 
    171 // Symbol 4 is zed
    172 // CHECK:      # Symbol 0x00000004
    173 // CHECK-NEXT: (('st_name', 0x00000035) # 'zed'
    174 // CHECK-NEXT:  ('st_value', 0x00000000)
    175 // CHECK-NEXT:  ('st_size', 0x00000000)
    176 // CHECK-NEXT:  ('st_bind', 0x00000000)
    177 // CHECK-NEXT:  ('st_type', 0x00000006)
    178 // CHECK-NEXT:  ('st_other', 0x00000000)
    179 // CHECK-NEXT:  ('st_shndx', 0x00000005)
    180 
    181 // Symbol 7 is section 4
    182 // CHECK:      # Symbol 0x00000007
    183 // CHECK-NEXT: (('st_name', 0x00000000) # ''
    184 // CHECK-NEXT:  ('st_value', 0x00000000)
    185 // CHECK-NEXT:  ('st_size', 0x00000000)
    186 // CHECK-NEXT:  ('st_bind', 0x00000000)
    187 // CHECK-NEXT:  ('st_type', 0x00000003)
    188 // CHECK-NEXT:  ('st_other', 0x00000000)
    189 // CHECK-NEXT:  ('st_shndx', 0x00000004)
    190 
    191 
    192         .text
    193 bar:
    194 	leal	.Lfoo@GOTOFF(%ebx), %eax
    195 
    196         .global bar2
    197 bar2:
    198 	calll	bar2@PLT
    199 	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
    200 	movb	bar3@GOTOFF(%ebx), %al
    201 
    202 	.type	bar3,@object
    203 	.local	bar3
    204 	.comm	bar3,1,1
    205 
    206         movl	bar2j@GOT(%eax), %eax
    207 
    208         leal foo@TLSGD(, %ebx,1), %eax
    209         movl $foo@TPOFF, %edx
    210         movl foo@INDNTPOFF, %ecx
    211         addl foo@NTPOFF(%eax), %eax
    212         addl foo@GOTNTPOFF(%ebx), %ecx
    213         leal foo@TLSLDM(%ebx), %eax
    214         leal foo@DTPOFF(%eax), %edx
    215         calll 4096
    216         movl zed@GOT(%eax), %eax
    217         movl zed@GOTOFF(%eax), %eax
    218         movl zed@INDNTPOFF(%eax), %eax
    219         movl zed@NTPOFF(%eax), %eax
    220         movl zed@GOTNTPOFF(%eax), %eax
    221         call zed@PLT
    222         movl zed@TLSGD(%eax), %eax
    223         movl zed@TLSLDM(%eax), %eax
    224         movl zed@TPOFF(%eax), %eax
    225         movl zed@DTPOFF(%eax), %eax
    226         pushl $bar
    227         addl foo@GOTTPOFF(%edx), %eax
    228 
    229         .section        zedsec,"awT",@progbits
    230 zed:
    231         .long 0
    232 
    233         .section	.rodata.str1.16,"aMS",@progbits,1
    234 .Lfoo:
    235 	.asciz	 "bool llvm::llvm_start_multithreaded()"
    236