--- /dev/null
+## Test llvm-nm for XCOFF object files with --print-size option.
+
+# RUN: yaml2obj %s -o %t.o
+# RUN: llvm-nm --print-size %t.o | FileCheck --match-full-lines %s
+
+--- !XCOFF
+FileHeader:
+ MagicNumber: 0x1DF
+Sections:
+ - Name: .text
+ Flags: [ STYP_TEXT ]
+ - Name: .data
+ Flags: [ STYP_DATA ]
+ - Name: .bss
+ Flags: [ STYP_BSS ]
+Symbols:
+ - Name: ._ZL5func0v
+ Section: .text
+ StorageClass: C_EXT
+ Type: 0x20
+ AuxEntries:
+ - Type: AUX_CSECT
+ SymbolAlignmentAndType: 0x02
+ StorageMappingClass: XMC_PR
+ - Name: val
+ Value: 0x200
+ Section: .data
+ StorageClass: C_EXT
+ Type: 0x20
+ AuxEntries:
+ - Type: AUX_CSECT
+ SymbolAlignmentAndType: 0x01
+ StorageMappingClass: XMC_RW
+ SectionOrLength: 0x8
+ - Name: comval
+ Section: .bss
+ Value: 0x13C
+ StorageClass: C_EXT
+ Type: 0x00
+ AuxEntries:
+ - Type: AUX_CSECT
+ SymbolAlignmentAndType: 0x03
+ StorageMappingClass: XMC_RW
+ SectionOrLength: 0x4
+
+## Label symbol.
+# CHECK: 00000000 00000000 T ._ZL5func0v
+## Common symbol.
+# CHECK-NEXT: 0000013c 00000004 C comval
+## SD symbol.
+# CHECK-NEXT: 00000200 00000008 D val
S.Address = 0;
if (isa<ELFObjectFileBase>(&Obj))
S.Size = ELFSymbolRef(Sym).getSize();
+
+ if (const XCOFFObjectFile *XCOFFObj =
+ dyn_cast<const XCOFFObjectFile>(&Obj))
+ S.Size = XCOFFObj->getSymbolSize(Sym.getRawDataRefImpl());
+
if (PrintAddress && isa<ObjectFile>(Obj)) {
SymbolRef SymRef(Sym);
Expected<uint64_t> AddressOrErr = SymRef.getAddress();