| 
 | 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.o  | 
 | 5 | +# RUN: not llvm-objcopy --strip-debug %t1.in.o %t1.out.o 2>&1 | FileCheck %s --check-prefix=ERROR-NOSYM -DFILE=%t1.out.o  | 
 | 6 | + | 
 | 7 | +# ERROR-NOSYM: error: '[[FILE]]': section '.gfids$y' does not have the corresponding symbol or the symbol has unexpected format  | 
 | 8 | + | 
 | 9 | +--- !COFF  | 
 | 10 | +header:  | 
 | 11 | +  Machine:         IMAGE_FILE_MACHINE_AMD64  | 
 | 12 | +  Characteristics: [  ]  | 
 | 13 | +sections:  | 
 | 14 | +  - Name:            .text  | 
 | 15 | +    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:       4  | 
 | 19 | +    SectionData:     '04000000'  | 
 | 20 | +    SizeOfRawData:   8  | 
 | 21 | +symbols:  | 
 | 22 | +  - Name:            .text  | 
 | 23 | +    Value:           0  | 
 | 24 | +    SectionNumber:   1  | 
 | 25 | +    SimpleType:      IMAGE_SYM_TYPE_NULL  | 
 | 26 | +    ComplexType:     IMAGE_SYM_DTYPE_NULL  | 
 | 27 | +    StorageClass:    IMAGE_SYM_CLASS_STATIC  | 
 | 28 | +    SectionDefinition:  | 
 | 29 | +      Length:          0  | 
 | 30 | +      NumberOfRelocations: 4  | 
 | 31 | +      NumberOfLinenumbers: 0  | 
 | 32 | +      CheckSum:        0  | 
 | 33 | +      Number:          1  | 
 | 34 | +  - Name:            foo  | 
 | 35 | +    Value:           0  | 
 | 36 | +    SectionNumber:   0  | 
 | 37 | +    SimpleType:      IMAGE_SYM_TYPE_NULL  | 
 | 38 | +    ComplexType:     IMAGE_SYM_DTYPE_NULL  | 
 | 39 | +    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL  | 
 | 40 | +...  | 
 | 41 | + | 
 | 42 | +## In this case, the symbol .giats$y has a non-zero offset.  | 
 | 43 | +# RUN: yaml2obj %s --docnum=2 -o %t2.in.o  | 
 | 44 | +# RUN: not llvm-objcopy --strip-debug %t2.in.o %t2.out.o 2>&1 | FileCheck %s --check-prefix=ERROR-OFFSET -DFILE=%t2.out.o  | 
 | 45 | + | 
 | 46 | +# ERROR-OFFSET: error: '[[FILE]]': section '.giats$y' does not have the corresponding symbol or the symbol has unexpected format  | 
 | 47 | + | 
 | 48 | +--- !COFF  | 
 | 49 | +header:  | 
 | 50 | +  Machine:         IMAGE_FILE_MACHINE_AMD64  | 
 | 51 | +  Characteristics: [  ]  | 
 | 52 | +sections:  | 
 | 53 | +  - Name:            .text  | 
 | 54 | +    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:       4  | 
 | 58 | +    SectionData:     '0600000010000000'  | 
 | 59 | +    SizeOfRawData:   8  | 
 | 60 | +symbols:  | 
 | 61 | +  - Name:            .text  | 
 | 62 | +    Value:           0  | 
 | 63 | +    SectionNumber:   1  | 
 | 64 | +    SimpleType:      IMAGE_SYM_TYPE_NULL  | 
 | 65 | +    ComplexType:     IMAGE_SYM_DTYPE_NULL  | 
 | 66 | +    StorageClass:    IMAGE_SYM_CLASS_STATIC  | 
 | 67 | +    SectionDefinition:  | 
 | 68 | +      Length:          0  | 
 | 69 | +      NumberOfRelocations: 0  | 
 | 70 | +      NumberOfLinenumbers: 0  | 
 | 71 | +      CheckSum:        0  | 
 | 72 | +      Number:          1  | 
 | 73 | +  - Name:            '.giats$y'  | 
 | 74 | +    Value:           42  | 
 | 75 | +    SectionNumber:   2  | 
 | 76 | +    SimpleType:      IMAGE_SYM_TYPE_NULL  | 
 | 77 | +    ComplexType:     IMAGE_SYM_DTYPE_NULL  | 
 | 78 | +    StorageClass:    IMAGE_SYM_CLASS_STATIC  | 
 | 79 | +    SectionDefinition:  | 
 | 80 | +      Length:          8  | 
 | 81 | +      NumberOfRelocations: 0  | 
 | 82 | +      NumberOfLinenumbers: 0  | 
 | 83 | +      CheckSum:        1167279533  | 
 | 84 | +      Number:          5  | 
 | 85 | +  - Name:            foo  | 
 | 86 | +    Value:           0  | 
 | 87 | +    SectionNumber:   0  | 
 | 88 | +    SimpleType:      IMAGE_SYM_TYPE_NULL  | 
 | 89 | +    ComplexType:     IMAGE_SYM_DTYPE_NULL  | 
 | 90 | +    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL  | 
 | 91 | +...  | 
 | 92 | + | 
 | 93 | +## In this case, the symbol .gljmp$y has a non-static storage class.  | 
 | 94 | +# RUN: yaml2obj %s --docnum=3 -o %t3.in.o  | 
 | 95 | +# RUN: not llvm-objcopy --strip-debug %t3.in.o %t3.out.o 2>&1 | FileCheck %s --check-prefix=ERROR-EXTERNAL -DFILE=%t3.out.o  | 
 | 96 | + | 
 | 97 | +# ERROR-EXTERNAL: error: '[[FILE]]': section '.gljmp$y' does not have the corresponding symbol or the symbol has unexpected format  | 
 | 98 | + | 
 | 99 | +--- !COFF  | 
 | 100 | +header:  | 
 | 101 | +  Machine:         IMAGE_FILE_MACHINE_AMD64  | 
 | 102 | +  Characteristics: [  ]  | 
 | 103 | +sections:  | 
 | 104 | +  - Name:            .text  | 
 | 105 | +    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:       4  | 
 | 109 | +    SectionData:     '0600000010000000'  | 
 | 110 | +    SizeOfRawData:   8  | 
 | 111 | +symbols:  | 
 | 112 | +  - Name:            .text  | 
 | 113 | +    Value:           0  | 
 | 114 | +    SectionNumber:   1  | 
 | 115 | +    SimpleType:      IMAGE_SYM_TYPE_NULL  | 
 | 116 | +    ComplexType:     IMAGE_SYM_DTYPE_NULL  | 
 | 117 | +    StorageClass:    IMAGE_SYM_CLASS_STATIC  | 
 | 118 | +    SectionDefinition:  | 
 | 119 | +      Length:          0  | 
 | 120 | +      NumberOfRelocations: 0  | 
 | 121 | +      NumberOfLinenumbers: 0  | 
 | 122 | +      CheckSum:        0  | 
 | 123 | +      Number:          1  | 
 | 124 | +  - Name:            '.gljmp$y'  | 
 | 125 | +    Value:           0  | 
 | 126 | +    SectionNumber:   2  | 
 | 127 | +    SimpleType:      IMAGE_SYM_TYPE_NULL  | 
 | 128 | +    ComplexType:     IMAGE_SYM_DTYPE_NULL  | 
 | 129 | +    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL  | 
 | 130 | +  - Name:            foo  | 
 | 131 | +    Value:           0  | 
 | 132 | +    SectionNumber:   0  | 
 | 133 | +    SimpleType:      IMAGE_SYM_TYPE_NULL  | 
 | 134 | +    ComplexType:     IMAGE_SYM_DTYPE_NULL  | 
 | 135 | +    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL  | 
 | 136 | +...  | 
 | 137 | + | 
 | 138 | +## In this case, .gfids$y contains a symbol index that is not present in the  | 
 | 139 | +## symbol table. Generally the behavior should be the same for every section consisting  | 
 | 140 | +## of .symidx directives, e.g .giats$y, .gljmp$y and .gehcont$y.  | 
 | 141 | +# RUN: yaml2obj %s --docnum=4 -o %t4.in.o  | 
 | 142 | +# RUN: not llvm-objcopy --strip-debug %t4.in.o %t4.out.o 2>&1 | FileCheck %s --check-prefix=ERROR-SYMIDX  -DFILE=%t4.out.o  | 
 | 143 | + | 
 | 144 | +# ERROR-SYMIDX: error: '[[FILE]]': section '.gfids$y' contains a .symidx (16) that is incorrect or was stripped  | 
 | 145 | +--- !COFF  | 
 | 146 | +header:  | 
 | 147 | +  Machine:         IMAGE_FILE_MACHINE_AMD64  | 
 | 148 | +  Characteristics: [  ]  | 
 | 149 | +sections:  | 
 | 150 | +  - Name:            .text  | 
 | 151 | +    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:       4  | 
 | 155 | +    SectionData:     '0400000010000000'  | 
 | 156 | +    SizeOfRawData:   8  | 
 | 157 | +symbols:  | 
 | 158 | +  - Name:            .text  | 
 | 159 | +    Value:           0  | 
 | 160 | +    SectionNumber:   1  | 
 | 161 | +    SimpleType:      IMAGE_SYM_TYPE_NULL  | 
 | 162 | +    ComplexType:     IMAGE_SYM_DTYPE_NULL  | 
 | 163 | +    StorageClass:    IMAGE_SYM_CLASS_STATIC  | 
 | 164 | +    SectionDefinition:  | 
 | 165 | +      Length:          0  | 
 | 166 | +      NumberOfRelocations: 0  | 
 | 167 | +      NumberOfLinenumbers: 0  | 
 | 168 | +      CheckSum:        0  | 
 | 169 | +      Number:          1  | 
 | 170 | +  - Name:            '.gfids$y'  | 
 | 171 | +    Value:           0  | 
 | 172 | +    SectionNumber:   2  | 
 | 173 | +    SimpleType:      IMAGE_SYM_TYPE_NULL  | 
 | 174 | +    ComplexType:     IMAGE_SYM_DTYPE_NULL  | 
 | 175 | +    StorageClass:    IMAGE_SYM_CLASS_STATIC  | 
 | 176 | +    SectionDefinition:  | 
 | 177 | +      Length:          8  | 
 | 178 | +      NumberOfRelocations: 0  | 
 | 179 | +      NumberOfLinenumbers: 0  | 
 | 180 | +      CheckSum:        1167279533  | 
 | 181 | +      Number:          5  | 
 | 182 | +  - Name:            foo  | 
 | 183 | +    Value:           0  | 
 | 184 | +    SectionNumber:   0  | 
 | 185 | +    SimpleType:      IMAGE_SYM_TYPE_NULL  | 
 | 186 | +    ComplexType:     IMAGE_SYM_DTYPE_NULL  | 
 | 187 | +    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL  | 
 | 188 | +...  | 
0 commit comments