summaryrefslogtreecommitdiff
path: root/xmake/modules/utils/binary
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-09 22:41:52 +0800
committerruki <[email protected]>2025-12-09 22:41:52 +0800
commit9bcc8fdd4eecb665ea98a38e3fa03b889663922a (patch)
treedc44938688fb32c59d87031b8bf1cce5fdfd4c75 /xmake/modules/utils/binary
parent4840a395c687cb90c0821f7ce9b075eaa9160465 (diff)
improve readsyms
Diffstat (limited to 'xmake/modules/utils/binary')
-rw-r--r--xmake/modules/utils/binary/readsyms.lua25
1 files changed, 21 insertions, 4 deletions
diff --git a/xmake/modules/utils/binary/readsyms.lua b/xmake/modules/utils/binary/readsyms.lua
index 6aaa414d0..e5954e92a 100644
--- a/xmake/modules/utils/binary/readsyms.lua
+++ b/xmake/modules/utils/binary/readsyms.lua
@@ -81,11 +81,28 @@ function dump(binaryfile)
end
end
--- read symbols from object file (auto-detect format: ELF, COFF, Mach-O)
+-- read symbols from object file(s) (auto-detect format: ELF, COFF, Mach-O)
--
--- @param binaryfile the object file path (required)
--- @return the symbols table
+-- @param binaryfile the object file path or table of object files (required)
+-- @return the symbols table (all symbols from all files if table is provided)
function main(binaryfile)
- return _get_symbols(binaryfile)
+ assert(binaryfile, "usage: xmake l utils.binary.readsyms <binaryfile> or readsyms(binaryfiles)")
+
+ local all_symbols = {}
+ if type(binaryfile) == "string" then
+ -- single file
+ return _get_symbols(binaryfile)
+ else
+ -- multiple files
+ for _, objectfile in ipairs(binaryfile) do
+ local symbols = _get_symbols(objectfile)
+ if symbols then
+ for _, sym in ipairs(symbols) do
+ table.insert(all_symbols, sym)
+ end
+ end
+ end
+ return all_symbols
+ end
end