summaryrefslogtreecommitdiff
path: root/xmake/rules
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-11 23:42:48 +0800
committerruki <[email protected]>2025-12-12 09:00:44 +0800
commit65b4b2932a7c2fd6dab3fe60597055d1440bddc5 (patch)
tree440e1f56021740a82f79cb6ebac277645f7cf91c /xmake/rules
parentb0eb30a4becb5b6d925aa77418ce30c7f1f79d69 (diff)
improve readsyms
Diffstat (limited to 'xmake/rules')
-rw-r--r--xmake/rules/utils/symbols/export_all/export_all.lua62
1 files changed, 31 insertions, 31 deletions
diff --git a/xmake/rules/utils/symbols/export_all/export_all.lua b/xmake/rules/utils/symbols/export_all/export_all.lua
index 6e077aaf3..fa75038d1 100644
--- a/xmake/rules/utils/symbols/export_all/export_all.lua
+++ b/xmake/rules/utils/symbols/export_all/export_all.lua
@@ -158,38 +158,38 @@ function _get_allsymbols_by_readsyms(target, opt)
_get_sourcefiles_map(target, sourcefiles_map)
end
local objectfiles = target:objectfiles()
- local symbols = readsyms(objectfiles)
- if symbols then
- for _, sym in ipairs(symbols) do
- if sym.name and sym.type then
- -- only export function symbols (T/t) for DLL exports
- -- skip data (D/d), bss (B/b), other sections (S/s), and undefined (U) symbols
- if sym.type == "T" or sym.type == "t" then
- local symbol = sym.name
- -- we need ignore DllMain, https://github.com/xmake-io/xmake/issues/3992
- if target:is_arch("x86") and symbol:startswith("_") and not symbol:startswith("__") and not symbol:startswith("_DllMain@") then
- symbol = symbol:sub(2)
- end
- if export_filter then
- -- find sourcefile for this symbol (approximate match)
- local sourcefile = nil
- for objfile, srcfile in pairs(sourcefiles_map) do
- if objfile:find(path.basename(symbol), 1, true) then
- sourcefile = srcfile
- break
- end
- end
- if export_filter(symbol, {sourcefile = sourcefile}) then
- allsymbols:insert(symbol)
- end
- elseif not symbol:startswith("__") then
- if export_classes or not symbol:startswith("?") then
- if export_classes then
- if not symbol:startswith("??_G") and not symbol:startswith("??_E") then
- allsymbols:insert(symbol)
+ for _, objectfile in ipairs(objectfiles) do
+ local objects = readsyms(objectfile)
+ if objects then
+ local sourcefile = sourcefiles_map[objectfile]
+ for _, obj in ipairs(objects) do
+ local symbols = obj.symbols
+ if symbols then
+ for _, sym in ipairs(symbols) do
+ if sym.name and sym.type then
+ -- only export function symbols (T/t) for DLL exports
+ -- skip data (D/d), bss (B/b), other sections (S/s), and undefined (U) symbols
+ if sym.type == "T" or sym.type == "t" then
+ local symbol = sym.name
+ -- we need ignore DllMain, https://github.com/xmake-io/xmake/issues/3992
+ if target:is_arch("x86") and symbol:startswith("_") and not symbol:startswith("__") and not symbol:startswith("_DllMain@") then
+ symbol = symbol:sub(2)
+ end
+ if export_filter then
+ if export_filter(symbol, {sourcefile = sourcefile}) then
+ allsymbols:insert(symbol)
+ end
+ elseif not symbol:startswith("__") then
+ if export_classes or not symbol:startswith("?") then
+ if export_classes then
+ if not symbol:startswith("??_G") and not symbol:startswith("??_E") then
+ allsymbols:insert(symbol)
+ end
+ else
+ allsymbols:insert(symbol)
+ end
+ end
end
- else
- allsymbols:insert(symbol)
end
end
end