Subject: re: "detected global register use not covered by .register pseudo-op"
To: matthew green <mrg@eterna.com.au>
From: Anders Lindgren <ali@df.lth.se>
List: port-sparc64
Date: 09/24/2007 17:11:32
On Mon, 24 Sep 2007, matthew green wrote:

>   help - it's not even clear what "global registers" means (%g0-%g7?
>   registers not saved by functions? something else?).
>
>   Any pointers or other hints?
>

.oO( out of memory here )

   The sparc global registers are always visible; they're not affected by 
register window switching.

   The sparc64 ELF ABI reserves most of the global (%g1..7) registers for 
"compiler" or "OS" use (specifically, %g4 is used as a "static base" 
pointer to the data segment in the "embedany" code model, see e.g. the 
-mcmodel section of gcc(1)). %g0 is of course hardwired to zero as usual. 
Don't remember off hand what other global registers are reserved for use 
by the OS, but it is mentioned in the SPARCv9 ELF ABI documentation.

   It basically boils down to that ever since whatever version of 
sparc64-binutils started caring about this, all usage of globals need to 
be declared with a pseudo-op.


> i don't remember exactly what it is about but newer code
> tends to have this in it:
>
>       .register       %g2,#scratch
>       .register       %g3,#scratch

   These are here precisely to make gas swallow the asm, since it now barfs 
on anything using globals whose use wasn't declared. I think gas' whining 
is basically there to make you testify that you know what you're doing, 
since you're stepping into toolchain-and-kernel-reserved territory.

/ali:)