diff --git a/llvm/test/tools/llvm-readobj/XCOFF/symbols-invalid.test b/llvm/test/tools/llvm-readobj/XCOFF/symbols-invalid.test --- a/llvm/test/tools/llvm-readobj/XCOFF/symbols-invalid.test +++ b/llvm/test/tools/llvm-readobj/XCOFF/symbols-invalid.test @@ -1,10 +1,5 @@ ## Test that we report warnings or dump raw data when symbols are invalid. -# RUN: yaml2obj %s --docnum=1 -o %t1 -# RUN: llvm-readobj --syms %t1 2>&1 | FileCheck %s -DFILE=%t1 --check-prefix=CASE1 - -# CASE1: warning: '[[FILE]]': the non-function C_EXT symbol at index 1 should have only 1 auxiliary entry, i.e. the CSECT auxiliary entry - --- !XCOFF FileHeader: MagicNumber: 0x1DF @@ -14,55 +9,45 @@ StorageClass: [[STORAGECLASS='C_EXT']] NumberOfAuxEntries: 2 -# RUN: yaml2obj %s --docnum=1 -DSTORAGECLASS='C_WEAKEXT' -o %t2 -# RUN: llvm-readobj --syms %t2 2>&1 | FileCheck %s -DFILE=%t2 --check-prefix=CASE2 - -# CASE2: warning: '[[FILE]]': the non-function C_WEAKEXT symbol at index 1 should have only 1 auxiliary entry, i.e. the CSECT auxiliary entry - -# RUN: yaml2obj %s --docnum=1 -DSTORAGECLASS='C_HIDEXT' -o %t3 -# RUN: llvm-readobj --syms %t3 2>&1 | FileCheck %s -DFILE=%t3 --check-prefix=CASE3 - -# CASE3: warning: '[[FILE]]': the non-function C_HIDEXT symbol at index 1 should have only 1 auxiliary entry, i.e. the CSECT auxiliary entry - # RUN: yaml2obj %s --docnum=1 -DSTORAGECLASS='C_STAT' -o %t4 -# RUN: llvm-readobj --syms %t4 2>&1 | FileCheck %s -DFILE=%t4 --check-prefix=CASE4 +# RUN: llvm-readobj --syms %t4 2>&1 | FileCheck %s -DFILE=%t4 --check-prefix=CASE1 -# CASE4: warning: '[[FILE]]': the C_STAT symbol at index 1 should not have more than 1 auxiliary entry +# CASE1: warning: '[[FILE]]': the C_STAT symbol at index 1 should not have more than 1 auxiliary entry # RUN: yaml2obj %s --docnum=1 -DSTORAGECLASS='C_DWARF' -o %t5 -# RUN: llvm-readobj --syms %t5 2>&1 | FileCheck %s -DFILE=%t5 --check-prefix=CASE5 +# RUN: llvm-readobj --syms %t5 2>&1 | FileCheck %s -DFILE=%t5 --check-prefix=CASE2 -# CASE5: warning: '[[FILE]]': the C_DWARF symbol at index 1 should not have more than 1 auxiliary entry +# CASE2: warning: '[[FILE]]': the C_DWARF symbol at index 1 should not have more than 1 auxiliary entry # RUN: yaml2obj %s --docnum=1 -DSTORAGECLASS='C_BLOCK' -o %t6 -# RUN: llvm-readobj --syms %t6 2>&1 | FileCheck %s -DFILE=%t6 --check-prefix=CASE6 +# RUN: llvm-readobj --syms %t6 2>&1 | FileCheck %s -DFILE=%t6 --check-prefix=CASE3 -# CASE6: warning: '[[FILE]]': the C_BLOCK symbol at index 1 should not have more than 1 auxiliary entry +# CASE3: warning: '[[FILE]]': the C_BLOCK symbol at index 1 should not have more than 1 auxiliary entry # RUN: yaml2obj %s --docnum=1 -DSTORAGECLASS='C_FCN' -o %t7 -# RUN: llvm-readobj --syms %t7 2>&1 | FileCheck %s -DFILE=%t7 --check-prefix=CASE7 +# RUN: llvm-readobj --syms %t7 2>&1 | FileCheck %s -DFILE=%t7 --check-prefix=CASE4 -# CASE7: warning: '[[FILE]]': the C_FCN symbol at index 1 should not have more than 1 auxiliary entry +# CASE4: warning: '[[FILE]]': the C_FCN symbol at index 1 should not have more than 1 auxiliary entry ## This case tests the raw data output ability when a file auxiliary entry does ## not have the matching auxiliary type. # RUN: yaml2obj %s --docnum=2 -o %t8 -# RUN: llvm-readobj --syms %t8 | FileCheck %s --strict-whitespace --match-full-lines --check-prefix=CASE8 - -# CASE8:Symbols [ -# CASE8-NEXT: Symbol { -# CASE8-NEXT: Index: 0 -# CASE8-NEXT: Name: .fun -# CASE8-NEXT: Value (SymbolTableIndex): 0x0 -# CASE8-NEXT: Section: N_UNDEF -# CASE8-NEXT: Source Language ID: TB_C (0x0) -# CASE8-NEXT: CPU Version ID: 0x0 -# CASE8-NEXT: StorageClass: C_FILE (0x67) -# CASE8-NEXT: NumberOfAuxEntries: 1 -# CASE8-NEXT: !Unexpected raw auxiliary entry data: -# CASE8-NEXT: 00000000 00000001 00020300 00000000 00fb -# CASE8-NEXT: } -# CASE8-NEXT:] +# RUN: llvm-readobj --syms %t8 | FileCheck %s --strict-whitespace --match-full-lines --check-prefix=CASE5 + +# CASE5:Symbols [ +# CASE5-NEXT: Symbol { +# CASE5-NEXT: Index: 0 +# CASE5-NEXT: Name: .fun +# CASE5-NEXT: Value (SymbolTableIndex): 0x0 +# CASE5-NEXT: Section: N_UNDEF +# CASE5-NEXT: Source Language ID: TB_C (0x0) +# CASE5-NEXT: CPU Version ID: 0x0 +# CASE5-NEXT: StorageClass: C_FILE (0x67) +# CASE5-NEXT: NumberOfAuxEntries: 1 +# CASE5-NEXT: !Unexpected raw auxiliary entry data: +# CASE5-NEXT: 00000000 00000001 00020300 00000000 00fb +# CASE5-NEXT: } +# CASE5-NEXT:] --- !XCOFF FileHeader: diff --git a/llvm/test/tools/llvm-readobj/XCOFF/symbols.test b/llvm/test/tools/llvm-readobj/XCOFF/symbols.test --- a/llvm/test/tools/llvm-readobj/XCOFF/symbols.test +++ b/llvm/test/tools/llvm-readobj/XCOFF/symbols.test @@ -134,6 +134,33 @@ LineNumHi: 2 LineNumLo: 3 +##The C_WEAKEXT symbol with two Function auxiliary entries and a CSECT auxiliary entry. + - Name: .fun7 + Value: 0x0 + Section: .text + Type: 0x20 + StorageClass: C_WEAKEXT + NumberOfAuxEntries: 3 + AuxEntries: + - Type: AUX_FCN + OffsetToExceptionTbl: 2 + SizeOfFunction: 3 + SymIdxOfNextBeyond: 4 + PtrToLineNum: 5 + - Type: AUX_FCN + OffsetToExceptionTbl: 8 + SizeOfFunction: 5 + SymIdxOfNextBeyond: 8 + PtrToLineNum: 5 + - Type: AUX_CSECT + ParameterHashIndex: 11 + TypeChkSectNum: 22 + SymbolAlignmentAndType: 33 + StorageMappingClass: XMC_PR + SectionOrLength: 256 + StabInfoIndex: 44 + StabSectNum: 55 + # SYMBOL32: Symbols [ # SYMBOL32-NEXT: Symbol { # SYMBOL32-NEXT: Index: 0 @@ -304,4 +331,38 @@ # SYMBOL32-NEXT: LineNumber (Low 2 Bytes): 0x3 # SYMBOL32-NEXT: } # SYMBOL32-NEXT: } +# SYMBOL32-NEXT: Symbol { +# SYMBOL32-NEXT: Index: 21 +# SYMBOL32-NEXT: Name: .fun7 +# SYMBOL32-NEXT: Value (RelocatableAddress): 0x0 +# SYMBOL32-NEXT: Section: .text +# SYMBOL32-NEXT: Type: 0x20 +# SYMBOL32-NEXT: StorageClass: C_WEAKEXT (0x6F) +# SYMBOL32-NEXT: NumberOfAuxEntries: 3 +# SYMBOL32-NEXT: Function Auxiliary Entry { +# SYMBOL32-NEXT: Index: 22 +# SYMBOL32-NEXT: OffsetToExceptionTable: 0x2 +# SYMBOL32-NEXT: SizeOfFunction: 0x3 +# SYMBOL32-NEXT: PointerToLineNum: 0x5 +# SYMBOL32-NEXT: SymbolIndexOfNextBeyond: 4 +# SYMBOL32-NEXT: } +# SYMBOL32-NEXT: Function Auxiliary Entry { +# SYMBOL32-NEXT: Index: 23 +# SYMBOL32-NEXT: OffsetToExceptionTable: 0x8 +# SYMBOL32-NEXT: SizeOfFunction: 0x5 +# SYMBOL32-NEXT: PointerToLineNum: 0x5 +# SYMBOL32-NEXT: SymbolIndexOfNextBeyond: 8 +# SYMBOL32-NEXT: } +# SYMBOL32-NEXT: CSECT Auxiliary Entry { +# SYMBOL32-NEXT: Index: 24 +# SYMBOL32-NEXT: SectionLen: 256 +# SYMBOL32-NEXT: ParameterHashIndex: 0xB +# SYMBOL32-NEXT: TypeChkSectNum: 0x16 +# SYMBOL32-NEXT: SymbolAlignmentLog2: 4 +# SYMBOL32-NEXT: SymbolType: XTY_SD (0x1) +# SYMBOL32-NEXT: StorageMappingClass: XMC_PR (0x0) +# SYMBOL32-NEXT: StabInfoIndex: 0x2C +# SYMBOL32-NEXT: StabSectNum: 0x37 +# SYMBOL32-NEXT: } +# SYMBOL32-NEXT: } # SYMBOL32-NEXT: ] diff --git a/llvm/tools/llvm-readobj/XCOFFDumper.cpp b/llvm/tools/llvm-readobj/XCOFFDumper.cpp --- a/llvm/tools/llvm-readobj/XCOFFDumper.cpp +++ b/llvm/tools/llvm-readobj/XCOFFDumper.cpp @@ -616,22 +616,13 @@ case XCOFF::C_EXT: case XCOFF::C_WEAKEXT: case XCOFF::C_HIDEXT: { - if (!SymbolEntRef.isFunction() && NumberOfAuxEntries > 1) - reportUniqueWarning("the non-function " + - enumToString(static_cast(SymbolClass), - makeArrayRef(SymStorageClass)) + - " symbol at index " + Twine(SymbolIdx) + - " should have only 1 auxiliary entry, i.e. the CSECT " - "auxiliary entry"); - // For 32-bit objects, print the function auxiliary symbol table entry. The // last one must be a CSECT auxiliary entry. // For 64-bit objects, both a function auxiliary entry and an exception // auxiliary entry may appear, print them in the loop and skip printing the // CSECT auxiliary entry, which will be printed outside the loop. for (int I = 1; I <= NumberOfAuxEntries; I++) { - if ((I == NumberOfAuxEntries && !Obj.is64Bit()) || - !SymbolEntRef.isFunction()) + if (I == NumberOfAuxEntries && !Obj.is64Bit()) break; uintptr_t AuxAddress = XCOFFObjectFile::getAdvancedSymbolEntryAddress(