brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.3 KiB · a4f15b2 Raw
234 lines · plain
1## If a symbol needing a PLT entry also needs a GLOB_DAT relocation, GNU ld's2## x86 port places the PLT entry in .plt.got, relocated by a GLOB_DAT. The3## 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-646# RUN: llvm-objdump -d %t.x86-64 | FileCheck %s --check-prefix=647# RUN: yaml2obj --docnum=2 %s -o %t.x86-328# RUN: llvm-objdump -d %t.x86-32 | FileCheck %s --check-prefix=329 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), %rax23# 64-NEXT:   movq    {{.*}}(%rip), %rax24# 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), %eax42# 32-NEXT:   movl    -0x4(%eax), %eax43# 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 and49## doesn't have .got.plt.50## %t.x86-32 is linked with ld.bfd -pie -z lazy a.o b.so and51## has .got.plt.52 53## a.s54## .globl _start; _start:55## mov combined0@gotpcrel(%rip), %rax  # movl combined0@GOT(%eax), %eax  for x86-3256## mov combined1@gotpcrel(%rip), %rax  # movl combined1@GOT(%eax), %eax  for x86-3257## call combined0@plt58## call combined1@plt59## call foo0@plt60## call foo1@plt61 62## b.s63## .globl foo0, foo1, combined0, combined164## foo0: foo1: combined0: combined1:65 66--- !ELF67FileHeader:68  Class:           ELFCLASS6469  Data:            ELFDATA2LSB70  Type:            ET_DYN71  Machine:         EM_X86_6472  Entry:           0x104073Sections:74  - Name:            .rela.dyn75    Type:            SHT_RELA76    Flags:           [ SHF_ALLOC ]77    Address:         0x34078    Link:            .dynsym79    AddressAlign:    0x880    Relocations:81      - Offset:          0x2FF082        Symbol:          combined083        Type:            R_X86_64_GLOB_DAT84      - Offset:          0x2FF885        Symbol:          combined186        Type:            R_X86_64_GLOB_DAT87  - Name:            .rela.plt88    Type:            SHT_RELA89    Flags:           [ SHF_ALLOC, SHF_INFO_LINK ]90    Address:         0x37091    Link:            .dynsym92    AddressAlign:    0x893    Info:            .got94    Relocations:95      - Offset:          0x2FE096        Symbol:          foo197        Type:            R_X86_64_JUMP_SLOT98      - Offset:          0x2FE899        Symbol:          foo0100        Type:            R_X86_64_JUMP_SLOT101  - Name:            .plt102    Type:            SHT_PROGBITS103    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]104    Address:         0x1000105    AddressAlign:    0x10106    EntSize:         0x10107    Offset:          0x1000108    Content:         FF35CA1F0000FF25CC1F00000F1F4000FF25CA1F00006800000000E9E0FFFFFFFF25C21F00006801000000E9D0FFFFFF109  - Name:            .plt.got110    Type:            SHT_PROGBITS111    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]112    Address:         0x1030113    AddressAlign:    0x8114    EntSize:         0x8115    Content:         FF25BA1F00006690FF25BA1F00006690116  - Name:            .text117    Type:            SHT_PROGBITS118    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]119    Address:         0x1040120    AddressAlign:    0x1121    Content:         488B05A91F0000488B05AA1F0000E8DDFFFFFFE8E0FFFFFFE8C3FFFFFFE8AEFFFFFF122  - Name:            .got123    Type:            SHT_PROGBITS124    Flags:           [ SHF_WRITE, SHF_ALLOC ]125    Address:         0x2FC8126    AddressAlign:    0x8127    EntSize:         0x8128    Content:         '682E000000000000000000000000000000000000000000001610000000000000261000000000000000000000000000000000000000000000'129Symbols:130  - Name:            _start131    Section:         .text132    Binding:         STB_GLOBAL133    Value:           0x1040134DynamicSymbols:135  - Name:            foo1136    Binding:         STB_GLOBAL137  - Name:            foo0138    Binding:         STB_GLOBAL139  - Name:            combined0140    Binding:         STB_GLOBAL141  - Name:            combined1142    Binding:         STB_GLOBAL143...144 145--- !ELF146FileHeader:147  Class:           ELFCLASS32148  Data:            ELFDATA2LSB149  Type:            ET_DYN150  Machine:         EM_386151  Entry:           0x1040152Sections:153  - Name:            .rel.dyn154    Type:            SHT_REL155    Flags:           [ SHF_ALLOC ]156    Address:         0x218157    Link:            .dynsym158    AddressAlign:    0x4159    Relocations:160      - Offset:          0x2FEC161        Symbol:          combined0162        Type:            R_386_GLOB_DAT163      - Offset:          0x2FF0164        Symbol:          combined1165        Type:            R_386_GLOB_DAT166  - Name:            .rel.plt167    Type:            SHT_REL168    Flags:           [ SHF_ALLOC, SHF_INFO_LINK ]169    Address:         0x228170    Link:            .dynsym171    AddressAlign:    0x4172    Info:            .got.plt173    Relocations:174      - Offset:          0x3000175        Symbol:          foo1176        Type:            R_386_JUMP_SLOT177      - Offset:          0x3004178        Symbol:          foo0179        Type:            R_386_JUMP_SLOT180  - Name:            .plt181    Type:            SHT_PROGBITS182    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]183    Address:         0x1000184    AddressAlign:    0x10185    EntSize:         0x4186    Offset:          0x1000187    Content:         FFB304000000FFA30800000000000000FFA30C0000006800000000E9E0FFFFFFFFA3100000006808000000E9D0FFFFFF188  - Name:            .plt.got189    Type:            SHT_PROGBITS190    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]191    Address:         0x1030192    AddressAlign:    0x8193    EntSize:         0x8194    Content:         FFA3F8FFFFFF6690FFA3FCFFFFFF6690195  - Name:            .text196    Type:            SHT_PROGBITS197    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]198    Address:         0x1040199    AddressAlign:    0x1200    Content:         8B80F8FFFFFF8B80FCFFFFFFE8DFFFFFFFE8E2FFFFFFE8C5FFFFFFE8B0FFFFFF201  - Name:            .got202    Type:            SHT_PROGBITS203    Flags:           [ SHF_WRITE, SHF_ALLOC ]204    Address:         0x2FEC205    AddressAlign:    0x4206    EntSize:         0x4207    Content:         '0000000000000000'208  - Name:            .got.plt209    Type:            SHT_PROGBITS210    Flags:           [ SHF_WRITE, SHF_ALLOC ]211    Address:         0x2FF4212    AddressAlign:    0x4213    EntSize:         0x4214    Content:         442F000000000000000000001610000026100000215Symbols:216  - Name:            _GLOBAL_OFFSET_TABLE_217    Type:            STT_OBJECT218    Section:         .got.plt219    Value:           0x2FF4220  - Name:            _start221    Section:         .text222    Binding:         STB_GLOBAL223    Value:           0x1040224DynamicSymbols:225  - Name:            combined0226    Binding:         STB_GLOBAL227  - Name:            foo1228    Binding:         STB_GLOBAL229  - Name:            foo0230    Binding:         STB_GLOBAL231  - Name:            combined1232    Binding:         STB_GLOBAL233...234