в спеке mach-o
1. The static linker creates a __PAGEZERO segment as the first segment of an executable file. This segment is located at virtual memory location zero and has no protection rights assigned, the combination of which causes accesses to NULL, a common C programming error, to immediately crash. The __PAGEZERO segment is the size of one full VM page for the current CPU architecture (for x86 and PowerPC, this is 4096 bytes or 0x1000 in hexadecimal). Because there is no data in the __PAGEZERO segment, it occupies no space in the file (the file size in the segment command is zero).
Field Descriptions
2. vmsize
Indicates the number of bytes of virtual memory occupied by this segment. See also the description of filesize, below.
3. filesize
Indicates the number of bytes occupied by this segment on disk. For segments that require more memory at runtime than they do at build time, vmsize can be larger than filesize. For example, the __PAGEZERO segment generated by the linker for MH_EXECUTABLE files has a vmsize of 0x1000 but a filesize of zero. Because __PAGEZERO contains no data, there is no need for it to occupy any space until runtime. Also, the static linker often allocates uninitialized data at the end of the __DATA segment; in this case, the vmsize is larger than the filesize.
The loader guarantees that any memory of this sort is initialized with zeros.
если сделать: otool -lv app, там можно найти:
segname __PAGEZERO
vmaddr 0x0000000000000000
vmsize 0x0000000100000000
fileoff 0
filesize 0
Все логично, подходит по спеке.
Размер файла на диске 12кб (ок, 3 pagesize’а)
Сам размер файла 8300+ байт, если открывать средствами не какого-нибудь hexdump, а средствами с++ или саблаймом тем же.
это при чтении файла fs распознает формат и отдает лишние 0? Нелогичено для меня, почему тогда размер на диске учитывает эти 0