Skip to content

Commit 3bb68cf

Browse files
committed
dump symbols by objdump
1 parent 582e9e5 commit 3bb68cf

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

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

+24-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,27 @@ function _get_allsymbols_by_objdump(target, objdump, opt)
7373
local objectsymbols = try { function () return os.iorunv(objdump, {"--syms", objectfile}) end }
7474
if objectsymbols then
7575
for _, line in ipairs(objectsymbols:split('\n', {plain = true})) do
76-
print(line)
76+
if line:find("(scl 2)", 1, true) then
77+
local splitinfo = line:split("%s")
78+
local symbol = splitinfo[#splitinfo]
79+
if symbol then
80+
if not symbol:startswith("__") then
81+
-- we need ignore DllMain, https://github.com/xmake-io/xmake/issues/3992
82+
if target:is_arch("x86") and symbol:startswith("_") and not symbol:startswith("_DllMain@") then
83+
symbol = symbol:sub(2)
84+
end
85+
if export_classes or not symbol:startswith("?") then
86+
if export_classes then
87+
if not symbol:startswith("??_G") and not symbol:startswith("??_E") then
88+
allsymbols:insert(symbol)
89+
end
90+
else
91+
allsymbols:insert(symbol)
92+
end
93+
end
94+
end
95+
end
96+
end
7797
end
7898
end
7999
end
@@ -103,12 +123,12 @@ function main(target, opt)
103123
-- get all symbols
104124
local allsymbols
105125
local msvc = toolchain.load("msvc", {plat = target:plat(), arch = target:arch()})
106-
if msvc:check() then
126+
if false then--msvc:check() then
107127
local dumpbin = assert(find_tool("dumpbin", {envs = msvc:runenvs()}), "dumpbin not found!")
108128
allsymbols = _get_allsymbols_by_dumpbin(target, dumpbin.program, {export_classes = export_classes})
109129
elseif target:has_tool("cc", "clang", "clang_cl", "clangxx") then
110130
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})
131+
allsymbols = _get_allsymbols_by_objdump(target, objdump.program, {export_classes = export_classes})
112132
end
113133

114134
-- export all symbols
@@ -125,3 +145,4 @@ function main(target, opt)
125145

126146
end, {dependfile = dependfile, files = target:objectfiles(), changed = target:is_rebuilt()})
127147
end
148+

0 commit comments

Comments
 (0)