1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
|
## Check that obj2yaml is able to dump a normal object which
## contains the SHT_SYMTAB_SHNDX section and symbols with
## section index == SHN_XINDEX.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=CASE1
# CASE1: --- !ELF
# CASE1-NEXT: FileHeader:
# CASE1-NEXT: Class: ELFCLASS64
# CASE1-NEXT: Data: ELFDATA2LSB
# CASE1-NEXT: Type: ET_REL
# CASE1-NEXT: Machine: EM_X86_64
# CASE1-NEXT: Sections:
# CASE1-NEXT: - Name: bar
# CASE1-NEXT: Type: SHT_PROGBITS
# CASE1-NEXT: - Name: .symtab_shndx
# CASE1-NEXT: Type: SHT_SYMTAB_SHNDX
# CASE1-NEXT: Link: .symtab
# CASE1-NEXT: EntSize: 0x0000000000000004
# CASE1-NEXT: Entries: [ 0, 1, 2 ]
# CASE1-NEXT: Symbols:
# CASE1-NEXT: - Name: bar
# CASE1-NEXT: Type: STT_SECTION
# CASE1-NEXT: Index: SHN_XINDEX
# CASE1-NEXT: - Name: .symtab_shndx
# CASE1-NEXT: Type: STT_SECTION
# CASE1-NEXT: Index: SHN_XINDEX
# CASE1-NEXT: ...
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: bar
Type: SHT_PROGBITS
- Name: .symtab_shndx
Type: SHT_SYMTAB_SHNDX
Entries: [ 0, 1, 2 ]
Link: .symtab
Symbols:
- Type: STT_SECTION
Index: SHN_XINDEX
- Type: STT_SECTION
Index: SHN_XINDEX
## Check that yaml2obj is unable to dump an object, which has
## symbols with section index == SHN_XINDEX, but no SHT_SYMTAB_SHNDX section.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: not obj2yaml %t2 2>&1 | FileCheck %s -DFILE=%t2 --check-prefix=CASE2
# CASE2: Error reading file: [[FILE]]: extended symbol index (1) is past the end of the SHT_SYMTAB_SHNDX section of size 0
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Symbols:
- Type: STT_SECTION
Index: SHN_XINDEX
## Check that yaml2obj is unable to dump an object, which has symbols with
## section index == SHN_XINDEX, but SHT_SYMTAB_SHNDX table contains invalid indices
## that are larger than total number of the sections.
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: not obj2yaml %t3 2>&1 | FileCheck %s -DFILE=%t3 --check-prefix=CASE3
# CASE3: Error reading file: [[FILE]]: invalid section index: 254
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: bar
Type: SHT_PROGBITS
- Name: .symtab_shndx
Type: SHT_SYMTAB_SHNDX
Entries: [ 0, 254 ]
Link: .symtab
Symbols:
- Type: STT_SECTION
Index: SHN_XINDEX
## Check that yaml2obj is unable to dump an object, which has symbols with
## section index == SHN_XINDEX, but SHT_SYMTAB_SHNDX table contains more
## entries than the number of symbols in .symtab.
# RUN: yaml2obj --docnum=4 %s -o %t4
# RUN: not obj2yaml %t4 2>&1 | FileCheck %s -DFILE=%t4 --check-prefix=CASE4
## CASE4: Error reading file: [[FILE]]: SHT_SYMTAB_SHNDX has 3 entries, but the symbol table associated has 2
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: bar
Type: SHT_PROGBITS
- Name: .symtab_shndx
Type: SHT_SYMTAB_SHNDX
Entries: [ 0, 1, 2 ]
Link: .symtab
Symbols:
- Type: STT_SECTION
Index: SHN_XINDEX
## ELF gABI allows having multiple SHT_SYMTAB_SHNDX sections.
## We only support having one associated with .symtab now.
# RUN: yaml2obj --docnum=5 %s -o %t5
# RUN: not obj2yaml %t5 2>&1 | FileCheck %s -DFILE=%t5 --check-prefix=CASE5
# CASE5: Error reading file: [[FILE]]: multiple SHT_SYMTAB_SHNDX sections are not supported
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .symtab_shndx1
Type: SHT_SYMTAB_SHNDX
Entries: [ 0 ]
EntSize: 4
Link: .symtab
- Name: .symtab_shndx2
Type: SHT_SYMTAB_SHNDX
Entries: [ 0 ]
Link: .symtab
Symbols: []
## Check that yaml2obj can't dump the object if SHT_SYMTAB_SHNDX is
## not associated with a SHT_SYMTAB section (this case is illegal).
# RUN: yaml2obj --docnum=6 %s -o %t6
# RUN: not obj2yaml %t6 2>&1 | FileCheck %s -DFILE=%t6 --check-prefix=CASE6
# CASE6: Error reading file: [[FILE]]: SHT_SYMTAB_SHNDX section is linked with SHT_PROGBITS section (expected SHT_SYMTAB/SHT_DYNSYM)
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .symtab_shndx
Type: SHT_SYMTAB_SHNDX
Entries: [ 0 ]
Link: .foo
- Name: .foo
Type: SHT_PROGBITS
## Check that yaml2obj can't dump the object if SHT_SYMTAB_SHNDX is
## associated with a SHT_DYNSYM section (not implemented yet).
# RUN: yaml2obj --docnum=7 %s -o %t7
# RUN: not obj2yaml %t7 2>&1 | FileCheck %s -DFILE=%t7 --check-prefix=CASE7
# CASE7: Error reading file: [[FILE]]: only SHT_SYMTAB_SHNDX associated with SHT_SYMTAB are supported
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .symtab_shndx
Type: SHT_SYMTAB_SHNDX
Entries: [ 0, 1 ]
Link: .dynsym
DynamicSymbols:
- Type: STT_SECTION
Index: SHN_XINDEX
|