binutils Newspaper
JUNE 15, 2026
elf Proposed

elf: Set text-segment address to the maximum page size

This patch sets the text-segment address to the maximum page size for ELF Position Dependent Executables (PDEs) when specified via command-line.

This patch modifies the linker to ensure that the text-segment address of an ELF Position Dependent Executable (PDE) is set to the maximum page size when the -z max-page-size=SIZE option is used. If the default text-segment address is lower than the specified maximum page size, the linker will adjust it. This change is intended to address issue PR ld/34184 and includes a new test case and updates to the test suite.

In Details

The linker's fold_binary function in ldexp.c is modified to adjust the text-segment address for ELF PDEs. This ensures that the text segment is aligned to the maximum page size specified via -z max-page-size. This addresses PR ld/34184 and includes a new test case (testsuite/ld-elf/pr34184.c) and updates to the test suite (testsuite/ld-elf/elf.exp).

For Context

When creating executable files, the linker assigns memory addresses to different parts of the program, including the text segment (containing the program's code). Page size refers to the size of a memory page, which is a unit of memory management used by the operating system. This patch ensures that the starting address of the program's code is aligned to the maximum page size specified during linking. This alignment is important for performance and security reasons. The -z max-page-size option controls the maximum page size used by the linker.

Filed Under: elflinkerpage sizepdealignment