Typically, a .a library is simply an archive that itself contains a bunch of object files. These commands are executed on Linux; they will vary between platforms. You can usually view the main contents of the archive by running nm libxxx.a
/usr/lib> nm libc.a | head -10 init-first.o: U abort U _dl_non_dynamic_init 0000000000000000 T _dl_start w _dl_starting_up U __environ U __fpu_control U __init_misc 0000000000000004 C __libc_argc
The nm man page has many details on what exit means.
The ar command can extract individual files for you, for example.
~/tmp> ar x libc.a init-first.o ~/tmp> file init-first.o init-first.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
As you can see above, the objects here are the ELF format, so for the complex bit of what you are asking, you really need something that can learn the ELF binaries. Linux usually comes with the readelf command, which will give a lot of information on the command line:
~/tmp> readelf -s init-first.o Symbol table '.symtab' contains 19 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000000 0 SECTION LOCAL DEFAULT 1 2: 00000000 0 SECTION LOCAL DEFAULT 3 3: 00000000 0 SECTION LOCAL DEFAULT 4 4: 00000000 0 SECTION LOCAL DEFAULT 5 5: 00000000 0 SECTION LOCAL DEFAULT 6 6: 00000000 11 FUNC GLOBAL DEFAULT 1 _dl_start 7: 00000000 0 NOTYPE GLOBAL DEFAULT UND abort 8: 00000010 133 FUNC GLOBAL DEFAULT 1 __libc_init_first 9: 00000000 0 NOTYPE WEAK DEFAULT UND _dl_starting_up ...
There is a libelf library that very likely does what you want and accesses this information programmatically. I never used it, since I always got the necessary information from the available command line tools.
http://directory.fsf.org/wiki/Libelf
source share