-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[llvm-nm][WebAssembly] Print function symbol sizes #81315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
nm already prints sizes for data symbols. Do that for function symbols too.
@llvm/pr-subscribers-mc @llvm/pr-subscribers-llvm-binary-utilities Author: Derek Schuff (dschuff) Changesnm already prints sizes for data symbols. Do that for function symbols too. Full diff: https://github.com/llvm/llvm-project/pull/81315.diff 3 Files Affected:
diff --git a/llvm/test/tools/llvm-nm/wasm/linked.yaml b/llvm/test/tools/llvm-nm/wasm/linked.yaml
index 992c1811743b7a..6aee4b9fc184c4 100644
--- a/llvm/test/tools/llvm-nm/wasm/linked.yaml
+++ b/llvm/test/tools/llvm-nm/wasm/linked.yaml
@@ -1,10 +1,15 @@
# RUN: yaml2obj %s -o %t.wasm
# RUN: llvm-nm %t.wasm | FileCheck %s
+# RUN: llvm-nm -P %t.wasm | FileCheck %s --check-prefix=POSIX
# CHECK: 0000009f T my_func_export
# CHECK-NEXT: 0000002a D my_global_export
# CHECK-NEXT: 00000000 D my_table_export
+# POSIX: my_func_export T 9f 3
+# POSIX-NEXT: my_global_export D 2a 0
+# POSIX-NEXT: my_table_export D 0 0
+
--- !WASM
FileHeader:
Version: 0x1
diff --git a/llvm/test/tools/llvm-nm/wasm/print-size.test b/llvm/test/tools/llvm-nm/wasm/print-size.test
index c166edb4641c4b..610929b959b5f1 100644
--- a/llvm/test/tools/llvm-nm/wasm/print-size.test
+++ b/llvm/test/tools/llvm-nm/wasm/print-size.test
@@ -43,4 +43,4 @@ Sections:
Size: 32
# CHECK: 00000000 00000020 D a_data_symbol
-# CHECK: 00000001 00000000 T a_func
+# CHECK: 00000001 0000000d T a_func
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index da5998b70ea3f3..51f7e417306cf6 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -1858,6 +1858,11 @@ static bool getSymbolNamesFromObject(SymbolicFile &Obj,
const WasmSymbol &WasmSym = WasmObj->getWasmSymbol(Sym);
if (WasmSym.isTypeData() && !WasmSym.isUndefined())
S.Size = WasmSym.Info.DataRef.Size;
+ if (WasmSym.isTypeFunction() && !WasmSym.isUndefined())
+ S.Size = WasmObj
+ ->functions()[WasmSym.Info.ElementIndex -
+ WasmObj->getNumImportedFunctions()]
+ .Size;
}
if (PrintAddress && isa<ObjectFile>(Obj)) {
|
Actually WDYT of printing the symbol size in |
✅ With the latest revision this PR passed the C/C++ code formatter. |
This seems to have broken some buildbots in a way that didn't reproduce for me locally. I'm investigating and will revert if I don't figure it out soon. |
nm already prints sizes for data symbols. Do that for function symbols too,
and update objdump to also print size information.
Implements item 3 from #76107