@@ -73,7 +73,27 @@ function _get_allsymbols_by_objdump(target, objdump, opt)
73
73
local objectsymbols = try { function () return os .iorunv (objdump , {" --syms" , objectfile }) end }
74
74
if objectsymbols then
75
75
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
77
97
end
78
98
end
79
99
end
@@ -103,12 +123,12 @@ function main(target, opt)
103
123
-- get all symbols
104
124
local allsymbols
105
125
local msvc = toolchain .load (" msvc" , {plat = target :plat (), arch = target :arch ()})
106
- if msvc :check () then
126
+ if false then -- msvc:check() then
107
127
local dumpbin = assert (find_tool (" dumpbin" , {envs = msvc :runenvs ()}), " dumpbin not found!" )
108
128
allsymbols = _get_allsymbols_by_dumpbin (target , dumpbin .program , {export_classes = export_classes })
109
129
elseif target :has_tool (" cc" , " clang" , " clang_cl" , " clangxx" ) then
110
130
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 })
112
132
end
113
133
114
134
-- export all symbols
@@ -125,3 +145,4 @@ function main(target, opt)
125
145
126
146
end , {dependfile = dependfile , files = target :objectfiles (), changed = target :is_rebuilt ()})
127
147
end
148
+
0 commit comments