| Debugging with GDB | www.imodulo.com · 2003-04-05 | ||
| [ Software | Documentation | Contact ] |
When linking a program which uses overlays, you must place the overlays at their load addresses, while relocating them to run at their mapped addresses. To do this, you must write a linker script (). Unfortunately, since linker scripts are specific to a particular host system, target architecture, and target memory layout, this manual cannot provide portable sample code demonstrating GDB's overlay support.
However, the GDB source distribution does contain an overlaid program, with linker scripts for a few systems, as part of its test suite. The program consists of the following files from gdb/testsuite/gdb.base:
overlays.cThe main program file.
ovlymgr.cA simple overlay manager, used by overlays.c.
foo.cbar.cbaz.cgrbx.cOverlay modules, loaded and used by overlays.c.
d10v.ldm32r.ldLinker scripts for linking the test program on the d10v-elf and m32r-elf targets.
You can build the test program using the d10v-elf GCC cross-compiler like this:
$ d10v-elf-gcc -g -c overlays.c
$ d10v-elf-gcc -g -c ovlymgr.c
$ d10v-elf-gcc -g -c foo.c
$ d10v-elf-gcc -g -c bar.c
$ d10v-elf-gcc -g -c baz.c
$ d10v-elf-gcc -g -c grbx.c
$ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
baz.o grbx.o -Wl,-Td10v.ld -o overlays
The build process is identical for any other architecture, except that you must substitute the appropriate compiler and linker script for the target system for d10v-elf-gcc and d10v.ld.
| © Free Software Foundation, Inc. |