Kenwood HP 9000 Personal Computer User Manual


 
Chapter 3 77
Linker Tasks
Using Linker commands
if (fseek(destfp, aux_hdr.exec_tfile, 0))
{
fprintf(stderr, “error seeking start of text in %s\n”,
dest_file);
exit(1);
}
if ((fread(aux_hdr.exec_tmem, aux_hdr.exec_tsize, 1, destfp)) <=
0)
{
fprintf(stderr, “error reading text from %s\n”, dest_file);
exit(1);
}
/*
* Now load the data, if any:
*/
if (aux_hdr.exec_dsize) {
if (fseek(destfp, aux_hdr.exec_dfile, 0))
{
fprintf(stderr, “error seeking start of data in %s\n”,
dest_file);
exit(1);
}
if ((fread(aux_hdr.exec_dmem, aux_hdr.exec_dsize, 1,
destfp))<= 0)
{
fprintf(stderr, “error reading data from %s\n”, dest_file);
exit(1);
}
}
fclose(destfp); /* done reading from module file */
/*
-----------------------------------------------------------------
* STEP 4: Zero out the bss (uninitialized data segment):
*/
bss_start = aux_hdr.exec_dmem + aux_hdr.exec_dsize;
bss_size = aux_hdr.exec_bsize;
memset(bss_start, 0, bss_size);
/*
-----------------------------------------------------------------
* STEP 5: Flush the text from the data cache before execution:
*/
/*
* The flush_cache routine must know the exact size of the
* text, data, and bss, computed as follows:
* Size = (Data Addr - Text Addr) + Data Size + BSS Size
* where (Data Addr - Text Addr) = Text Size + alignment between
* Text and Data.
*/
tdb_size = (aux_hdr.exec_dmem - aux_hdr.exec_tmem) +
aux_hdr.exec_dsize + aux_hdr.exec_bsize;
flush_cache(addr, tdb_size);