This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to compile and link 32 bit c code with 64 bit c code
On 01/06/2010 06:29 AM, Qing Wang wrote:
> I noticed that if some c files are compiled as 32 bit code by -m32,
> and others are compiled as 64 bit code by -m64, they will not work
> together.
> But can I add something in the c files (say asm(".code64")) and
> compile all of c files by -m32, and then when the program switches
> into 64 bit mode from 32 bit mode, those ".code64" code can work
> properly (i.e. access the memory above 64G)?
This is impossible for lots of reasons, even if you could change the
processor ito 64-bit mode. You'll only be linking against one libgcc,
and it'll be either the 32- or 64-bit one. The shared library loader
will expect either 32- or 64-bit code, and so on. It's easy to
communicate between 32- and 64-bit processes with pipes or shared
memory.
Andrew.