From 9bcc8fdd4eecb665ea98a38e3fa03b889663922a Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 9 Dec 2025 22:41:52 +0800 Subject: improve readsyms --- xmake/modules/utils/binary/readsyms.lua | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'xmake/modules/utils/binary/readsyms.lua') 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 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 -- cgit v1.3.1