Logo
Articles Compilers Libraries Books MiniBooklets Assembly C++ Linux Others Videos
Advertisement

Article by Ayman Alheraki on January 11 2026 10:38 AM

Executable Headers Across Operating Systems Full Technical Specifications for Windows, Linux, macOS, Android, and iOS

Executable Headers Across Operating Systems: Full Technical Specifications for Windows, Linux, macOS, Android, and iOS

Executable headers are crucial structures in program files that instruct an operating system how to load, link, and execute a program. Each OS uses its own format, and understanding these headers is essential for developers building cross-platform tools, compilers, loaders, or reverse engineering utilities.

This article provides full header specifications, practical C/C++ struct examples, and explains the purpose and fields of each header type.

1. Windows: PE (Portable Executable)

  • Extension: .exe

  • Structure: MS-DOS Header → PE Signature → COFF File Header → Optional Header → Section Headers → Code/Data Sections

Full Header Specifications

1.1 DOS Header (IMAGE_DOS_HEADER)

  • Purpose: Allows old DOS programs to display a message and identifies the file as PE.

  • Key Field: e_lfanew → offset to PE header.

1.2 PE Header (IMAGE_NT_HEADERS64)

  • Signature: "PE\0\0"

  • Includes: COFF File Header + Optional Header

1.3 COFF File Header (IMAGE_FILE_HEADER)

  • Fields:

    • Machine → target CPU (e.g., x86/x64)

    • NumberOfSections

    • TimeDateStamp

    • PointerToSymbolTable

    • NumberOfSymbols

    • SizeOfOptionalHeader

    • Characteristics

1.4 Optional Header (IMAGE_OPTIONAL_HEADER64)

  • Fields:

    • Magic → PE32+ (0x20b)

    • AddressOfEntryPoint

    • ImageBase

    • SectionAlignment

    • FileAlignment

    • SizeOfImage

    • DataDirectories → export/import/debug/relocations

1.5 Section Headers (IMAGE_SECTION_HEADER)

  • Fields:

    • Name → e.g., .text, .data

    • VirtualAddress

    • SizeOfRawData

    • PointerToRawData

    • Characteristics → read/write/execute

2. Linux: ELF (Executable and Linkable Format)

  • Extension: None

  • Structure: ELF Header → Program Header Table → Section Header Table → Sections

Full Header Specifications

2.1 ELF Header (Elf64_Ehdr)

  • Purpose: Identifies ELF file and provides offsets.

  • Fields:

    • e_ident[16] → magic number and class

    • e_type → executable, shared object, relocatable

    • e_machine → CPU type

    • e_entry → entry point virtual address

    • e_phoff → program header table offset

    • e_shoff → section header table offset

2.2 Program Header (Elf64_Phdr)

  • Purpose: Defines segments for execution

  • Fields:

    • p_type → load, dynamic, interpreter

    • p_offset → file offset

    • p_vaddr → virtual address

    • p_memsz → memory size

2.3 Section Header (Elf64_Shdr)

  • Purpose: Defines sections used in linking/relocation.

  • Fields:

    • sh_name

    • sh_type

    • sh_flags

    • sh_addr

    • sh_offset

    • sh_size

3. macOS / iOS: Mach-O

  • Extension: None

  • Structure: Mach-O Header → Load Commands → Segments → Sections

Full Header Specifications

3.1 Mach-O Header (mach_header_64)

  • Fields:

    • magic0xfeedfacf for 64-bit

    • cputype, cpusubtype

    • filetype

    • ncmds, sizeofcmds

    • flags, reserved

3.2 Load Command (load_command)

  • Fields:

    • cmd → type of command

    • cmdsize → total size including data

3.3 Segment Command 64 (segment_command_64)

  • Fields:

    • segname[16]

    • vmaddr, vmsize

    • fileoff, filesize

    • maxprot, initprot

    • nsects, flags

4. Android: APK (ZIP Archive)

  • Extension: .apk

  • Structure: ZIP Archive → AndroidManifest.xml, classes.dex, resources.arsc, assets

Full Header Specifications

4.1 ZIP Local File Header

  • Fields:

    • signature0x04034b50

    • version_needed

    • general_purpose

    • compression_method

    • crc32, compressed_size, uncompressed_size

    • filename_length, extra_field_length

  • APK Contents:

    • AndroidManifest.xml → app components & permissions

    • classes.dex → compiled bytecode

    • resources.arsc → binary resources

    • META-INF/ → signatures

Comparison Table

OSHeader FormatExtension32-bit64-bitDigital SignatureCross-platform
WindowsPE.exeYesYesYesLimited
LinuxELFNoneYesYesYesWide
macOS/iOSMach-ONoneYesYesYesLimited
AndroidAPK.apkYesYesYesLimited

Conclusion

Executable headers vary widely across operating systems. Understanding their full technical structure enables:

  • Writing cross-platform loaders

  • Developing debuggers and reverse engineering tools

  • Creating compiler backends and binary utilities

  • Windows PE: optimized for Windows and DLLs.

  • Linux ELF: flexible and widely supported.

  • macOS/iOS Mach-O: supports multi-architecture binaries.

  • Android APK: ZIP-based, optimized for Java/Dalvik execution.

Advertisements

Responsive Counter
General Counter
1000760
Daily Counter
2380