brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.6 KiB · 90c8263 Raw
256 lines · plain
1## Check that we are able to dump MIPS PLT GOT entries using -A properly.2 3# RUN: yaml2obj --docnum=1 %s -o %t.plt.o4# RUN: llvm-readobj -A %t.plt.o | FileCheck %s --check-prefix=LLVM5# RUN: llvm-readelf -A %t.plt.o | \6# RUN:   FileCheck %s --strict-whitespace --match-full-lines --check-prefix=GNU7 8# LLVM:      PLT GOT {9# LLVM-NEXT:   Reserved entries [10# LLVM-NEXT:     Entry {11# LLVM-NEXT:       Address: 0x200012# LLVM-NEXT:       Initial: 0x013# LLVM-NEXT:       Purpose: PLT lazy resolver14# LLVM-NEXT:     }15# LLVM-NEXT:     Entry {16# LLVM-NEXT:       Address: 0x200817# LLVM-NEXT:       Initial: 0x018# LLVM-NEXT:       Purpose: Module pointer19# LLVM-NEXT:     }20# LLVM-NEXT:   ]21# LLVM-NEXT:   Entries [22# LLVM-NEXT:     Entry {23# LLVM-NEXT:       Address: 0x201024# LLVM-NEXT:       Initial: 0x025# LLVM-NEXT:       Value: 0x026# LLVM-NEXT:       Type: None (0x0)27# LLVM-NEXT:       Section: Undefined (0x0)28# LLVM-NEXT:       Name: foo (5)29# LLVM-NEXT:     }30# LLVM-NEXT:     Entry {31# LLVM-NEXT:       Address: 0x201832# LLVM-NEXT:       Initial: 0x033# LLVM-NEXT:       Value: 0x034# LLVM-NEXT:       Type: None (0x0)35# LLVM-NEXT:       Section: Undefined (0x0)36# LLVM-NEXT:       Name: bar (1)37# LLVM-NEXT:     }38# LLVM-NEXT:   ]39# LLVM-NEXT: }40 41#       GNU:PLT GOT:42# GNU-EMPTY:43#  GNU-NEXT: Reserved entries:44#  GNU-NEXT:   Address  Initial Purpose45#  GNU-NEXT:  0000000000002000 0000000000000000 PLT lazy resolver46#  GNU-NEXT:  0000000000002008 0000000000000000 Module pointer47# GNU-EMPTY:48#  GNU-NEXT: Entries:49#  GNU-NEXT:   Address  Initial Sym.Val. Type    Ndx Name50#  GNU-NEXT:  0000000000002010 0000000000000000 0000000000000000 NOTYPE  UND foo51#  GNU-NEXT:  0000000000002018 0000000000000000 0000000000000000 NOTYPE  UND bar52#   GNU-NOT:{{.}}53 54--- !ELF55FileHeader:56  Class:   ELFCLASS6457  Data:    ELFDATA2LSB58  Type:    ET_REL59  Machine: EM_MIPS60Sections:61  - Name:    .rel.plt62    Type:    SHT_REL63    Flags:   [ SHF_ALLOC ]64    Address: 0x100065    Link:    .dynsym66    Relocations:67      - Offset: 0x168        Symbol: 169        Type:   R_MIPS_JUMP_SLOT70      - Offset: 0x271        Symbol: 272        Type:   R_MIPS_JUMP_SLOT73  - Name:    .got.plt74    Type:    SHT_PROGBITS75    Flags:   [ SHF_WRITE, SHF_ALLOC ]76    Address: 0x200077    Size:    32 ## (dynamic symbols number + 2) * 878  - Name: .dynamic79    Type: SHT_DYNAMIC80    Entries:81      - Tag:   DT_JMPREL82        Value: 0x100083      - Tag:   DT_MIPS_PLTGOT84        Value: 0x200085DynamicSymbols:86  - Name:   "foo"87  - Name:   "bar"88 89## Check we report errors when dynamic tags, needed for dumping PLT, are missing.90 91# RUN: yaml2obj --docnum=2 -DTAG=DT_MIPS_PLTGOT %s -o %t.err1.o92# RUN: llvm-readobj -A %t.err1.o 2>&1 | FileCheck %s -DFILE=%t.err1.o --check-prefixes=NO-OUTPUT,ERR193 94# RUN: yaml2obj --docnum=2 -DTAG=DT_JMPREL %s -o %t.err2.o95# RUN: llvm-readobj -A %t.err2.o 2>&1 | FileCheck %s -DFILE=%t.err2.o --check-prefixes=NO-OUTPUT,ERR296 97--- !ELF98FileHeader:99  Class:   ELFCLASS64100  Data:    ELFDATA2LSB101  Type:    ET_EXEC102  Machine: EM_MIPS103Sections:104  - Name: .dynamic105    Type: SHT_DYNAMIC106    Entries:107      - Tag:   [[TAG]]108        Value: 0109      - Tag:   DT_NULL110        Value: 0111 112## Check we report errors when we are unable to find PLTGOT/JMPREL sections.113# RUN: yaml2obj --docnum=3 %s -DVAL1=0xffff -o %t.err3.o114# RUN: llvm-readobj -A %t.err3.o 2>&1 | FileCheck %s -DFILE=%t.err3.o -check-prefixes=NO-OUTPUT,ERR3115 116# RUN: yaml2obj --docnum=3 %s -DVAL2=0xffff -o %t.err4.o117# RUN: llvm-readobj -A %t.err4.o 2>&1 | FileCheck %s -DFILE=%t.err4.o -check-prefixes=NO-OUTPUT,ERR4118 119--- !ELF120FileHeader:121  Class:   ELFCLASS64122  Data:    ELFDATA2LSB123  Type:    ET_EXEC124  Machine: EM_MIPS125Sections:126  - Name: .dynamic127    Type: SHT_DYNAMIC128    Entries:129      - Tag:   DT_MIPS_PLTGOT130        Value: [[VAL1=0]]131      - Tag:   DT_JMPREL132        Value: [[VAL2=0]]133      - Tag:   DT_NULL134        Value: 0135  - Name:    .foo136    Type:    SHT_PROGBITS137    Address: 0x100138    ShSize:  0xffffffff139    Link:    [[LINK=0x1]]140DynamicSymbols: []141 142## Check we report errors when we are unable to dump PLTGOT properly.143 144# RUN: yaml2obj --docnum=3 -DVAL1=0x100 %s -o %t.err5.o145# RUN: llvm-readobj -A %t.err5.o 2>&1 | FileCheck %s -DFILE=%t.err5.o -check-prefixes=NO-OUTPUT,ERR5146 147# RUN: yaml2obj --docnum=3 -DVAL2=0x100 -DLINK=0xaaaaaaaa %s -o %t.err6.o148# RUN: llvm-readobj -A %t.err6.o 2>&1 | FileCheck %s -DFILE=%t.err6.o -check-prefixes=NO-OUTPUT,ERR6149 150# RUN: yaml2obj --docnum=3 -DVAL2=0x100 %s -o %t.err7.o151# RUN: llvm-readobj -A %t.err7.o 2>&1 | FileCheck %s -DFILE=%t.err7.o -check-prefixes=NO-OUTPUT,ERR7152 153# NO-OUTPUT:      LoadName: <Not found>154# NO-OUTPUT-NEXT: There is no .MIPS.abiflags section in the file.155# NO-OUTPUT-NEXT: There is no .MIPS.options section in the file.156# NO-OUTPUT-NEXT: There is no .reginfo section in the file.157 158# ERR1-NEXT: warning: '[[FILE]]': cannot find JMPREL dynamic tag159# ERR2-NEXT: warning: '[[FILE]]': cannot find MIPS_PLTGOT dynamic tag160# ERR3-NEXT: warning: '[[FILE]]': there is no non-empty PLTGOT section at 0xffff161# ERR4-NEXT: warning: '[[FILE]]': there is no non-empty RELPLT section at 0xffff162# ERR5-NEXT: warning: '[[FILE]]': unable to read PLTGOT section content: section [index 2] has a sh_offset (0x70) + sh_size (0xffffffff) that is greater than the file size (0x280)163# ERR6-NEXT: warning: '[[FILE]]': unable to get a symbol table linked to the SHT_PROGBITS section with index 2: invalid section index: 2863311530164# ERR7-NEXT: warning: '[[FILE]]': unable to get a string table for the SHT_DYNAMIC section with index 1: invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM165 166# NO-OUTPUT-EMPTY:167# NO-OUTPUT-NOT: {{.}}168 169## Check how we print PLT entries when they are unnamed section symbols.170# RUN: yaml2obj --docnum=4 %s -o %t3171# RUN: llvm-readobj -A %t3 2>&1 | FileCheck %s -DFILE=%t3 --check-prefix=SEC-SYMS-LLVM172# RUN: llvm-readelf -A %t3 2>&1 | FileCheck %s -DFILE=%t3 --check-prefix=SEC-SYMS-GNU173 174# SEC-SYMS-LLVM:      PLT GOT {175# SEC-SYMS-LLVM:        Entries [176# SEC-SYMS-LLVM:          Entry {177# SEC-SYMS-LLVM:            Section: Absolute (0xFFF1)178# SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)179# SEC-SYMS-LLVM-NEXT:       Name: <?> (0)180# SEC-SYMS-LLVM-NEXT:     }181# SEC-SYMS-LLVM-NEXT:     Entry {182# SEC-SYMS-LLVM:            Section: .got.plt (0x2)183# SEC-SYMS-LLVM-NEXT:       Name: .got.plt (0)184# SEC-SYMS-LLVM-NEXT:     }185# SEC-SYMS-LLVM-NEXT:     Entry {186# SEC-SYMS-LLVM:            Section: Common (0xFFF2)187# SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON)188# SEC-SYMS-LLVM-NEXT:       Name: <?> (0)189# SEC-SYMS-LLVM-NEXT:     }190# SEC-SYMS-LLVM-NEXT:     Entry {191# SEC-SYMS-LLVM:            Type: Section (0x3)192# SEC-SYMS-LLVM-NEXT: warning: '[[FILE]]': found an extended symbol index (4), but unable to locate the extended symbol index table193# SEC-SYMS-LLVM-NEXT:       Section: Reserved (0xFFFF)194# SEC-SYMS-LLVM-NEXT:       Name: <?> (0)195# SEC-SYMS-LLVM-NEXT:     }196# SEC-SYMS-LLVM-NEXT:   ]197# SEC-SYMS-LLVM-NEXT: }198 199# SEC-SYMS-GNU:      PLT GOT:200# SEC-SYMS-GNU:       Entries:201# SEC-SYMS-GNU-NEXT:   Address          {{.*}} Ndx Name202# SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff1 (SHN_ABS)203# SEC-SYMS-GNU-NEXT:   0000000000002010 {{.*}} ABS <?>204# SEC-SYMS-GNU-NEXT:   0000000000002018 {{.*}}   2 .got.plt205# SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': unable to get section index for symbol with st_shndx = 0xfff2 (SHN_COMMON)206# SEC-SYMS-GNU-NEXT:   0000000000002020 {{.*}} COM <?>207# SEC-SYMS-GNU-NEXT: warning: '[[FILE]]': found an extended symbol index (4), but unable to locate the extended symbol index table208# SEC-SYMS-GNU-NEXT:   0000000000002028 {{.*}} RSV[0xffff] <?>209 210--- !ELF211FileHeader:212  Class:   ELFCLASS64213  Data:    ELFDATA2LSB214  Type:    ET_REL215  Machine: EM_MIPS216Sections:217  - Name:    .rel.plt218    Type:    SHT_REL219    Flags:   [ SHF_ALLOC ]220    Address: 0x1000221    Link:    .dynsym222    Relocations:223      - Offset: 0x1224        Symbol: 1225        Type:   R_MIPS_JUMP_SLOT226      - Offset: 0x2227        Symbol: 2228        Type:   R_MIPS_JUMP_SLOT229      - Offset: 0x2230        Symbol: 3231        Type:   R_MIPS_JUMP_SLOT232      - Offset: 0x3233        Symbol: 4234        Type:   R_MIPS_JUMP_SLOT235  - Name:    .got.plt236    Type:    SHT_PROGBITS237    Flags:   [ SHF_WRITE, SHF_ALLOC ]238    Address: 0x2000239    Size:    48 ## (dynamic symbols number + 2) * 8240  - Name: .dynamic241    Type: SHT_DYNAMIC242    Entries:243      - Tag:   DT_JMPREL244        Value: 0x1000245      - Tag:   DT_MIPS_PLTGOT246        Value: 0x2000247DynamicSymbols:248  - Type:    STT_SECTION249    Index:   SHN_ABS250  - Type:    STT_SECTION251    Section: .got.plt252  - Type:    STT_SECTION253    Index:   SHN_COMMON254  - Type:    STT_SECTION255    Index:   SHN_XINDEX256