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 utility maps sections 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. Define the
linker symbol _TEXT_START_ADDR on MicroBlaze and MicroBlaze V processors, or START_ADDR on Arm processors. See the following code for an example:
mb-gcc <input files and flags> -Wl,-defsym -Wl,_TEXT_START_ADDR=0x100
mb-ld <.o files> -defsym _TEXT_START_ADDR=0x100
The linker uses the following default script from the
$XILINX_/gnu///<processor_name>/lib/ldscripts area,
where<procname> =
microblaze, <processor_name>
=microblaze, and <platform>
= lin or nt.
-
elf32<procname>.xis the default when none of the following cases apply. -
elf32<procname>.xnis the default when the linker is invoked with the-noption. -
elf32<procname>.xbnis the default when the linker is invoked with the-Noption. -
elf32<procname>.xris the default when the linker is invoked with the-roption. -
elf32<procname>.xuis the default when the linker is invoked with the-Uroption.
To use a linker script, provide it on the GCC command line. Use the command
line option -T <script> for the compiler. See the
following code for details:
compiler -T <linker_script> <Other Options and Input Files>
Include the linker script as follows if the linker executes on its own.
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. You can generate linker scripts for your program by right clicking the application component and selecting Reset Link Script.
Linker scripts assign specific variables or functions to specific memories via section attributes in the C code. Linker scripts can also assign specific object files to sections in memory. To understand these and other features of GNU linker scripts, see the GNU linker section in 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.