104
Chapter 13. Debugging Programs That Use Overlays
except that the program variables and heap would share an address space with the main program and
the overlay area.
An overlay loaded into instruction memory and ready for use is called a
mapped
overlay; its
mapped
address
is its address in the instruction memory. An overlay not present (or only partially present)
in instruction memory is called
unmapped
; its
load address
is its address in the larger memory. The
mapped address is also called the
virtual memory address
, or
VMA
; the load address is also called the
load memory address
, or
LMA
.
Unfortunately, overlays are not a completely transparent way to adapt a program to limited instruction
memory. They introduce a new set of global constraints you must keep in mind as you design your
program:
•
Before calling or returning to a function in an overlay, your program must make sure that overlay
is actually mapped. Otherwise, the call or return will transfer control to the right address, but in the
wrong overlay, and your program will probably crash.
•
If the process of mapping an overlay is expensive on your system, you will need to choose your
overlays carefully to minimize their effect on your program’s performance.
•
The executable file you load onto your system must contain each overlay’s instructions, appearing
at the overlay’s load address, not its mapped address. However, each overlay’s instructions must be
relocated and its symbols defined as if the overlay were at its mapped address. You can use GNU
linker scripts to specify different load and relocation addresses for pieces of your program; see .
•
The procedure for loading executable files onto your system must be able to load their contents into
the larger address space as well as the instruction and data spaces.
The overlay system described above is rather simple, and could be improved in many ways:
•
If your system has suitable bank switch registers or memory management hardware, you could use
those facilities to make an overlay’s load area contents simply appear at their mapped address in
instruction space. This would probably be faster than copying the overlay to its mapped area in the
usual way.
•
If your overlays are small enough, you could set aside more than one overlay area, and have more
than one overlay mapped at a time.
•
You can use overlays to manage data, as well as instructions. In general, data overlays are even less
transparent to your design than code overlays: whereas code overlays only require care when you
call or return to functions, data overlays require care every time you access the data. Also, if you
change the contents of a data overlay, you must copy its contents back out to its load address before
you can copy a different data overlay into the same mapped area.
13.2. Overlay Commands
To use gdb’s overlay support, each overlay in your program must correspond to a separate section
of the executable file. The section’s virtual memory address and load memory address must be the
overlay’s mapped and load addresses. Identifying overlays with sections allows gdb to determine the
appropriate address of a function or variable, depending on whether the overlay is mapped or not.
gdb’s overlay commands all start with the word
overlay
; you can abbreviate this as
ov
or
ovly
. The
commands are:
overlay off
Disable gdb’s overlay support. When overlay support is disabled, gdb assumes that all functions
and variables are always present at their mapped addresses. By default, gdb’s overlay support is
disabled.
Summary of Contents for ENTERPRISE LINUX 3 - SECURITY GUIDE
Page 1: ...Red Hat Enterprise Linux 3 Debugging with gdb ...
Page 12: ...2 Chapter 1 Debugging with gdb ...
Page 28: ...18 Chapter 4 Getting In and Out of gdb ...
Page 34: ...24 Chapter 5 gdb Commands ...
Page 44: ...34 Chapter 6 Running Programs Under gdb ...
Page 68: ...58 Chapter 8 Examining the Stack ...
Page 98: ...88 Chapter 10 Examining Data ...
Page 112: ...102 Chapter 12 Tracepoints ...
Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Page 138: ...128 Chapter 14 Using gdb with Different Languages ...
Page 144: ...134 Chapter 15 Examining the Symbol Table ...
Page 170: ...160 Chapter 19 Debugging remote programs ...
Page 198: ...188 Chapter 21 Controlling gdb ...
Page 204: ...194 Chapter 22 Canned Sequences of Commands ...
Page 206: ...196 Chapter 23 Command Interpreters ...
Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Page 296: ...286 Chapter 27 gdb Annotations ...
Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Page 322: ...312 Chapter 30 Using History Interactively ...
Page 362: ...352 Appendix D gdb Remote Serial Protocol ...
Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Page 386: ...376 Appendix G GNU Free Documentation License ...
Page 410: ......