x86 32-bits compiler use on a 64-bits machine ?
Tom St Denis
tstdenis@ellipticsemi.com
Wed Jul 2 12:48:00 GMT 2008
Christophe LYON wrote:
> Hi Andrew,
>
> Thanks for your answer.
>
>>> The documentation only mentions the size of int and pointer types.
>>
>> The gcc documentation talks only about gcc; you're asking about the
>> system linker.
>>
>
> I did not mean that.
> If I compile a.c with "gcc-x.x.x (32 bits)" on a Pentium 4 machine,
> and with "gcc-x.x.x (64 bits) -m32" on an Opteron, am I guaranteed
> that both a.o will have the same contents?
> Any risk that the file compiled on Opteron contains Opteron-only
> instructions for instance? Or references only 64 bits variants of some
> system structures?
If you use -m32 it will be x86_32 code, sections, etc. You should be
able to link it with a 32-bit binutils just fine (provided your on the
same revision of GCC, e.g. don't mix a 32-bit GCC 3.2 with a 64-bit GCC
4.3).
You won't be guaranteed to get the same object code (byte for byte)
unless you have the exact same configuration for GCC and revision.
> If I compile a.c with "gcc-x.x.x (32 bits)" on a Pentium 4 machine,
> and b.c with "gcc-x.x.x (64 bits) -m32" on an Opteron, I need to be
> able to link a.o and b.o together and that the result is actually
> meaningful on a Pentium 4.
Linking should be no problem provided they're the same revision. Also
helps to build your 64-bit GCC with multi-lib enabled.
Tom
More information about the Gcc-help
mailing list