Kenwood HP 9000 Personal Computer User Manual


 
Chapter 3 67
Linker Tasks
Using Linker commands
The useful members of the som_exec_auxhdr structure are:
.exec_tsize Size of text (code) segment.
.exec_tmem Address at which to load the text (already adjusted for
offset specified by the -R linker option).
.exec_tfile Offset into file (location) where text segment starts.
.exec_dsize Size of data segment.
.exec_dmem Address at which to load the data (already adjusted).
.exec_dfile Offset into file (location) where data segment starts.
.exec_bsize Size of bss segment. It is assumed to start immediately
after the data segment.
.exec_entry Address of entry point (if one was specified by the -e
linker option).
Step 5: Read the text and data into the allocated space.
Once you know the location of the required segments in the file, you can
read them into the area allocated in Step 2.
The location of the text and data segments in the file is defined by the
.exec_tfile and .exec_dfile members of the som_exec_auxhdr
structure. The address at which to place the segments in the allocated
memory is defined by the .exec_tmem and .exec_dmem members. The
size of the segments to read in is defined by the .exec_tsize and
.exec_dsize members.
Step 6: Clear (zero out) the bss segment. The bss segment
starts immediately after the data segment. To zero out the bss, find the
end of the data segment and use memset (see memory(3C)) to zero out
the size of the bss.
The end of the data segment can be determined by adding the
.exec_dmem and .exec_dsize members of the som_exec_auxhdr
structure. The bss's size is defined by the .exec_bsize member.
Step 7: Flush the text from the data cache before executing
code from the loaded module.
Before executing code in the
allocated space, a program should flush the instruction and data caches.
Although this is really only necessary on systems that have instruction
and data caches, it is easiest just to do it on all systems for ease of
portability.