189 lines · plain
1## Test that we bail out if a section consisting of symidx is invalid.2 3## In this case, the symbol .gfids$y is not present at all.4# RUN: yaml2obj %s --docnum=1 -o %t1.in.o5# RUN: not llvm-objcopy --strip-debug %t1.in.o %t1.out.o 2>&1 | FileCheck %s --check-prefix=ERROR-NOSYM -DFILE=%t1.out.o6 7# ERROR-NOSYM: error: '[[FILE]]': section '.gfids$y' does not have the corresponding symbol or the symbol has unexpected format8 9--- !COFF10header:11 Machine: IMAGE_FILE_MACHINE_AMD6412 Characteristics: [ ]13sections:14 - Name: .text15 Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]16 - Name: '.gfids$y'17 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]18 Alignment: 419 SectionData: '04000000'20 SizeOfRawData: 821symbols:22 - Name: .text23 Value: 024 SectionNumber: 125 SimpleType: IMAGE_SYM_TYPE_NULL26 ComplexType: IMAGE_SYM_DTYPE_NULL27 StorageClass: IMAGE_SYM_CLASS_STATIC28 SectionDefinition:29 Length: 030 NumberOfRelocations: 431 NumberOfLinenumbers: 032 CheckSum: 033 Number: 134 - Name: foo35 Value: 036 SectionNumber: 037 SimpleType: IMAGE_SYM_TYPE_NULL38 ComplexType: IMAGE_SYM_DTYPE_NULL39 StorageClass: IMAGE_SYM_CLASS_EXTERNAL40...41 42## In this case, the symbol .giats$y has a non-zero offset.43# RUN: yaml2obj %s --docnum=2 -o %t2.in.o44# RUN: not llvm-objcopy --strip-debug %t2.in.o %t2.out.o 2>&1 | FileCheck %s --check-prefix=ERROR-OFFSET -DFILE=%t2.out.o45 46# ERROR-OFFSET: error: '[[FILE]]': section '.giats$y' does not have the corresponding symbol or the symbol has unexpected format47 48--- !COFF49header:50 Machine: IMAGE_FILE_MACHINE_AMD6451 Characteristics: [ ]52sections:53 - Name: .text54 Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]55 - Name: '.giats$y'56 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]57 Alignment: 458 SectionData: '0600000010000000'59 SizeOfRawData: 860symbols:61 - Name: .text62 Value: 063 SectionNumber: 164 SimpleType: IMAGE_SYM_TYPE_NULL65 ComplexType: IMAGE_SYM_DTYPE_NULL66 StorageClass: IMAGE_SYM_CLASS_STATIC67 SectionDefinition:68 Length: 069 NumberOfRelocations: 070 NumberOfLinenumbers: 071 CheckSum: 072 Number: 173 - Name: '.giats$y'74 Value: 4275 SectionNumber: 276 SimpleType: IMAGE_SYM_TYPE_NULL77 ComplexType: IMAGE_SYM_DTYPE_NULL78 StorageClass: IMAGE_SYM_CLASS_STATIC79 SectionDefinition:80 Length: 881 NumberOfRelocations: 082 NumberOfLinenumbers: 083 CheckSum: 116727953384 Number: 585 - Name: foo86 Value: 087 SectionNumber: 088 SimpleType: IMAGE_SYM_TYPE_NULL89 ComplexType: IMAGE_SYM_DTYPE_NULL90 StorageClass: IMAGE_SYM_CLASS_EXTERNAL91...92 93## In this case, the symbol .gljmp$y has a non-static storage class.94# RUN: yaml2obj %s --docnum=3 -o %t3.in.o95# RUN: not llvm-objcopy --strip-debug %t3.in.o %t3.out.o 2>&1 | FileCheck %s --check-prefix=ERROR-EXTERNAL -DFILE=%t3.out.o96 97# ERROR-EXTERNAL: error: '[[FILE]]': section '.gljmp$y' does not have the corresponding symbol or the symbol has unexpected format98 99--- !COFF100header:101 Machine: IMAGE_FILE_MACHINE_AMD64102 Characteristics: [ ]103sections:104 - Name: .text105 Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]106 - Name: '.gljmp$y'107 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]108 Alignment: 4109 SectionData: '0600000010000000'110 SizeOfRawData: 8111symbols:112 - Name: .text113 Value: 0114 SectionNumber: 1115 SimpleType: IMAGE_SYM_TYPE_NULL116 ComplexType: IMAGE_SYM_DTYPE_NULL117 StorageClass: IMAGE_SYM_CLASS_STATIC118 SectionDefinition:119 Length: 0120 NumberOfRelocations: 0121 NumberOfLinenumbers: 0122 CheckSum: 0123 Number: 1124 - Name: '.gljmp$y'125 Value: 0126 SectionNumber: 2127 SimpleType: IMAGE_SYM_TYPE_NULL128 ComplexType: IMAGE_SYM_DTYPE_NULL129 StorageClass: IMAGE_SYM_CLASS_EXTERNAL130 - Name: foo131 Value: 0132 SectionNumber: 0133 SimpleType: IMAGE_SYM_TYPE_NULL134 ComplexType: IMAGE_SYM_DTYPE_NULL135 StorageClass: IMAGE_SYM_CLASS_EXTERNAL136...137 138## In this case, .gfids$y contains a symbol index that is not present in the139## symbol table. Generally the behavior should be the same for every section consisting140## of .symidx directives, e.g .giats$y, .gljmp$y and .gehcont$y.141# RUN: yaml2obj %s --docnum=4 -o %t4.in.o142# RUN: not llvm-objcopy --strip-debug %t4.in.o %t4.out.o 2>&1 | FileCheck %s --check-prefix=ERROR-SYMIDX -DFILE=%t4.out.o143 144# ERROR-SYMIDX: error: '[[FILE]]': section '.gfids$y' contains a .symidx (16) that is incorrect or was stripped145--- !COFF146header:147 Machine: IMAGE_FILE_MACHINE_AMD64148 Characteristics: [ ]149sections:150 - Name: .text151 Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]152 - Name: '.gfids$y'153 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]154 Alignment: 4155 SectionData: '0400000010000000'156 SizeOfRawData: 8157symbols:158 - Name: .text159 Value: 0160 SectionNumber: 1161 SimpleType: IMAGE_SYM_TYPE_NULL162 ComplexType: IMAGE_SYM_DTYPE_NULL163 StorageClass: IMAGE_SYM_CLASS_STATIC164 SectionDefinition:165 Length: 0166 NumberOfRelocations: 0167 NumberOfLinenumbers: 0168 CheckSum: 0169 Number: 1170 - Name: '.gfids$y'171 Value: 0172 SectionNumber: 2173 SimpleType: IMAGE_SYM_TYPE_NULL174 ComplexType: IMAGE_SYM_DTYPE_NULL175 StorageClass: IMAGE_SYM_CLASS_STATIC176 SectionDefinition:177 Length: 8178 NumberOfRelocations: 0179 NumberOfLinenumbers: 0180 CheckSum: 1167279533181 Number: 5182 - Name: foo183 Value: 0184 SectionNumber: 0185 SimpleType: IMAGE_SYM_TYPE_NULL186 ComplexType: IMAGE_SYM_DTYPE_NULL187 StorageClass: IMAGE_SYM_CLASS_EXTERNAL188...189