Executable files typically contain a code segment and at least one data segment. I assume that each one has a standard minimum size, which can be 8K. And unused space is filled with zeros. Also note that an EXE written at a higher level (than an assembly) contains some additional material on top of the direct translation of your own code and data:
- start and end code (in C and its successors, this processes the input arguments, calls
main() , and then clears after exiting main() ) - stub code and data (for example, Windows executables contain a small stub for a DOS program whose sole purpose is to display the message "This program does not run in DOS").
However, since executables usually have to do something (i.e. their code and data segment contain useful stuff), and the storage is cheap, by default no one will optimize your case :-)
However, I believe that most compilers have command line options with which you can get them to optimize the space - you can check the results with this option.
Here is more detailed information on EXE file formats .
source share