Linker Scripts - 2024.2 English

Vitis Unified Software Platform Documentation: Embedded Software Development (UG1400)

Document ID
UG1400
Release Date
2024-11-13
Version
2024.2 English

The linker utility uses commands specified in linker scripts to divide your program on different blocks of memories. It describes the mapping between all of the sections in all of the input object files to output sections in the executable file. The output sections are mapped to memories in the system. You do not need a linker script if you do not want to change the default contiguous assignment of program contents to memory. There is a default linker script provided with the linker that places section contents contiguously.

You can selectively modify only the starting address of your program by defining the linker symbol _TEXT_START_ADDR on MicroBlaze and MicroBlazeâ„¢ -V processors, or START_ADDR on Arm processors, as displayed in this example:

mb-gcc <input files and flags> -Wl,-defsym -Wl,_TEXT_START_ADDR=0x100
mb-ld <.o files> -defsym _TEXT_START_ADDR=0x100

The choices of the default script that are used by the linker from the $XILINX_/gnu/<procname>/<platform>/<processor_name>/lib/ldscripts area are described as follows (where <procname> =microblaze, <processor_name> = microblaze, and <platform> = lin or nt):

  • elf32<procname>.x is used by default when none of the following cases apply.
  • elf32<procname>.xn is used when the linker is invoked with the -n option.
  • elf32<procname>.xbn is used when the linker is invoked with the -N option.
  • elf32<procname>.xr is used when the linker is invoked with the -r option.
  • elf32<procname>.xu is used when the linker is invoked with the -Ur option.

To use a linker script, provide it on the GCC command line. Use the command line option -T <script> for the compiler, as described below:

compiler -T <linker_script> <Other Options and Input Files>

If the linker is executed on its own, include the linker script as follows:

linker -T <linker_script> <Other Options and Input Files>

This tells GCC to use your linker script in the place of the default built-in linker script. Linker scripts can be generated for your program by right clicking the application component and selecting Reset Link Script to generate or reset the linker script..

Linker scripts can be used to assign specific variables or functions to specific memories. This is done through section attributes in the C code. Linker scripts can also be used to assign specific object files to sections in memory. These and other features of GNU linker scripts are explained in the GNU linker documentation, which is a part of the binutils manual. For a specific list of input sections that are assigned by MicroBlaze and MicroBlazeâ„¢ -V processor linker scripts, see MicroBlaze Linker Script Sections.