[PATCH] D113104: add the xcoff symbol size for the llvm-nm.
Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 11 13:25:07 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4372e629a9a9: [AIX] add the xcoff symbol size for the llvm-nm. (authored by zhijian <zhijian at ca.ibm.com>).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113104/new/
https://reviews.llvm.org/D113104
Files:
llvm/test/tools/llvm-nm/XCOFF/size.test
llvm/tools/llvm-nm/llvm-nm.cpp
Index: llvm/tools/llvm-nm/llvm-nm.cpp
===================================================================
--- llvm/tools/llvm-nm/llvm-nm.cpp
+++ llvm/tools/llvm-nm/llvm-nm.cpp
@@ -1687,6 +1687,11 @@
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();
Index: llvm/test/tools/llvm-nm/XCOFF/size.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-nm/XCOFF/size.test
@@ -0,0 +1,51 @@
+## 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113104.399058.patch
Type: text/x-patch
Size: 2279 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220111/cef89e95/attachment.bin>
More information about the llvm-commits
mailing list