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 (see Overlay Description in Using ld: the GNU linker). 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:
The main program file.
A simple overlay manager, used by overlays.c.
Overlay modules, loaded and used by overlays.c.
Linker scripts for linking the test program on the
You can build the test program using the
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