Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

interpreting gcc map file

Tags:

gcc

I need to find the code size for a library developed using C on linux. I have generated the map file using the gcc linker options against a sample application that uses this library.

The map file is quite exhaustive. How do I find out the code size of the library from the map file? any pointers to any documentation on how to interpret the map file would also be very useful.

like image 682
sthustfo Avatar asked Sep 02 '10 17:09

sthustfo


1 Answers

You want to find out the size of the machine instructions in a given shared object? Why do you need the map file?

This gives the size of the .text section. The .text section is where executable code is stored:

$ objdump  -x /usr/bin/objdump | grep .text
 13 .text         0002c218  0000000000403320  0000000000403320  00003320  2**4

In this example, there are 2c218 bytes of executable text. In decimal this is about 180 KiB:

$ printf %d\\n 0x2c218
180760

Edit: This is how it looks like with a library:

$ objdump -x /usr/lib/libcairo.so | grep .text
 11 .text         00054c18  000000000000cc80  000000000000cc80  0000cc80  2**4
$ printf %d\\n 0x54c18
347160
like image 144
Uli Schlachter Avatar answered Oct 06 '22 11:10

Uli Schlachter