Skip to content

Commit 582e9e5

Browse files
committed
use objdump to dump symbols
1 parent a5cf8c2 commit 582e9e5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

xmake/rules/utils/symbols/export_all/export_all.lua

+19
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ function _get_allsymbols_by_dumpbin(target, dumpbin, opt)
6464
return allsymbols
6565
end
6666

67+
-- use objdump to get all symbols from object files
68+
function _get_allsymbols_by_objdump(target, objdump, opt)
69+
opt = opt or {}
70+
local allsymbols = hashset.new()
71+
local export_classes = opt.export_classes
72+
for _, objectfile in ipairs(target:objectfiles()) do
73+
local objectsymbols = try { function () return os.iorunv(objdump, {"--syms", objectfile}) end }
74+
if objectsymbols then
75+
for _, line in ipairs(objectsymbols:split('\n', {plain = true})) do
76+
print(line)
77+
end
78+
end
79+
end
80+
return allsymbols
81+
end
82+
6783
-- export all symbols for dynamic library
6884
function main(target, opt)
6985

@@ -90,6 +106,9 @@ function main(target, opt)
90106
if msvc:check() then
91107
local dumpbin = assert(find_tool("dumpbin", {envs = msvc:runenvs()}), "dumpbin not found!")
92108
allsymbols = _get_allsymbols_by_dumpbin(target, dumpbin.program, {export_classes = export_classes})
109+
elseif target:has_tool("cc", "clang", "clang_cl", "clangxx") then
110+
local objdump = assert(find_tool("llvm-objdump") or find_tool("objdump"), "objdump not found!")
111+
allsymbols = _get_allsymbols_by_dumpbin(target, objdump.program, {export_classes = export_classes})
93112
end
94113

95114
-- export all symbols

0 commit comments

Comments
 (0)