The short answer is that it isn’t an arbitrary “magic number” but a consequence of the SPARC ABI’s alignment and loading conventions. In the System V ABI for SPARC, the text (code) segment is normally mapped at virtual address 0x10000 (which is 64 KB), and ELF’s file‐layout rules require that for any loadable segment the file offset and the virtual address have the same remainder modulo the segment’s alignment (the p_align field). Since the text segment is given an alignment of 0x10000, its file offset must also be 0x10000—that is, 64 KB.
Here’s a bit more detail:
-
ELF Mapping Requirement:
In ELF, each program header (the “segment”) specifies both a file offset (p_offset) and a desired virtual memory address (p_vaddr). One of the ELF requirements is that:
[
\text{(p_offset mod p_align)} = \text{(p_vaddr mod p_align)}
]
For SPARC executables, the text segment is usually set up with a p_vaddr starting at 0x10000 and a p_align of 0x10000. To satisfy the condition above, the file offset p_offset must then also be 0x10000 (64 KB).
-
ABIs and Historical Reasons:
The choice of having the text segment begin at 64 KB in memory (and therefore in the file) is part of the historical design of SPARC system implementations. It helps with things like:
- Reserved Low Addresses: Often the lowest portion of the address space is reserved for things such as exception vectors or other system-level information.
- Linking and Relocation: By having the text segment start at a well‐defined, 64 KB–aligned address, the runtime linker and loader can simplify relocation and position–independent code handling.
- Performance and Hardware Constraints: Alignment at large boundaries (like 64 KB) can sometimes benefit performance, cache behavior, or adhere to hardware page mapping constraints on some SPARC systems.
-
Impact on the File Layout:
Although it might look “wasteful” to have a large hole (the first 64 KB, which is not used for actual code) at the beginning of the ELF file, this arrangement ensures that when the segment is loaded into memory the mapping has the correct alignment and address. It’s a design trade–off dictated by the ABI and the need for consistency across tools (assembler, linker, loader, etc.).
In summary, the 64 KB offset from the beginning of the ELF file to the text section is a direct consequence of enforcing the alignment rules required by the SPARC ABI, ensuring that the text segment is loaded at the proper, 64 KB–aligned virtual address.