Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

13.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 (). 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.c

The main program file.

ovlymgr.c

A simple overlay manager, used by overlays.c.

foo.c, bar.c, baz.c, grbx.c

Overlay modules, loaded and used by overlays.c.

d10v.ld, m32r.ld

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.

 
 
  Published under the terms of the GNU General Public License Design by Interspire