diff options
| author | ruki <[email protected]> | 2024-05-19 22:35:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-05-19 22:35:52 +0800 |
| commit | 582e9e5e8c6215f01818bf767c5379e2cdbe861a (patch) | |
| tree | 891380e422a01911d2a7aaa87345b1686a205691 | |
| parent | a5cf8c2bb716632c27f75aff173d1684ea5c679b (diff) | |
use objdump to dump symbols
| -rw-r--r-- | xmake/rules/utils/symbols/export_all/export_all.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/xmake/rules/utils/symbols/export_all/export_all.lua b/xmake/rules/utils/symbols/export_all/export_all.lua index b67a415c8..e172b56cb 100644 --- a/xmake/rules/utils/symbols/export_all/export_all.lua +++ b/xmake/rules/utils/symbols/export_all/export_all.lua @@ -64,6 +64,22 @@ function _get_allsymbols_by_dumpbin(target, dumpbin, opt) return allsymbols end +-- use objdump to get all symbols from object files +function _get_allsymbols_by_objdump(target, objdump, opt) + opt = opt or {} + local allsymbols = hashset.new() + local export_classes = opt.export_classes + for _, objectfile in ipairs(target:objectfiles()) do + local objectsymbols = try { function () return os.iorunv(objdump, {"--syms", objectfile}) end } + if objectsymbols then + for _, line in ipairs(objectsymbols:split('\n', {plain = true})) do + print(line) + end + end + end + return allsymbols +end + -- export all symbols for dynamic library function main(target, opt) @@ -90,6 +106,9 @@ function main(target, opt) if msvc:check() then local dumpbin = assert(find_tool("dumpbin", {envs = msvc:runenvs()}), "dumpbin not found!") allsymbols = _get_allsymbols_by_dumpbin(target, dumpbin.program, {export_classes = export_classes}) + elseif target:has_tool("cc", "clang", "clang_cl", "clangxx") then + local objdump = assert(find_tool("llvm-objdump") or find_tool("objdump"), "objdump not found!") + allsymbols = _get_allsymbols_by_dumpbin(target, objdump.program, {export_classes = export_classes}) end -- export all symbols |
