3 <title>Debugging with GDB
</title>
4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"Debugging with GDB">
6 <meta name=
"generator" content=
"makeinfo 4.3">
7 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home">
12 Node:
<a name=
"Overlay%20Sample%20Program">Overlay Sample Program
</a>,
13 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Automatic-Overlay-Debugging.html#Automatic%20Overlay%20Debugging">Automatic Overlay Debugging
</a>,
14 Up:
<a rel=
"up" accesskey=
"u" href=
"Overlays.html#Overlays">Overlays
</a>
18 <h3 class=
"section">Overlay Sample Program
</h3>
20 <p>When linking a program which uses overlays, you must place the overlays
21 at their load addresses, while relocating them to run at their mapped
22 addresses. To do this, you must write a linker script (see
<a href=
"../ld.info/Overlay-Description.html#Overlay%20Description">Overlay Description
</a>). Unfortunately,
23 since linker scripts are specific to a particular host system, target
24 architecture, and target memory layout, this manual cannot provide
25 portable sample code demonstrating GDB's overlay support.
27 <p>However, the GDB source distribution does contain an overlaid
28 program, with linker scripts for a few systems, as part of its test
29 suite. The program consists of the following files from
30 <code>gdb/testsuite/gdb.base
</code>:
33 <dt><code>overlays.c
</code>
34 <dd>The main program file.
35 <br><dt><code>ovlymgr.c
</code>
36 <dd>A simple overlay manager, used by
<code>overlays.c
</code>.
37 <br><dt><code>foo.c
</code>
38 <dd><dt><code>bar.c
</code>
39 <dd><dt><code>baz.c
</code>
40 <dd><dt><code>grbx.c
</code>
41 <dd>Overlay modules, loaded and used by
<code>overlays.c
</code>.
42 <br><dt><code>d10v.ld
</code>
43 <dd><dt><code>m32r.ld
</code>
44 <dd>Linker scripts for linking the test program on the
<code>d10v-elf
</code>
45 and
<code>m32r-elf
</code> targets.
48 <p>You can build the test program using the
<code>d10v-elf
</code> GCC
49 cross-compiler like this:
51 <pre class=
"example"> $ d10v-elf-gcc -g -c overlays.c
52 $ d10v-elf-gcc -g -c ovlymgr.c
53 $ d10v-elf-gcc -g -c foo.c
54 $ d10v-elf-gcc -g -c bar.c
55 $ d10v-elf-gcc -g -c baz.c
56 $ d10v-elf-gcc -g -c grbx.c
57 $ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
58 baz.o grbx.o -Wl,-Td10v.ld -o overlays
61 <p>The build process is identical for any other architecture, except that
62 you must substitute the appropriate compiler and linker script for the
63 target system for
<code>d10v-elf-gcc
</code> and
<code>d10v.ld
</code>.