@@ -64,6 +64,22 @@ function _get_allsymbols_by_dumpbin(target, dumpbin, opt)
64
64
return allsymbols
65
65
end
66
66
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
+
67
83
-- export all symbols for dynamic library
68
84
function main (target , opt )
69
85
@@ -90,6 +106,9 @@ function main(target, opt)
90
106
if msvc :check () then
91
107
local dumpbin = assert (find_tool (" dumpbin" , {envs = msvc :runenvs ()}), " dumpbin not found!" )
92
108
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 })
93
112
end
94
113
95
114
-- export all symbols
0 commit comments