Page 1 of 1
Problem in using cross compiler.
Posted: Sat Jan 29, 2011 10:08 am
by piyushneo
I am following the OS development tutorial at
http://www.brokenthorn.com/Resources/OSDevIndex.html . After completing bootloader they have used MS Visual C++ to develp kernal further and given instruction to setup Runtime Environment for the same. But i am working on a Linux Platform ( Ubutnu) and will be using gcc for my kernal development. I read a great article about GCC Cross-compiler
http://wiki.osdev.org/GCC_Cross-Compiler on this site which seems to be solution for my problem but i have few doubts regarding that :
1. Do i have to build cross compiler up to stage 1 or 2 ?
2. Will the binary generated be a flat binary i.e i need not to parse the kernal file in order to get the entry point , just start executing with the first byte of file.
3. As kernel is loaded at 0x00100000. How to set base address with this cross compiler?
Re: Problem in using cross compiler.
Posted: Sat Jan 29, 2011 11:32 am
by Tosi
piyushneo wrote:
1. Do i have to build cross compiler up to stage 1 or 2 ?
I have no idea what this means. I would say no.
2. Will the binary generated be a flat binary i.e i need not to parse the kernal file in order to get the entry point , just start executing with the first byte of file.
You can tell the linker whether to generate a flat binary or an actual executable format. I do not recommend making a flat binary kernel.
3. As kernel is loaded at 0x00100000. How to set base address with this cross compiler?
Use a linker script to lay out your sections. You can tell it what the physical and virtual addresses are for each section.
Re: Problem in using cross compiler.
Posted: Sat Jan 29, 2011 12:03 pm
by piyushneo
1. Do i have to build cross compiler up to stage 1 or 2 ?
Sorry a typo..i meant step 1 or 2 ( given on link above)...though i knew its answer now.
Use a linker script to lay out your sections. You can tell it what the physical and virtual addresses are for each section.
When i will compile through cross compiler, will the section term still be valid as it is no more efl ? i mean can i use the same script which is used for elf format?
Thanks for replying..
Re: Problem in using cross compiler.
Posted: Sat Jan 29, 2011 3:14 pm
by Graham
piyushneo wrote:Use a linker script to lay out your sections. You can tell it what the physical and virtual addresses are for each section.
When i will compile through cross compiler, will the section term still be valid as it is no more efl ?
If I recall correctly the tutorial in the wiki shows you how to build a cross compiler which will output 32-bit ELF files.
I just use gcc/clang and ld from the Ubuntu repositories and set the appropriate flags (-m32 and -ffreestanding for the C compiler and -melf_i386 for ld) to make them produce 32 bit code without relying on the host operating system's libraries, which seems to be working fine and avoids all the hassle :p.
Re: Problem in using cross compiler.
Posted: Sat Jan 29, 2011 5:42 pm
by Combuster
If you use the host compiler, you can still drag in linux-specific code. The arguments will not prevent such errors. Also, the arguments look like they expect an amd64 toolchain - it might not work on 32-bit linux, it will not work if you have an relatively old version of gcc, it will not work under windows, and it will not work on non-intel platforms. I won't start about clang/llvm as it can be rather unfriendly to anyone trying to get one to work.
In any case, the cross-compiler requires no arguments that you can forget, will never drag in references to your host unless you explicitly tell it to, and will work the same on any platform.