[llvm] [XCOFF][obj2yaml] Support SymbolAlignmentAndType as 2 separate fields in YAML. (PR #76828)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 18 00:49:03 PST 2024
================
@@ -1,209 +1,112 @@
-## Check that obj2yaml can parse SymbolAlignmentAndType, SymbolAlignment, and SymbolType.
+## Check that obj2yaml can parse SymbolAlignmentAndType, SymbolAlignment,
+## and SymbolType. If either SymbolAlignment or SymbolType are specified
+## along with SymbolAligmentAndType, report an error.
-# RUN: yaml2obj %s --docnum=1 -o %t32
-# RUN: obj2yaml %t32 | FileCheck %s --check-prefix=CHECK32
+# RUN: yaml2obj %s --docnum=1 -DMAGIC=0x01DF -o %t32
+# RUN: obj2yaml %t32 | FileCheck %s --check-prefix=CHECK
+# RUN: yaml2obj %s --docnum=1 -DMAGIC=0x01F7 -o %t64
+# RUN: obj2yaml %t64 | FileCheck %s --check-prefix=CHECK
-# CHECK32: --- !XCOFF
-# CHECK32-NEXT: FileHeader:
-# CHECK32-NEXT: MagicNumber: 0x1DF
-# CHECK32-NEXT: NumberOfSections: 0
-# CHECK32-NEXT: CreationTime: 0
-# CHECK32-NEXT: OffsetToSymbolTable: 0x14
-# CHECK32-NEXT: EntriesInSymbolTable: 10
-# CHECK32-NEXT: AuxiliaryHeaderSize: 0
-# CHECK32-NEXT: Flags: 0x0
-# CHECK32-NEXT: Symbols:
-# CHECK32: - Name: .fcn1
-# CHECK32-NEXT: Value: 0x0
-# CHECK32-NEXT: Section: N_UNDEF
-# CHECK32-NEXT: Type: 0x0
-# CHECK32-NEXT: StorageClass: C_EXT
-# CHECK32-NEXT: NumberOfAuxEntries: 1
-# CHECK32-NEXT: AuxEntries:
-# CHECK32-NEXT: - Type: AUX_CSECT
-# CHECK32-NEXT: ParameterHashIndex: 0
-# CHECK32-NEXT: TypeChkSectNum: 0
-# CHECK32-NEXT: SymbolType: XTY_SD
-# CHECK32-NEXT: SymbolAlignment: 4
-# CHECK32-NEXT: StorageMappingClass: XMC_PR
-# CHECK32: - Name: .fcn2
-# CHECK32-NEXT: Value: 0x0
-# CHECK32-NEXT: Section: N_UNDEF
-# CHECK32-NEXT: Type: 0x0
-# CHECK32-NEXT: StorageClass: C_EXT
-# CHECK32-NEXT: NumberOfAuxEntries: 1
-# CHECK32-NEXT: AuxEntries:
-# CHECK32-NEXT: - Type: AUX_CSECT
-# CHECK32-NEXT: ParameterHashIndex: 0
-# CHECK32-NEXT: TypeChkSectNum: 0
-# CHECK32-NEXT: SymbolType: XTY_SD
-# CHECK32-NEXT: SymbolAlignment: 2
-# CHECK32-NEXT: StorageMappingClass: XMC_PR
-# CHECK32: - Name: .fcn3
-# CHECK32-NEXT: Value: 0x0
-# CHECK32-NEXT: Section: N_UNDEF
-# CHECK32-NEXT: Type: 0x0
-# CHECK32-NEXT: StorageClass: C_EXT
-# CHECK32-NEXT: NumberOfAuxEntries: 1
-# CHECK32-NEXT: AuxEntries:
-# CHECK32-NEXT: - Type: AUX_CSECT
-# CHECK32-NEXT: ParameterHashIndex: 0
-# CHECK32-NEXT: TypeChkSectNum: 0
-# CHECK32-NEXT: SymbolType: XTY_SD
-# CHECK32-NEXT: SymbolAlignment: 0
-# CHECK32-NEXT: StorageMappingClass: XMC_PR
-# CHECK32: - Name: .fcn4
-# CHECK32-NEXT: Value: 0x0
-# CHECK32-NEXT: Section: N_UNDEF
-# CHECK32-NEXT: Type: 0x0
-# CHECK32-NEXT: StorageClass: C_EXT
-# CHECK32-NEXT: NumberOfAuxEntries: 1
-# CHECK32-NEXT: AuxEntries:
-# CHECK32-NEXT: - Type: AUX_CSECT
-# CHECK32-NEXT: ParameterHashIndex: 0
-# CHECK32-NEXT: TypeChkSectNum: 0
-# CHECK32-NEXT: SymbolType: XTY_ER
-# CHECK32-NEXT: SymbolAlignment: 5
-# CHECK32-NEXT: StorageMappingClass: XMC_PR
+# CHECK: --- !XCOFF
+# CHECK-NEXT: FileHeader:
+# CHECK-NEXT: MagicNumber:
+# CHECK: Symbols:
+# CHECK: - Name: .fcn1
+# CHECK: NumberOfAuxEntries: 1
+# CHECK-NEXT: AuxEntries:
+# CHECK-NEXT: - Type: AUX_CSECT
+# CHECK: SymbolType: XTY_ER
+# CHECK-NEXT: SymbolAlignment: 4
+# CHECK: - Name: .fcn2
+# CHECK: NumberOfAuxEntries: 1
+# CHECK-NEXT: AuxEntries:
+# CHECK-NEXT: - Type: AUX_CSECT
+# CHECK: SymbolType: XTY_SD
+# CHECK-NEXT: SymbolAlignment: 2
+# CHECK: - Name: .fcn3
+# CHECK: NumberOfAuxEntries: 1
+# CHECK-NEXT: AuxEntries:
+# CHECK-NEXT: - Type: AUX_CSECT
+# CHECK: SymbolType: XTY_SD
+# CHECK-NEXT: SymbolAlignment: 0
--- !XCOFF
FileHeader:
- MagicNumber: 0x1DF
+ MagicNumber: [[MAGIC]]
Symbols:
- - StorageClass: C_FILE
- AuxEntries:
- - Type: AUX_FILE
- FileNameOrString: FileName
- FileStringType: XFT_CD
- - StorageClass: C_EXT
- Name: .fcn1
+ - StorageClass: C_EXT
+ Name: .fcn1
AuxEntries:
- - Type: AUX_CSECT
- SymbolAlignmentAndType: 17
+ - Type: AUX_CSECT
SymbolAlignment: 4
- SectionOrLength: 4
- - StorageClass: C_EXT
- Name: .fcn2
+ - StorageClass: C_EXT
+ Name: .fcn2
AuxEntries:
- - Type: AUX_CSECT
- SymbolAlignmentAndType: 18
+ - Type: AUX_CSECT
+ SymbolAlignment: 2
SymbolType: XTY_SD
- SectionOrLength: 4
- StorageClass: C_EXT
- Name: .fcn3
+ Name: .fcn3
AuxEntries:
- - Type: AUX_CSECT
+ - Type: AUX_CSECT
SymbolType: XTY_SD
- SectionOrLength: 4
- - StorageClass: C_EXT
- Name: .fcn4
- AuxEntries:
- - Type: AUX_CSECT
- SymbolAlignment: 5
- SectionOrLength: 4
-
-# RUN: yaml2obj %s --docnum=2 -o %t64
-# RUN: obj2yaml %t64 | FileCheck %s --check-prefix=CHECK64
-#
-# CHECK64: --- !XCOFF
-# CHECK64-NEXT: FileHeader:
-# CHECK64-NEXT: MagicNumber: 0x1F7
-# CHECK64-NEXT: NumberOfSections: 0
-# CHECK64-NEXT: CreationTime: 0
-# CHECK64-NEXT: OffsetToSymbolTable: 0x18
-# CHECK64-NEXT: EntriesInSymbolTable: 10
-# CHECK64-NEXT: AuxiliaryHeaderSize: 0
-# CHECK64-NEXT: Flags: 0x0
-# CHECK64-NEXT: Symbols:
-# CHECK64: - Name: .fcn1
-# CHECK64-NEXT: Value: 0x0
-# CHECK64-NEXT: Section: N_UNDEF
-# CHECK64-NEXT: Type: 0x0
-# CHECK64-NEXT: StorageClass: C_EXT
-# CHECK64-NEXT: NumberOfAuxEntries: 1
-# CHECK64-NEXT: AuxEntries:
-# CHECK64-NEXT: - Type: AUX_CSECT
-# CHECK64-NEXT: ParameterHashIndex: 0
-# CHECK64-NEXT: TypeChkSectNum: 0
-# CHECK64-NEXT: SymbolType: XTY_SD
-# CHECK64-NEXT: SymbolAlignment: 4
-# CHECK64-NEXT: StorageMappingClass: XMC_PR
-# CHECK64-NEXT: SectionOrLengthLo: 4
-# CHECK64: - Name: .fcn2
-# CHECK64-NEXT: Value: 0x0
-# CHECK64-NEXT: Section: N_UNDEF
-# CHECK64-NEXT: Type: 0x0
-# CHECK64-NEXT: StorageClass: C_EXT
-# CHECK64-NEXT: NumberOfAuxEntries: 1
-# CHECK64-NEXT: AuxEntries:
-# CHECK64-NEXT: - Type: AUX_CSECT
-# CHECK64-NEXT: ParameterHashIndex: 0
-# CHECK64-NEXT: TypeChkSectNum: 0
-# CHECK64-NEXT: SymbolType: XTY_SD
-# CHECK64-NEXT: SymbolAlignment: 2
-# CHECK64-NEXT: StorageMappingClass: XMC_PR
-# CHECK64-NEXT: SectionOrLengthLo: 4
-# CHECK64: - Name: .fcn3
-# CHECK64-NEXT: Value: 0x0
-# CHECK64-NEXT: Section: N_UNDEF
-# CHECK64-NEXT: Type: 0x0
-# CHECK64-NEXT: StorageClass: C_EXT
-# CHECK64-NEXT: NumberOfAuxEntries: 1
-# CHECK64-NEXT: AuxEntries:
-# CHECK64-NEXT: - Type: AUX_CSECT
-# CHECK64-NEXT: ParameterHashIndex: 0
-# CHECK64-NEXT: TypeChkSectNum: 0
-# CHECK64-NEXT: SymbolType: XTY_SD
-# CHECK64-NEXT: SymbolAlignment: 0
-# CHECK64-NEXT: StorageMappingClass: XMC_PR
-# CHECK64-NEXT: SectionOrLengthLo: 4
-# CHECK64: - Name: .fcn4
-# CHECK64-NEXT: Value: 0x0
-# CHECK64-NEXT: Section: N_UNDEF
-# CHECK64-NEXT: Type: 0x0
-# CHECK64-NEXT: StorageClass: C_EXT
-# CHECK64-NEXT: NumberOfAuxEntries: 1
-# CHECK64-NEXT: AuxEntries:
-# CHECK64-NEXT: - Type: AUX_CSECT
-# CHECK64-NEXT: ParameterHashIndex: 0
-# CHECK64-NEXT: TypeChkSectNum: 0
-# CHECK64-NEXT: SymbolType: XTY_ER
-# CHECK64-NEXT: SymbolAlignment: 5
-# CHECK64-NEXT: StorageMappingClass: XMC_PR
-# CHECK64-NEXT: SectionOrLengthLo: 4
+## Ensure that SymbolAlignment is in range.
+# RUN: not yaml2obj %s --docnum=2 -o %t 2>&1 | FileCheck %s --check-prefix=ERROR1
+# ERROR1: symbol alignment must be less than 32
----------------
jh7370 wrote:
Nit: add a blank line between the check pattern and yaml.
https://github.com/llvm/llvm-project/pull/76828
More information about the llvm-commits
mailing list