Kenwood HP 9000 Personal Computer User Manual


 
Chapter 3 65
Linker Tasks
Using Linker commands
Dynamic Linking with -A and -R
This section describes how to do dynamic linking — that is, how to add
an object module to a running program. Conceptually, it is very similar to
loading a shared library and accessing its symbols (routines and data).
In fact, if you require such functionality, you should probably use shared
library management routines (see Chapter 6, “Shared Library
Management Routines,” on page 195).
However, be aware that dynamic linking is incompatible with shared
libraries. That is, a running program cannot be linked to shared libraries
and also use ld -A to dynamically load object modules.
NOTE Another reason to use shared library management routines instead of
dynamic linking is that dynamic linking may not be supported in a
future release. See “Linker Compatibility Warnings” and “Changes in
Future Releases” on page 32for additional future changes.
Topics in this section include:
“Overview of Dynamic Linking” describes steps to load an object file
into a running program.
“An Example Program” provides an example dynamic linking
scenario.
Overview of Dynamic Linking
The implementation details of dynamic linking vary across platforms. To
load an object module into the address space of a running program, and
to be able to access its procedures and data, follow these steps on all
HP9000 computers:
1. Determine how much space is required to load the module.
2. Allocate the required memory and obtain its starting address.
3. Link the module from the running application.
4. Get information about the module's text, data, and bss segments from
the module's header.
5. Read the text and data into the allocated space.
6. Clear (fill with zeros) the bss segment.
7. Flush the text from the data cache before executing code from the
loaded module.