You copied the Doc URL to your clipboard.

Linker support for creating demand-paged files

The linker provides features for you to create files that are memory mapped.

In operating systems that support virtual memory, an ELF file can be loaded by mapping the ELF files into the address space of the process loading the file. When a virtual address in a page that is mapped to the file is accessed, the operating system loads that page from disk. ELF files that are to be used this way must conform to a certain format.

Use the --paged command-line option to enable demand paging mode. This helps produce ELF files that can be demand paged efficiently.

The basic constraints for a demand-paged ELF file are:

  • There is no difference between the load and execution address for any output section.

  • All PT_LOAD Program Headers have a minimum alignment, pt_align, of the page size for the operating system.

  • All PT_LOAD Program Headers have a file offset, pt_offset, that is congruent to the virtual address (pt_addr) modulo pt_align.

When you specify --paged:

  • The linker automatically generates the Program Headers from the execution region base addresses. The usual situation where one load region generates one Program Header no longer applies.

  • The operating system page size is controlled by the --pagesize command-line option.

  • The linker attempts to place the ELF Header and Program Header in the first PT_LOAD program header, if space is available.


This is an example of a demand paged scatter file:

LR1 GetPageSize() + SizeOfHeaders()
    ER_RO +0
    ER_RW +GetPageSize()
    ER_ZI +0