[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The linker comes with the GNU binutils package. It is responsible for collecting the object files together, map the code in memory and create the final executable.
This chapter presents some details about using the GNU linker for 68HC11 and 68HC12. The GNU ld documentation is probably more complete. The GNU binutils contain the assembler, linker, archiver and many other utilities. These utilities use various format for object files including ELF-32, Motorola S-records, Intel HEX records, and others.
The complete GNU Linker documentation is available in The GNU Linker and other utility tools are described in The GNU Binary Utilities.
Gas generates object files in the ELF format. The specific tags
EM_68HC11
(70) and EM_68HC12
(53) are used to identify
the machine. These tags are defined by the
`Motorola Embedded Working Group' (see
http://www.mcu.motsps.com/dev_tools/hc12/eabi.
Gas generates the following relocation types:
This section presents the important ELF sections that an object file can contain. Each of them play an important role for building the final application.
.text
0x8000
. This can
be overridden with `-Ttext' option or better by specifying
a text
memory region.
.rodata
.data
.bss
.page0
.eeprom
.install[0-4]
.fini[0-4]
.vectors
0xffc0
and placed at that address by the linker. By using the
`-defsym vectors_addr=addr' linker option, it is
possible to set another address for the vectors table. For
example, `-defsym vectors_addr=0xbfc0' sets the vectors
table at 0xbfc0
.
.softregs
others
The Linker contains built-in linker scripts which indicate how to perform the link and where to put the different sections. You can use the provided linker scripts or write yours. In general, you will want to give the linker some information about the ROM and RAM you have on your board. The Linker defines two emulations which allow you to use one
The `m68hc11elf' and `m68hc12elf' emulations define the memory as follows:
MEMORY { page0 (rwx) : ORIGIN = 0x0, LENGTH = 256 text (rx) : ORIGIN = 0x08000, LENGTH = 0x8000 data : ORIGIN = 0x01100, LENGTH = 0x6F00 eeprom : ORIGIN = 0xb600, LENGTH = 512 } PROVIDE (_stack = 0x1100 + 0x6f00 - 1); |
which means that there are two RAM banks, one at [0x0..0xff]
and one
at [0x1100..0x7fff]
. There is also a ROM bank at [0x8000..0xffff]
.
The PROVIDE
instruction defines the address of the top of the stack
to the top of the RAM.
This memory configuration is suitable for the 68HC11/68HC12 simulator. It was
defined like this to be able to run the GCC test-suite.
The `m68hc11elfb' and `m68hc12elfb' emulations are the same
except that they include a
file `memory.x' that you must provide in the current directory or
in one of the `-L' directories. The file you have to write must
contain the above MEMORY
definition. You can change the address
and sizes of the different memory banks. You must also define the address
of the top of the stack.
To select a particular linker emulation, use the `-m emulation'
option. If you use m6811-elf-gcc
or m6812-elf-gcc
,
you must pass the emulation
through the `-Xlinker' or `-Wl' option. For example:
m6811-elf-gcc -Wl,-m,m68hc11elfb -o tst.out tst.o |
When you specify a linker emulation through the `-Wl,-m' option, you
must be careful to use the emulation that corresponds to your CPU target.
If you compiled your program with -m68hc12
or -m68hcs12
you
should use the `m68hc12elfb' emulation.
The Linker uses and provides some symbols that you can use in your program.
_start
_stack
etext
edata
__data_image
__data_image_end
__data_section_start
This symbol should rather be named: `__data_start'.
__data_section_size
This symbol should rather be named: `__data_size'.
__bss_start
__bss_size
_end
_vectors_addr
0xffc0
. If you have provided a
`-defsym vectors_addr=addr' option to the linker,
this symbol will have the value you have specified.
Note: If you provide a `vectors_addr' symbol, there will be two symbols: one with _ and one without.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |