I'm currently developing a 64 bit Kernel with some success, but as complexity grows, more and more stuff have to be done before switching to longmode (especially memory management). So I decided to write some 32Bit C-Code instead of assembler for this, but now the linker complains, that it cannot link 32 with 64 bit code. There was no problem when writing 32/64bit assembler, even mixed in a single file, so I think it should be possible with C, too. Any solution is welcome, my guess is some kind of converting the 32bit object-file to 64bit, but I dont know how to do that. Any Ideas?
(System: Linux, GCC, ld... standard...)
linking 32/64 bit
Re: linking 32/64 bit
Krox wrote:I'm currently developing a 64 bit Kernel with some success, but as complexity grows, more and more stuff have to be done before switching to longmode (especially memory management). So I decided to write some 32Bit C-Code instead of assembler for this, but now the linker complains, that it cannot link 32 with 64 bit code. There was no problem when writing 32/64bit assembler, even mixed in a single file, so I think it should be possible with C, too. Any solution is welcome, my guess is some kind of converting the 32bit object-file to 64bit, but I dont know how to do that. Any Ideas?
(System: Linux, GCC, ld... standard...)
Hi,
I am currently developing a custom linker for exactly the same need - I need to mix 16, 32 and 64 bit code for my bootloader. I am on Windows, and the MS linker chokes on 16-bit object files that contain relocations, and also does not support cross-linking (ie. mixing 32-bit and 64-bit object files). I have tried the DJGPP toolchain as well to no avail (but that was a year ago, I dont know if support for mixing object files has changed since).
Re: linking 32/64 bit
actually, I have found a solution at least for 32/64 bit. The following will convert 32 bit elf files (and possibly others) to 64 bit.
But anyway, a custom linker sounds interesting, cause there are several other little shortcomings with ld I think. Is there anything to show/test already?
Code: Select all
objcopy -O elf64-x86-64 filename.obj
Re: linking 32/64 bit
Actually, in a few days the linker should be ready. Far from complete, but functional. However in its current form it only handles COFF object files (and outputs PE images). I'm interested in making it work with ELF files as well, but that is not on top of the list.Krox wrote:actually, I have found a solution at least for 32/64 bit. The following will convert 32 bit elf files (and possibly others) to 64 bit.But anyway, a custom linker sounds interesting, cause there are several other little shortcomings with ld I think. Is there anything to show/test already?Code: Select all
objcopy -O elf64-x86-64 filename.obj
Re: linking 32/64 bit
I have a working copy of the linker available (it is still a "beta version" though). If anyone wants to try it out, please feel free to. A more detailed description and howto is included in the archive file.
Summary:
- links COFF object files containing 16-bit, 32-bit and 64-bit code together
- generates PE/COFF image file, to get the raw image use some helper program (one such program is included in the archive).
- you need a .NET environment to run the linker
- intended at those who develop on Windows and use the MS toolchain
(edit) See files in later post.
Summary:
- links COFF object files containing 16-bit, 32-bit and 64-bit code together
- generates PE/COFF image file, to get the raw image use some helper program (one such program is included in the archive).
- you need a .NET environment to run the linker
- intended at those who develop on Windows and use the MS toolchain
(edit) See files in later post.
Last edited by ru2aqare on Sat Jul 19, 2008 2:06 pm, edited 1 time in total.
Re: linking 32/64 bit
Any chance of the source code?
Re: linking 32/64 bit
Here is the source (and also the updated binaries). The source is GPL - do whatever you want with it (some feedback would be nice though). You will need the helper dll if you want to compile it.Kieran wrote:Any chance of the source code?
- Attachments
-
- Linker_b563.part03.rar
- Source + binaries.
- (13.83 KiB) Downloaded 143 times
-
- Linker_b563.part02.rar
- Source + binaries.
- (63.48 KiB) Downloaded 107 times
-
- Linker_b563.part01.rar
- Source + binaries.
- (63.48 KiB) Downloaded 104 times