This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: 32-bit libraries in 64-bit build.
On Wed, May 20, 2009 at 10:03:08AM -0700, Bob Plantz wrote:
> On Wed, 2009-05-20 at 12:31 -0400, Michael Meissner wrote:
>
> > structures as well. 64 and 32-bit programs use a completely different ABI, and
> > the stack is set up differently.
>
> The main difference being that the first six arguments are passed in
> registers instead of on the stack. It's very "RISC-like."
Also the alignment of the stack, whether or not the implementation can assume
the use of the SSE2 registers, size of long, how 64-bit values are returned,
what the stack unwind tables look like, etc. Lots of differences.
> > Finally, some 32-bit instruction encodings
> > are not available when the computer is in 64-bit mode, and others behave
> > differently when the 64-bit registers are enabled.
> >
>
> Isn't this true only at the individual instruction level?
If the 32-bit library was compiled with encodings that conflict with the 64-bit
instructions, then instructions will do funky things if you somehow manage to
bolt a 32-bit library into a 64-bit program, because the library will be called
in 64-bit mode.
> For example, you can do
> movb %ah, %al # 32-bit, no REX prefix byte
> movb %al, %r8b # 64-bit, requires REX prefix byte
>
> but you cannot do
> movb %ah, %r8b # mixed mode, conflict
>
> The first sequence of instructions will run on my machine under 64-bit
> Ubuntu.
>
> An aside: The gnu assembler, gas, gives an error message about the REX
> prefix being required for the second case. It took me a while to figure
> it out. The error message should really say something about this being
> an attempt to mix 32-bit and 64-bit modes.
Well as they say, patches are welcome.
--
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
meissner@linux.vnet.ibm.com