Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Jan 2003 22:17:06 +0100
From:      Thomas Moestl <tmoestl@gmx.net>
To:        John Polstra <jdp@polstra.com>
Cc:        sparc@freebsd.org
Subject:   Re: Question about odd stack pointer values on sparc64
Message-ID:  <20030112211706.GA278@crow.dom2ip.de>
In-Reply-To: <XFMail.20030112124444.jdp@polstra.com>
References:  <XFMail.20030112124444.jdp@polstra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 2003/01/12 at 12:44:44 -0800, John Polstra wrote:
> Still working on getting Modula-3 going on Sparc64.  I think I'm
> getting close ...
> 
> In GDB I notice that the stack pointer and frame pointer are often
> (always?) odd numbers, e.g.:
> 
>     (gdb) p/x $sp
>     $1 = 0x7fdffffdec1
>     (gdb) p/x $fp
>     $2 = 0x7fdffffdfb1
> 
> What is the reason for that?  Are the low-order bits simply ignored?
> Surely the stack is more aligned than that.

The actual stack location is %sp + SPOFF (where SPOFF is 2047) by
convention. This causes the stack pointer to always contain an odd
number; 32 bit binaries do not have this offset, so their stack
pointers are always even. This allows some kernel trap handlers to
easily distinguish between 32 and 64 bit binaries. 2047 seems to have
been chosen of all odd numbers to enlarge the range of "interesting"
%fp-relative locations addressable using immediates.
The SPARC compliance definition (SCD) has more information on this
(it's available at http://www.sparc.com/resource.htm).

	- Thomas

-- 
Thomas Moestl <tmoestl@gmx.net>	http://www.tu-bs.de/~y0015675/
              <tmm@FreeBSD.org>	http://people.FreeBSD.org/~tmm/
PGP fingerprint: 1C97 A604 2BD0 E492 51D0  9C0F 1FE6 4F1D 419C 776C

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-sparc" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030112211706.GA278>