1## If a symbol needing a PLT entry also needs a GLOB_DAT relocation, GNU ld's 2## x86 port places the PLT entry in .plt.got, relocated by a GLOB_DAT. The 3## JUMP_SLOT relocation is unused in this case. 4## Test that we synthesize @plt symbols for such PLT entries. 5# RUN: yaml2obj --docnum=1 %s -o %t.x86-64 6# RUN: llvm-objdump -d %t.x86-64 | FileCheck %s --check-prefix=64 7# RUN: yaml2obj --docnum=2 %s -o %t.x86-32 8# RUN: llvm-objdump -d %t.x86-32 | FileCheck %s --check-prefix=32 9 10# 64: Disassembly of section .plt: 11# 64-EMPTY: 12# 64-NEXT: <.plt>: 13# 64: <foo1@plt>: 14# 64: <foo0@plt>: 15 16# 64: Disassembly of section .plt.got: 17# 64-EMPTY: 18# 64-NEXT: <combined0@plt>: 19# 64: <combined1@plt>: 20 21# 64: <_start>: 22# 64-NEXT: movq {{.*}}(%rip), %rax 23# 64-NEXT: movq {{.*}}(%rip), %rax 24# 64-NEXT: callq {{.*}} <combined0@plt> 25# 64-NEXT: callq {{.*}} <combined1@plt> 26# 64-NEXT: callq {{.*}} <foo0@plt> 27# 64-NEXT: callq {{.*}} <foo1@plt> 28 29# 32: Disassembly of section .plt: 30# 32-EMPTY: 31# 32-NEXT: <.plt>: 32# 32: <foo1@plt>: 33# 32: <foo0@plt>: 34 35# 32: Disassembly of section .plt.got: 36# 32-EMPTY: 37# 32-NEXT: <combined0@plt>: 38# 32: <combined1@plt>: 39 40# 32: <_start>: 41# 32-NEXT: movl -0x8(%eax), %eax 42# 32-NEXT: movl -0x4(%eax), %eax 43# 32-NEXT: calll {{.*}} <combined0@plt> 44# 32-NEXT: calll {{.*}} <combined1@plt> 45# 32-NEXT: calll {{.*}} <foo0@plt> 46# 32-NEXT: calll {{.*}} <foo1@plt> 47 48## %t.x86-64 is linked with ld.bfd -pie -z now a.o b.so and 49## doesn't have .got.plt. 50## %t.x86-32 is linked with ld.bfd -pie -z lazy a.o b.so and 51## has .got.plt. 52 53## a.s 54## .globl _start; _start: 55## mov combined0@gotpcrel(%rip), %rax # movl combined0@GOT(%eax), %eax for x86-32 56## mov combined1@gotpcrel(%rip), %rax # movl combined1@GOT(%eax), %eax for x86-32 57## call combined0@plt 58## call combined1@plt 59## call foo0@plt 60## call foo1@plt 61 62## b.s 63## .globl foo0, foo1, combined0, combined1 64## foo0: foo1: combined0: combined1: 65 66--- !ELF 67FileHeader: 68 Class: ELFCLASS64 69 Data: ELFDATA2LSB 70 Type: ET_DYN 71 Machine: EM_X86_64 72 Entry: 0x1040 73Sections: 74 - Name: .rela.dyn 75 Type: SHT_RELA 76 Flags: [ SHF_ALLOC ] 77 Address: 0x340 78 Link: .dynsym 79 AddressAlign: 0x8 80 Relocations: 81 - Offset: 0x2FF0 82 Symbol: combined0 83 Type: R_X86_64_GLOB_DAT 84 - Offset: 0x2FF8 85 Symbol: combined1 86 Type: R_X86_64_GLOB_DAT 87 - Name: .rela.plt 88 Type: SHT_RELA 89 Flags: [ SHF_ALLOC, SHF_INFO_LINK ] 90 Address: 0x370 91 Link: .dynsym 92 AddressAlign: 0x8 93 Info: .got 94 Relocations: 95 - Offset: 0x2FE0 96 Symbol: foo1 97 Type: R_X86_64_JUMP_SLOT 98 - Offset: 0x2FE8 99 Symbol: foo0 100 Type: R_X86_64_JUMP_SLOT 101 - Name: .plt 102 Type: SHT_PROGBITS 103 Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 104 Address: 0x1000 105 AddressAlign: 0x10 106 EntSize: 0x10 107 Offset: 0x1000 108 Content: FF35CA1F0000FF25CC1F00000F1F4000FF25CA1F00006800000000E9E0FFFFFFFF25C21F00006801000000E9D0FFFFFF 109 - Name: .plt.got 110 Type: SHT_PROGBITS 111 Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 112 Address: 0x1030 113 AddressAlign: 0x8 114 EntSize: 0x8 115 Content: FF25BA1F00006690FF25BA1F00006690 116 - Name: .text 117 Type: SHT_PROGBITS 118 Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 119 Address: 0x1040 120 AddressAlign: 0x1 121 Content: 488B05A91F0000488B05AA1F0000E8DDFFFFFFE8E0FFFFFFE8C3FFFFFFE8AEFFFFFF 122 - Name: .got 123 Type: SHT_PROGBITS 124 Flags: [ SHF_WRITE, SHF_ALLOC ] 125 Address: 0x2FC8 126 AddressAlign: 0x8 127 EntSize: 0x8 128 Content: '682E000000000000000000000000000000000000000000001610000000000000261000000000000000000000000000000000000000000000' 129Symbols: 130 - Name: _start 131 Section: .text 132 Binding: STB_GLOBAL 133 Value: 0x1040 134DynamicSymbols: 135 - Name: foo1 136 Binding: STB_GLOBAL 137 - Name: foo0 138 Binding: STB_GLOBAL 139 - Name: combined0 140 Binding: STB_GLOBAL 141 - Name: combined1 142 Binding: STB_GLOBAL 143... 144 145--- !ELF 146FileHeader: 147 Class: ELFCLASS32 148 Data: ELFDATA2LSB 149 Type: ET_DYN 150 Machine: EM_386 151 Entry: 0x1040 152Sections: 153 - Name: .rel.dyn 154 Type: SHT_REL 155 Flags: [ SHF_ALLOC ] 156 Address: 0x218 157 Link: .dynsym 158 AddressAlign: 0x4 159 Relocations: 160 - Offset: 0x2FEC 161 Symbol: combined0 162 Type: R_386_GLOB_DAT 163 - Offset: 0x2FF0 164 Symbol: combined1 165 Type: R_386_GLOB_DAT 166 - Name: .rel.plt 167 Type: SHT_REL 168 Flags: [ SHF_ALLOC, SHF_INFO_LINK ] 169 Address: 0x228 170 Link: .dynsym 171 AddressAlign: 0x4 172 Info: .got.plt 173 Relocations: 174 - Offset: 0x3000 175 Symbol: foo1 176 Type: R_386_JUMP_SLOT 177 - Offset: 0x3004 178 Symbol: foo0 179 Type: R_386_JUMP_SLOT 180 - Name: .plt 181 Type: SHT_PROGBITS 182 Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 183 Address: 0x1000 184 AddressAlign: 0x10 185 EntSize: 0x4 186 Offset: 0x1000 187 Content: FFB304000000FFA30800000000000000FFA30C0000006800000000E9E0FFFFFFFFA3100000006808000000E9D0FFFFFF 188 - Name: .plt.got 189 Type: SHT_PROGBITS 190 Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 191 Address: 0x1030 192 AddressAlign: 0x8 193 EntSize: 0x8 194 Content: FFA3F8FFFFFF6690FFA3FCFFFFFF6690 195 - Name: .text 196 Type: SHT_PROGBITS 197 Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 198 Address: 0x1040 199 AddressAlign: 0x1 200 Content: 8B80F8FFFFFF8B80FCFFFFFFE8DFFFFFFFE8E2FFFFFFE8C5FFFFFFE8B0FFFFFF 201 - Name: .got 202 Type: SHT_PROGBITS 203 Flags: [ SHF_WRITE, SHF_ALLOC ] 204 Address: 0x2FEC 205 AddressAlign: 0x4 206 EntSize: 0x4 207 Content: '0000000000000000' 208 - Name: .got.plt 209 Type: SHT_PROGBITS 210 Flags: [ SHF_WRITE, SHF_ALLOC ] 211 Address: 0x2FF4 212 AddressAlign: 0x4 213 EntSize: 0x4 214 Content: 442F000000000000000000001610000026100000 215Symbols: 216 - Name: _GLOBAL_OFFSET_TABLE_ 217 Type: STT_OBJECT 218 Section: .got.plt 219 Value: 0x2FF4 220 - Name: _start 221 Section: .text 222 Binding: STB_GLOBAL 223 Value: 0x1040 224DynamicSymbols: 225 - Name: combined0 226 Binding: STB_GLOBAL 227 - Name: foo1 228 Binding: STB_GLOBAL 229 - Name: foo0 230 Binding: STB_GLOBAL 231 - Name: combined1 232 Binding: STB_GLOBAL 233... 234