Skip to content

Mach-O Reference

LC_SEGMENT_64

LC_SEGMENT_64 — segments and sections

LC_SEGMENT_64 describes a region of the file to map into memory — __TEXT, __DATA, __LINKEDIT — together with the sections inside it and the protections the segment is mapped with.

What it describes

An LC_SEGMENT_64 load command maps a contiguous region of the file into a contiguous region of memory. A typical executable has a handful:

  • __TEXT — read-only, executable: machine code and constants.
  • __DATA / __DATA_CONST — writable (or initialized-then-protected) data.
  • __LINKEDIT — the tables dyld needs (symbols, signatures, bind info).

Key fields

FieldMeaning
segnameThe 16-byte segment name (__TEXT).
vmaddr / vmsizeWhere and how large the segment is in memory.
fileoff / filesizeWhere its bytes live in the file.
maxprot / initprotMaximum and initial memory protections (r/w/x).
nsectsNumber of sections that follow this command.

Sections

Right after the segment command come nsects section records. A section is a named subdivision of a segment — __TEXT,__text (the code itself), __TEXT,__cstring (C string literals), __DATA,__objc_classlist, and so on. Each section record gives the section's own address, size, file offset and alignment.

The split matters for analysis: the segment sets the memory protection a region is mapped with (so __TEXT is non-writable), while sections tell you what each part of that region actually contains.