I created a file containing the following line:
int main() { return 0; }
After compiling this, I was surprised to find out that the binary for this simple program is 8328 bytes! What is going on here, and what in the world is the binary doing in those 8328 bytes? Surely this program can be expressed in just a few lines of assembly.
Note: I compiled this with the following line:
g++ main.cpp
My g++ version is g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
There’s a lot in that binary:
fileon it)striptool will remove for you (or link withgcc -s)lddandstringstools)argcandargv, then callsmainmain‘s return value to the operating system.For comic effect, try linking that program statically, where your binary will include the functions that would normally be dynamically linked to DLLs. (however, this option will simplify deployment)