SPNU118Z September 1995 – March 2023 66AK2E05 , 66AK2H06 , 66AK2H12 , 66AK2H14 , AM1705 , AM1707 , AM1802 , AM1806 , AM1808 , AM1810 , AM5K2E04 , OMAP-L132 , OMAP-L137 , OMAP-L138 , SM470R1B1M-HT , TMS470R1A288 , TMS470R1A384 , TMS470R1A64 , TMS470R1B1M , TMS470R1B512 , TMS470R1B768
This example links three object files named demo.c.obj, ctrl.c.obj, and tables.c.obj and creates a program called demo.out.
Assume that target memory has the following program memory configuration:
Address Range | Contents | ||
---|---|---|---|
0x0080 to 0x7000 | On-chip RAM_PG | ||
0xC000 to 0xFF80 | On-chip ROM |
Address Range | Contents | ||
---|---|---|---|
0x0080 to 0x0FFF | RAM block ONCHIP | ||
0x0060 to 0xFFFF | Mapped external addresses EXT |
Address Range | Contents | ||
---|---|---|---|
0x00000000 to 0x00001000 | SLOW_MEM | ||
0x00001000 to 0x00002000 | FAST_MEM | ||
0x08000000 to 0x08000400 | EEPROM |
The output sections are constructed in the following manner:
Linker Command File, demo.cmd shows the linker command file for this example. Output Map File, demo.map shows the map file.
/*****************************************************************************/
/*** Specify Link Options ***/
/*****************************************************************************/
--entry_point SETUP /* Define the program entry point */
--output_file=demo.out /* Name the output file */
--map_file=demo.map /* Create an output map file */
/*****************************************************************************/
/*** Specify the Input Files ***/
/*****************************************************************************/
demo.c.obj
ctrl.c.obj
tables.c.obj
/*****************************************************************************/
/*** Specify the Memory Configurations ***/
/*****************************************************************************/
MEMORY
{
FAST_MEM : org = 0x00000000 len = 0x00001000 /* PROGRAM MEMORY (ROM) */
SLOW_MEM : org = 0x00001000 len = 0x00001000 /* DATA MEMORY (RAM) */
EEPROM : org = 0x08000000 len = 0x00000400 /* COEFFICIENTS (EEPROM) */
}
/*****************************************************************************/
/* Specify the Output Sections */
/*****************************************************************************/
SECTIONS
{
.text : {} > FAST_MEM /* Link all .text sections into ROM */
.intvecs : {} > 0x0 /* Link interrupt vectors at 0x0 */
.data : /* Link .data sections */
{
tables.c.obj(.data)
. = 0x400; /* Create hole at end of block */
} > EEPROM, fill = 0xFF00FF00 /* Fill and link into EEPROM */
ctrl_vars: /* Create new sections for ctrl variables */
{
ctrl.c.obj(.bss)
} > SLOW_MEM, fill = 0x00000100 /* Fill with 0x100 and link into RAM */
.bss : {} > SLOW_MEM /* Link remaining .bss sections into RAM */
}
/*****************************************************************************/
/*** End of Command File ***/
/*****************************************************************************/
Invoke the linker by entering the following command:
armcl --run_linker demo.cmd
This creates the map file shown in Output Map File, demo.map and an output file called demo.out that can be run on an ARM device.
OUTPUT FILE NAME: <demo.out>
ENTRY POINT SYMBOL: "SETUP" address: 000000d4
MEMORY CONFIGURATION
name origin length attributes fill
-------- -------- --------- ---------- --------
FAST_MEM 00000000 000001000 RWIX
SLOW_MEM 00001000 000001000 RWIX
EEPROM 08000000 000000400 RWIX
SECTION ALLOCATION MAP
output attributes/
section page origin length input sections
-------- ---- ---------- ---------- ----------------
.text 0 00000020 00000138
00000020 000000a0 ctrl.c.obj (.text)
000000c0 00000000 tables.c.obj (.text)
000000c0 00000098 demo.c.obj (.text)
.intvecs 0 00000000 00000020
00000000 00000020 tables.c.obj (.intvecs)
.data 0 08000000 00000400
08000000 00000168 tables.c.obj (.data)
08000168 00000298 --HOLE-- [fill = ff00ff00]
08000400 00000000 ctrl.c.obj (.data)
08000400 00000000 demo.c.obj (.data)
ctrl_var 0 00001000 00000500
00001000 00000500 ctrl.c.obj (.bss) [fill = 00000100]
.bss 0 00001500 00000100 UNINITIALIZED
00001500 00000100 demo.c.obj (.bss)
00001600 00000000 tables.c.obj (.bss)
GLOBAL SYMBOLS
address name address name
-------- ---- -------- ----
000000d4 SETUP 00000020 clear
00000020 clear 000000b8 set
000000b8 set 000000c0 x42
000000c0 x42 000000d4 SETUP
[4 symbols]