[PATCH] D113104: add the xcoff symbol size for the llvm-nm.
Digger Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 19 11:37:06 PST 2021
DiggerLin updated this revision to Diff 388582.
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
@@ -1694,6 +1694,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,23 @@
+## Test llvm-nm for XCOFF object files with --print-size option.
+# RUN: llvm-nm --print-size %p/Inputs/test_xlclang.o | FileCheck --check-prefix=NM-SIZE %s
+
+## test_xlclang.o is generated by the following source compiled with IBM xlclang++ in aix os.
+## int value = 0;
+##
+## __attribute__ ((weak)) int weak_value = 5;
+##
+## static int func0 () {
+## return value;
+## }
+##
+## int func1 (int i) {
+## return func0() * i;
+## }
+
+# NM-SIZE: 0000104 00000004 d _Z5func1i
+# NM-SIZE-NEXT: 0000010c 0000000c D _Z5func1i
+# NM-SIZE-NEXT: 00000100 00000004 d value
+# NM-SIZE-NEXT: 00000118 00000004 D value
+# NM-SIZE-NEXT: 00000108 00000004 d weak_value
+# NM-SIZE-NEXT: 0000011c 00000004 W weak_value
+~
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113104.388582.patch
Type: text/x-patch
Size: 1540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211119/1a0af21d/attachment.bin>
More information about the llvm-commits
mailing list