Why is half of my compiled (small) objective-C file a large block of zeroes?

file-format, objective-c

Solution

It's most likely padding between code, data, relocation or other sections of the executable format you use.

Linkers like to pad such sections on a 4k or 8k boundary. This improves loading time for the price of a bit of memory-waste.

For a simple hello world it's significant, but for a large application the extra memory used for the padding is neglible.

Problem

I opened up my compiled Hello World Obj-C application in a text editor and, to my surprise, I found about 8 kilobytes of 00 00 00 00 00 00 00 00 .... Why are these here? Is there a way to clear out these zeroes (which I doubt have too much function)? Obviously it's not so important in this file, seeing as it's only 16kB to begin with, but I'd like to know anyway.

Original source