Contents of a static library

Viewed 79464

I have a static library, say mystaticlib.a. I want to see its contents, such as the number of object files inside it.

How can I do this on gcc?

5 Answers

It just stumbled over this:

You can open an archive (.a) with 7zip. Also works for the object files in the archive. Listing all sorts of contents like .text, .bss, .data, etc. with their offset, length, type, ... Furthermore its possible to unpack all, using a hex editor or notepad++ to view the contents. I tested this with an archive created with GNUToolsARMEmbedded\2018-q4-major\bin\arm-none-eabi- Toolchain and 7Zip 16.04 (64-bit)

I just discovered that you can use readelf -a to display the contents of all the object files in a static library.

Invoke the readelf command like this: $ readelf -a mystaticlib.a.

Related