Is it possible to take an object file (like a macintosh dylib or a linux .so file), and automatically generate a C .h file?
+1
A:
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
Pascal Cuoq
2010-05-27 20:20:06
This is not true if it is compiled with debugging symbols. libbfd may be able to read it, or you may be able to get a library for whatever debugging format you're using.
Tim Schaeffer
2010-05-27 20:39:29
@Tim But the arguments to functions would still be a mystery to you.
joveha
2010-05-28 13:04:10