manpagez: man pages & more
info gdb
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.4 Overlay Sample Program

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 ( Description section `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 No value for GDBN's overlay support.

However, the No value for GDBN 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 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.

© 2000-2017
Individual documents may contain additional copyright information.