Specifications
Embedded System Tools Guide (EDK 6.2i) www.xilinx.com 313
UG111 (v1.4) January 30, 2004 1-800-255-7778
MicroBlaze Processor
R
Note that using the built-in linker script implies that you have no control over which parts
of your program are mapped to the different kinds of memory. The default scripts used by
the linker are located at:
$XILINX_EDK/gnu/microblaze/nt(orsol)/microblaze/lib/ldscripts, where
$XILINX_EDK is the EDK installed directory. These scripts are imbibed into the linker and
hence any changes to these scripts will not be reflected. To customize linker scripts, you
must write your own linker script.
Minimal Linker Script
If your LMB, OPB and External Memory do not occupy contiguous areas of memory, you
can use a minimal linker script to define your memory layout. Here is a minimal linker
script that describes the memory regions only, and uses the default (built-in) linker script
for everything else.
/*
* Define the memory layout, specifying the start address and size of the
* different memory regions. The ILMB will contain only executable code
(x),
* the DLMB will contain only initialized data (i), and the DOPB will
contain
* all other writable data (w). Note that all sections of all your input
* object files must map into one of these memory regions. Other memory
types
* that may be specified are "r" for read-only data.
*/
MEMORY
{
ILMB (x) : ORIGIN = 0x0, LENGTH = 0x1000
DLMB (i) : ORIGIN = 0x2000, LENGTH = 0x1000
DOPB (w) : ORIGIN = 0x8000, LENGTH = 0x30000
}
This script specifies that the ILMB memory contains all object file sections that have the x
flag, the DLMB contains all object file sections that have the i flag and the DOPB contains
all object file sections that have the w flag. An object file section that has both the x and the
i flag (for example, the .text section) will be loaded into ILMB memory because this is
specified first in the linker script. Refer to the “Object-file Sections” section of this chapter
for more information on object file sections, and the flags that are set in each.
Your source files can now be compiled by specifying the minimal linker script as though it
were a regular file, e.g.,
mb-gcc minimal linker script file1.c file2.c
Remember to specify the minimal linker script as the first source file.
If you want more control over the layout of your memory, for example, if you want to split
up your .text section between ILMB and IOPB, or if you want your stack and heap in
DLMB and the rest of the .bss section in DOPB, you will need to write a full-fledged linker
script.
Linker Script
You will need to use a linker script if you want to control how your program is targeted to
LMB, OPB or External Memory. Remember that LMB memory is faster than both OPB and










