Path: utzoo!attcan!uunet!ncrlnk!ncr-sd!hp-sdd!hplabs!hp-ses!hpcuhb!hpcllla!hpcllak!cary From: cary@hpcllak.HP.COM (Cary Coutant) Newsgroups: comp.sys.hp Subject: Re: 9000/835 loader and assembler problems Message-ID: <3770013@hpcllak.HP.COM> Date: 8 Jun 89 04:09:54 GMT References: <14870@comp.vuw.ac.nz> Organization: Hewlett Packard Calif. Language Lab Lines: 80 A few comments to the previous responses: 1. An easier way to put your own junk at the end of an object file is to put 128 bytes of zeroes before the junk. The linker will not attempt to read any more object modules from the file if it sees a header full of zeroes. 2. The flush_cache() routine in the previous response was an old version that may not work correctly on some HP-PA implementations. I've included the correct version below. 3. One way to guarantee that you have to do the ld -A link only once is to call sbrk(0) before the link to obtain the starting address (for the -R option), then after the link use sbrk() to allocate enough space. This technique assumes that you don't do anything that would cause a call to malloc() in between the two calls to sbrk(). 4. The linker does indeed round both text and data addresses to page boundaries because of loader (i.e., exec()) requirements. For -N links, this rounding should probably be eliminated, and we may fix this in a future release. For this reason, you should always make sure you look in the aux header exec_tmem and exec_dmem fields for the actual addresses. Cary Coutant, Hewlett-Packard Computer Language Lab ; ; Routine to flush and synchronize data and instruction caches ; for dynamic loading ; ; Copyright Hewlett-Packard Co. 1985 ; .code ; flush_cache(addr, len) - executes FDC and FIC instructions for every cache ; line in the text region given by the starting address in arg0 and ; the length in arg1. When done, it executes a SYNC instruction and ; the seven NOPs required to assure that the cache has been flushed. ; ; Assumption: the cache line size must be at least 16 bytes. .proc .callinfo .export flush_cache,entry flush_cache .enter ldsid (0,%arg0),%r1 mtsp %r1,%sr0 ldo -1(%arg1),%arg1 copy %arg0,%arg2 copy %arg1,%arg3 fdc %arg1(0,%arg0) loop1 addib,>,n -16,%arg1,loop1 ; decrement by cache line size fdc %arg1(0,%arg0) ; flush first word at addr, to handle arbitrary cache line boundary fdc 0(0,%arg0) sync fic %arg3(%sr0,%arg2) loop2 addib,>,n -16,%arg3,loop2 ; decrement by cache line size fic %arg3(%sr0,%arg2) ; flush first word at addr, to handle arbitrary cache line boundary fic 0(%sr0,%arg2) sync nop nop nop nop nop nop nop .leave .procend .end