I've compiled a C file that does absolutely nothing (just a main
that returns... not even a "Hello, world" gets printed), and I've compiled it with various compilers (MinGW GCC, Visual C++, Windows DDK, etc.). All of them link with the C runtime, which is standard.
But what I don't get is: When I open up the file in a hex editor (or a disassembler), why do I see that almost half of the 16 KB is just huge sections of either 0x00 bytes or 0xCC bytes? It seems rather ridiculous to me... is there any way to prevent these from occurring? And why are they there in the first place?
Thank you!
Follow these steps to fix and recover a 0 byte file. Open the Run dialog box by pressing Win and R keys together. At the Command Prompt, type "chkdsk /f e:", where e is the name of the storage device or partition of the hard drive that holds the 0 byte file.
A zero bytes file can be caused by many different reasons, which can fall into 2 main situtaions. Hard drives run the risk of corruption and can lose data for a number of different reasons. This can cause your important files to become 0 byte files.
Most notably :, a POSIX required null utility. But you also require that it is an external file. So: the POSIX standard specified dummy executable files that do nothing could be: printf '' # requires a format. The format may be empty. test 1 # requires a non-empty string (or number).
A zero-byte file means that there is no data being stored in the file and the length of the file also becomes zero. In other words, the file contains no content that can be written and read.
Executables in general contain a code segment and at least one data segment. I guess each of these has a standard minimum size, which may be 8K. And unused space is filled up with zeros. Note also that an EXE written in a higher level (than assembly) language contains some extra stuff on top of the direct translation of your own code and data:
main()
, then cleans up after exiting from main()
)Still, since executables are usually supposed to do something (i.e. their code and data segment(s) do contain useful stuff), and storage is cheap, by default noone optimizes for your case :-)
However, I believe most of the compilers have command line parameters with which you can force them to optimize for space - you may want to check the results with that setting.
Here is more details on the EXE file formats.
As it turns out, I should've been able to guess this beforehand... the answer was the debug symbols and code; those were taking up most of the space. Not compiling with /DEBUG and /PDB (which I always do by default) reduced the 13 K down to 3 K.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With