3.4 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.

Note:

ELF files produced with the --sysv option are already demand-paged compliant. --arm_linux also implies --sysv.

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.

Example

This is an example of a demand paged scatter file:

LR1 GetPageSize() + SizeOfHeaders()
{
    ER_RO +0
    {
        *(+RO)
    }
    ER_RW +GetPageSize()
    {
        *(+RW)
    }
    ER_ZI +0
    {
        *(+ZI)
    }
}
Non-ConfidentialPDF file icon PDF versionARM DUI0474M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.