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
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 will be 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 from within IP integrator and the Vitis software platform.
In IP integrator or the Vitis IDE, select .
This opens up the linker script generator utility. Mapping sections to memory is done here. Stack and heap size can be set, as well as the memory mapping for stack and heap. When the linker script is generated, it is given as input to GCC automatically when the corresponding application is compiled within IP integrator or the Vitis environment.
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 processor linker scripts, see MicroBlaze Linker Script Sections.