[m-dev.] diff: Runtime support for stack layouts, round 2

Fergus Henderson fjh at cs.mu.oz.au
Wed Nov 26 18:46:56 AEDT 1997


On Wed, Nov 26, 1997 at 06:27:20PM +1100, Tyson Dowd wrote:
> 
> Well, now that I think about it, because all the labels are treated as
> entry labels, they do their own FIXUP anyway, so this
> INLINE_ASM_FIXUP_REGS is not necesary as part of the proceed() macro for
> .agc grades. So I should make it conditional.

That would work, I guess.

> Other solutions:
> 	- Couldn't we set $gp using succip instead of ($27)?
> 	  Don't we just set it as part of ASM_JUMP anyway?
> 	  So instead of jump, return, fixup relative to here, jump, 
> 	  it would be jump, fixup relative to return, return

I don't think so.  I think the ldgp assembler pseudo-instruction only
lets you do "fixup relative to here" not "fixup relative to there".

I think it works like this:

	- the assembler and linker together determine the offset of `here'
	  from the start of this code section, and the offset of the
	  start of the corresponding data section from the code section,
	  and hence the offset of `here' from the corresponding data section

	- the ldgp pseudo-instruction takes as argument a register containing
	  the address of `here' (possibly plus an offset, in case the ldgp
	  instruction is not the first one after the label),
	  and adds the offset of `here' from the corresponding data section
	  to calculute the address of the corresponding data section,
	  and stores the result in the $gp register.

> I thought the Alpha code was needed to use asm labels whether static
> or shared, (but the Sparc and i386 FIXUP code was necessary only for
> PIC with asm labels).

On Alpha, `-fpic' has no effect, all code is always compiled in `pic' mode.
However, if you don't use shared libraries, there will only be one
data section; the reason your code may have worked when compiled statically
was that although it would set $gp to the value for the wrong procedure,
there was only one value for all procedures anyway.

(Actually there will be a different data section for the C standard library,
which is always linked shared; but the C compiler handles the saving/
restoring of $gp for C function calls, so that wouldn't cause a problem.)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   WWW: <http://www.cs.mu.oz.au/~fjh>  
Note: due to some buggy software and a (probably accidental)
denial-of-service attack, any mail sent to me between
	Tue Nov 25 20:00:00 UTC (6am Wed, local time)
and	Wed Nov 26 06:00:00 UTC (4pm, local time)
may have gone into the bit-bucket.  Please re-send it.



More information about the developers mailing list