Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc compiled binaries w/different sizes?

Tags:

c++

linux

gcc

elf

If the same code is built at different times w/gcc, the resulting binary will have different contents. OK, I'm not wild about that, but that's what it is.

However, I've recently run into a situation where the same code, built with the same version of gcc, is generating a binary with a different size than a prior build (by about 1900 bytes).

Does anyone have any idea what may be causing either of these situations? Is this some kind of ELF issue? Are there any tools out there (other than ldd) that can be used to dump contents of binaries to see what exactly is different?

Thanks in advance.

like image 663
BillTorpey Avatar asked Aug 14 '09 13:08

BillTorpey


1 Answers

I've managed to sort things out, at least to my satisfaction, and wanted to pass along what I've found.

Using readelf, (readelf -a -W ) I created a report listing contents of both builds and compared them (using Beyond Compare). This showed that a couple of extra symbols were getting pulled in from boost libs.

Lo and behold, we were in fact building against a different version of a dependent library and didn't realize it. No harm done in this case, but it's good to know what's going into your executable.

Thanks to all for the thoughtful replies.

like image 177
BillTorpey Avatar answered Sep 25 '22 15:09

BillTorpey