Kenwood HP 9000 Personal Computer User Manual


 
44 Chapter 2
What Happens When You Compile and Link a Program
Linking Programs on HP-UX
In 64-bit mode for dynamically bound executables, the entry point,
defined by the symbol $START$ in the dynamic loader (dld.sl).
The a.out File
The information contained in the resulting a.out file depends on which
architecture the file was created on and what options were used to link
the program. In any case, an executable a.out file contains information
that HP-UX needs when loading and running the file, for example: Is it a
shared executable? Does it reference shared libraries? Is it
demand-loadable? Where do the code (text), data, and bss (uninitialized
data) segments reside in the file? For details on the format of this file, see
a.out(4).
Magic Numbers
In 32-bit mode, the linker records a magic number with each
executable program that determines how the program should be loaded.
There are three possible values for an executable file's magic number:
SHARE_MAGIC The program's text (code) can be shared by processes;
its data cannot be shared. The first process to run the
program loads the entire program into virtual memory.
If the program is already loaded by another process,
then a process shares the program text with the other
process.
DEMAND_MAGIC As with SHARE_MAGIC the program's text is shareable
but its data is not. However, the program's text is
loaded only as needed — that is, only as the pages are
accessed. This can improve process startup time since
the entire program does not need to be loaded; however,
it can degrade performance throughout execution.
EXEC_MAGIC Neither the program's text nor data is shareable. In
other words, the program is an unshared executable.
Usually, it is not desirable to create such unshared
executables because they place greater demands on
memory resources.
By default, the linker creates executables whose magic number is
SHARE_MAGIC. The following shows which linker option to use to
specifically set the magic number.