BSP and Device Driver Development Guide
The GNU linker has a command language to specify the image format. This
command language can be quite complicated but most of what is required
can be learned by careful examination of a well-documented example.
The following is a heavily commented version of the linker script
used with the the gen68340
BSP This file can be found at
$BSP340_ROOT/startup/linkcmds.
/* * Specify that the output is to be coff-m68k regardless of what the * native object format is. */ OUTPUT_FORMAT(coff-m68k) /* * Set the amount of RAM on the target board. * * NOTE: The default may be overridden by passing an argument to ld. */ RamSize = DEFINED(RamSize) ? RamSize : 4M; /* * Set the amount of RAM to be used for the application heap. Objects * allocated using malloc() come from this area. Having a tight heap * size is somewhat difficult and multiple attempts to squeeze it may * be needed reducing memory usage is important. If all objects are * allocated from the heap at system initialization time, this eases * the sizing of the application heap. * * NOTE 1: The default may be overridden by passing an argument to ld. * * NOTE 2: The TCP/IP stack requires additional memory in the Heap. * * NOTE 3: The GNAT/RTEMS run-time requires additional memory in * the Heap. */ HeapSize = DEFINED(HeapSize) ? HeapSize : 0x10000; /* * Set the size of the starting stack used during BSP initialization * until first task switch. After that point, task stacks allocated * by RTEMS are used. * * NOTE: The default may be overridden by passing an argument to ld. */ StackSize = DEFINED(StackSize) ? StackSize : 0x1000; /* * Starting addresses and length of RAM and ROM. * * The addresses must be valid addresses on the board. The * Chip Selects should be initialized such that the code addresses * are valid. */ MEMORY { ram : ORIGIN = 0x10000000, LENGTH = 4M rom : ORIGIN = 0x01000000, LENGTH = 4M } /* * This is for the network driver. See the Networking documentation * for more details. */ ETHERNET_ADDRESS = DEFINED(ETHERNET_ADDRESS) ? ETHERNET_ADDRESS : 0xDEAD12; /* * The following defines the order in which the sections should go. * It also defines a number of variables which can be used by the * application program. * * NOTE: Each variable appears with 1 or 2 leading underscores to * ensure that the variable is accessible from C code with a * single underscore. Some object formats automatically add * a leading underscore to all C global symbols. */ SECTIONS { /* * Make the RomBase variable available to the application. */ _RamSize = RamSize; __RamSize = RamSize; /* * Boot PROM - Set the RomBase variable to the start of the ROM. */ rom : { _RomBase = .; __RomBase = .; } >rom /* * Dynamic RAM - set the RamBase variable to the start of the RAM. */ ram : { _RamBase = .; __RamBase = .; } >ram /* * Text (code) goes into ROM */ .text : { /* * Create a symbol for each object (.o). */ CREATE_OBJECT_SYMBOLS /* * Put all the object files code sections here. */ *(.text) . = ALIGN (16); /* go to a 16-byte boundary */ /* * C++ constructors and destructors * * NOTE: See the CROSSGCC mailing-list FAQ for * more details about the "[......]". */ __CTOR_LIST__ = .; [......] __DTOR_END__ = .; /* * Declares where the .text section ends. */ etext = .; _etext = .; } >rom /* * Exception Handler Frame section */ .eh_fram : { . = ALIGN (16); *(.eh_fram) } >ram /* * GCC Exception section */ .gcc_exc : { . = ALIGN (16); *(.gcc_exc) } >ram /* * Special variable to let application get to the dual-ported * memory. */ dpram : { m340 = .; _m340 = .; . += (8 * 1024); } >ram /* * Initialized Data section goes in RAM */ .data : { copy_start = .; *(.data) . = ALIGN (16); _edata = .; copy_end = .; } >ram /* * Uninitialized Data section goes in ROM */ .bss : { /* * M68K specific: Reserve some room for the Vector Table * (256 vectors of 4 bytes). */ M68Kvec = .; _M68Kvec = .; . += (256 * 4); /* * Start of memory to zero out at initialization time. */ clear_start = .; /* * Put all the object files uninitialized data sections * here. */ *(.bss) *(COMMON) . = ALIGN (16); _end = .; /* * Start of the Application Heap */ _HeapStart = .; __HeapStart = .; . += HeapSize; /* * The Starting Stack goes after the Application Heap. * M68K stack grows down so start at high address. */ . += StackSize; . = ALIGN (16); stack_init = .; clear_end = .; /* * The RTEMS Executive Workspace goes here. RTEMS * allocates tasks, stacks, semaphores, etc. from this * memory. */ _WorkspaceBase = .; __WorkspaceBase = .; } >ram }
BSP and Device Driver Development Guide
Copyright © 1988-2004 OAR Corporation