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]

 



Thank Andrew.
For how to change modes, it is OK because we can load new gdt/cs/ds/..., change MSR_EFER and stack, and do long jump.
For how to link two different versions of libc, I don't know why I have this issue. I write my code, even including early_printk().I don't call any library. In all c files, I only include my .h files without any .h files in the library.
For the fact a binary is either 32- or 64-bit, I maybe make you confused. I admit we can't link a 32-bit object with a 64-bit object. I just want to implement the same functionality of ".code32" and ".code64" in assembly.
As you know, I can define a section in assembly as 32-bit code, then the compiler (or GAS?) will regard the part as 32 bit. Likewise, I also can define a section as 64-bit code in the same assembly file.
For example, in the same assembly file, we can write as follows.
ENTRY(entry32)  .code32  mov $8, %eax  .code64  mov $8, %rax
Then when running, the first "mov" will be regarded as 32 bit instruction and the second as 64-bit.
Maybe my title is wrong, I just want to find how to achieve in c files. Can I do as follows?
#include <xxx.h>
asm(".code32")void f1(...){...}
asm(".code64")void f2(...){...}
Thanks again.Qing
> Date: Thu, 7 Jan 2010 10:36:03 +0000
> From: aph@xxxxxxxxxx
> To: qinggwang@xxxxxxxxxxx
> CC: gcc-help@xxxxxxxxxxx
> Subject: Re: How to compile and link 32 bit c code with 64 bit c code
> 
> On 01/07/2010 10:28 AM, Andrew Haley wrote:
>> On 01/07/2010 05:46 AM, Qing Wang wrote:
>>>  
>>> What if I have no shared library in the project?
>>> All code is written by us, you can regard it as a small kernel.
>> 
>> Even if every byte in the executable is yours, you'll still have to
>> figure out how to link two different versions of libgcc (and libc?)
>> into an executable and out how to change modes within a running
>> process.
> 
> And besides, how are you going to do this without shared libraries?
> A binary is either 32- or 64-bit.
> 
> Andrew.
 		 	   		  
_________________________________________________________________
Keep your friends updated—even when you’re not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010


[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