Generating Header Files from Object Files
Is it possible to take an object file (like a macintosh dylib or a linux .so file), and autom开发者_如何学Pythonatically generate a C .h file?
No. The object file basically contains a mapping (that you can display with a command such as nm
) from symbol names to addresses, but there is absolutely no type information.
I'm simplifying a bit (some symbols are used but not defined in the object file, others are defined there), but the answer is still no.
As an example, here is the result of nm a.out
on whatever random file I last compiled :)
The example is so small that the gcc builtins outnumber the symbols I defined myself. But no type information...
$ nm a.out
0000200c D _NXArgc
00002008 D _NXArgv
00002000 D ___progname
00001fbc t __dyld_func_lookup
00001000 A __mh_execute_header
00002004 D _environ
U _exit
00001fca T _main
U _rand
00002030 S _x
00002010 d dyld__mach_header
00001fa8 t dyld_stub_binding_helper
00001f68 T start
精彩评论