[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] GCC 4.2.2 and binary compatibility
Hi Vincent,
On 24 Nov 2007 at 10:34, Vincent Rivière wrote:
>
> The first problem was about functions returning pointers. Traditional
> compilers used to return them into d0. GCC for Linux/m68k returns them
> into a0. My current binaries behaves like Linux, but it breaks the
> compatibility with older Atari functions written in assembly language.
> Thus in my next build, I'll disable that a0/d0 stuff and use d0 in all
> cases, just like older compilers.
>
> The second question is about alignment.
>
> Vincent Rivière wrote:
> > I would like to speak about another "feature" : alignment.
> >
> > By default, GCC aligns structure members on 4-byte boundaries,
> > producing useless 2-byte holes in a structure where longs and shorts
> > are mixed. I patched it long ago to use a 2-byte default alignment,
> > so no space is wasted. Some people said that the 68020+ CPU have
> > faster memory access to longs aligned on 32-bit boundaries. Is it
> > true on Atari computers ?
> >
> > I recently discovered another "feature" of GCC. When function
> > arguments are pushed on the stack, they are aligned on an "int"
> > boundary. When compiling with -mshort, there is no additional filler.
> > But when -mshort is not used, pushing a short then a long causes the
> > long to be aligned 2 bytes further. A short filler is inserted
> > between the 2 values. Just like structure alignment, it seems to me
> > that such alignment is useless on the Atari platform. I plan to
> > remove this alignment in my next build.
> >
> > So what do you think about removing the alignments, for structure
> > members and stack parameters ? Does it break some compatibility ?
>
> Petr Stehlik answered:
> > yes, it does.
> >
> > If you want to help the Atari community with your GCC port then
> > please don't mess with these settings (including the a0/d0 trials)
> > and make sure that you use the very same settings the gcc 2.95 for
> > MiNT had.
>
> Feel free to post any further comment.
>
The Lattice C compiler (in default mode) uses 32-bit integers and widens
shorter integer type (i.e. shorts and chars) to 32 bits before placing them on
the stack. However (also in default mode), non-character structure members are
aligned on word boundaries rather than long boundaries. Both these behaviours
may be changed by appropriate compiler arguments.
Since I suspect GCC is used a lot more than Lattice for current development, it
would probably be best to stick to the existing GCC implementation behaviour.
Regards,
Roger Burrows