Would this even be possible to write a linker that could link 64bit and 32bit object files?
elf32 + elf64 -> elf32 || elf64
mixed linker?
mixed linker?
Working On:Bootloader, RWFS Image Program
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: mixed linker?
Not sure... but I do link my elf64 object files into an elf32 for my multiboot bootloader. It hasn't given me any trouble.
Re: mixed linker?
what linker do you use? ld won't do that...
Working On:Bootloader, RWFS Image Program
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: mixed linker?
GNU ld. Works fine with a linker script.
Here's an excerpt from mine:
Here's an excerpt from mine:
I can even put 32-bit assembly code in there (and 16-bit with some tweaks).OUTPUT_FORMAT(elf32-i386)
OUTPUT_ARCH(i386:x86-64)
Re: mixed linker?
Awesome, could this be used as a technique to do boot a kernel with grub? I might want to add this to add this to the wiki...
Working On:Bootloader, RWFS Image Program
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: mixed linker?
I guess so. The one problem I can see is that everything has to be identity mapped. This isn't a problem for a bootloader, but a long mode kernel would usually be loaded in the higher half, and grub won't be about to do that (unless you have memory up to 0xFFFF800000000000). The only reason I bother with elf64 -> elf32 instead of elf32 -> elf32 in my bootloader is that 64-bit C code needs to be compiled to elf64.
Re: mixed linker?
My kernel is not higher half, so it works for me. I'm gonna attempt it right now so let's see what happens.
Working On:Bootloader, RWFS Image Program
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
Re: mixed linker?
Oh, this is just converting a 64 bit to 32 bit elf not mixed linking?
Working On:Bootloader, RWFS Image Program
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: mixed linker?
I was linking a series of elf64 files into an elf32 using ld. No objcopy or anything like that. You might be able to link elf64 and elf32 files together by doing it in 3 stages: link the elf32s into one relocatable elf32 file, link the elf64s into one relocatable elf32 file, then link the two relocatable elf32s into another elf32.