Re: link 32bit .o with 64bit .o

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

 



GuoMinskey <minskey_guo@xxxxxxxxxxx> writes:

> On x86 platform, Âis there any means to link 32 bit ELF output intoÂ64 bit Â?
> In Linux kernel, Âarch/x86/boot/compressed/head_64.S, Â starts from32-bit codeÂand enables CPU to jump into 64-bit. ÂSo, that file isÂassembledÂinto 64 bit ELFÂobject with mixed 32/64 bit code.
> Now, I want to call a routine from somewhere in the 32bit code partÂof head_64.S. Â ÂAnd I write the routine by C language, Âsay test.cÂand compile Âit with "gcc -m32 -c -o test.o". Â ÂHow can I link mytest.o to head_64.o ? ÂOr I have to use assembly language to rewritemy routine and embed it directly into head_64.S source code ?

On x86, 32-bit code can not call 64-bit code, nor vice-versa.  The Linux
kernel uses some tricks to start up in 32-bit mode, convert to 64-bit
mode, and branch to 64-bit code as it converts.  You can't do the same
tricks yourself; only the kernel can do them.

So, the answer is that you can link 32-bit and 64-bit code together
easily enough, using the linker's -b option as the kernel build does,
but you can't do anything useful with the result.

Ian



[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