This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: "small data" in m68k gcc?
- From: Gunther Nikl <gni at gecko dot de>
- To: Bernardo Innocenti <bernie at develer dot com>
- Cc: colin-gcc at horizon dot com, gcc at gcc dot gnu dot org
- Date: Tue, 14 Oct 2003 15:59:42 +0200
- Subject: Re: "small data" in m68k gcc?
- References: <20031012214902.2016.qmail@science.horizon.com> <200310130113.55072.bernie@develer.com>
On Mon, Oct 13, 2003 at 01:13:55AM +0200, Bernardo Innocenti wrote:
> > I'm trying to move some code away from a proprietary compiler, but
> > the multitasker depends on having A5-relative global variables, and
> > I'm having a hard time figuring out how to generate them.
>
> This has been quite common practice on the Amiga to generate residentable
> programs and reduce code and relocs size. Actually, the Amiga uses
> A4-relative addressing because A5 is used as a frame pointer and A6 is
> reserved for calling shared library functions through a jump table.
Correct. The AmigaOS/m68k patches add two additional pic modes (word
and long sized) and handle these modes at those places where they work
differently to the normal pic/PIC modes. These mode do only affect data,
not function calls.
> The Amiga people always enjoied A5-relative addressing with SAS/C
> (formerly known as Lattice C) and Storm C.
I suppose that should read "A4-relative", shouldn't it?
> Of course smart A5 addressing requires some support in the startup
> code (loading A5 for the first time).
There is an attribute for doing just that: __saveds__
> Programmers must be careful when mixing code compiled with small-data
> with code using A5 as a general purpose register.
Yes, that would cause havoc.
> On the Amiga, you'd use the "__loadds" function attribute for callbacks
> and softints.
__saveds
> > Even the -l option to gas, which is documented as changing the
> > default absolute addressing mode to .w (rather than .l), doesn't
> > seem to work.
>
> That's not meant to be used to trick the compiler. It's just
> a compatibility option for assembly source written for other
> assemblers.
The AmigaOS version of GAS 1.38 had a -l switch which forced the gas to
emit 16bit references for calls to external symbols.
> > attribute((pcrel)) -> var(%pc)
For const data in the text section such code should be generated by GAS
automatically.
Gunther