We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 18831

11.1 EDK- What is the purpose of the PHDRS section and the HDR lines in a linker script?


What is the purpose of the PHDRS section of a linker script? When do I need it?


The PHDRS section is used in a user-defined linker script to generate program header information in the executable. The linker creates reasonable program headers by default. The following is a brief explanation of PHDRS, including when and how to use them.

PHDRS Description

Program headers are read by the system loader (for Xilinx, data2bram) and describe how the program should be loaded into memory. Program headers define the start address of a memory location and the size that is loadable. If a memory that contains a loadable section (.text, .data...) => followed by an uninitialized section (.bss, .sbss - these do not need to be loaded into memory) => followed by another loadable section (.sdata, .sdata2..), the memory region needs two headers (one for each of the loadable memory chunks). The linker does not generate two headers in this case; consequently, you should use PHDRS.

Note that when the PHDRS command is used, the linker does not generate any program headers.

When and How to Use PHDRS

Linker generates the necessary program headers even if the linker script has multiple memory regions. It is only in the scenario described above that it cannot generate the right headers. To make the linker work correctly for each of the memory regions, define the loadable sections first in the linker script followed by the uninitialized ones. This ensures that the generated header is correct and that the loader functions properly. Use PHDRS only when the mix and match of initialized and uninitialized data for a memory is impossible to avoid.

AR# 18831
Date Created 09/03/2007
Last Updated 12/15/2012
Status Active
Type General Article