Re: How to compile and link 32 bit c code with 64 bit c code‏

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2010-01-05 at 11:47 +0800, Qing Wang wrote:
> Hi, 
>  
> I am making a 32 bit project to call some 64 bit functions.
> So, I have most of c files which will be compiled and linked into 32 bit binary.And I have some c files including those functions which will be compiled into 64 bit binary.
> Of course, I will call into assembly first to set up 64 bit mode, and then call those 64 bit functions, finally I will return to assembly to get back to 32 bit mode. 
>  
> Now I have a problem how to compile and link those 32 bit code with those 64 bit code together into one object file (like xxx.gz) 
> Unlike assembly, which is easy to embed ".code32" or ".code64" in assembly to distinguish 32 bit code and 64 bit code, (see the document "Using as The GNU Assembler"), how can I achieve this for c files? Or are there any examples to tell me to achieve this? 
>  
> Thanks.
> Qing  		 	   		  

What architecture?

What do you mean by "32 bit c code" versus "64 bit c code"? If I compile
with the -m32 option I get 32-bit code, and with -m64 I get 64-bit code.

If you are using the x86 architecture, mixing 32-bit functions with
64-bit functions simply does not work. Arguments are passed on the stack
in 32-bit, but in registers (the first six arguments) in 64-bit.

--Bob



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux