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?
Problem in using cross compiler.
-
- Member
- Posts: 255
- Joined: Tue Jun 15, 2010 9:27 am
- Location: Flyover State, United States
- Contact:
Re: Problem in using cross compiler.
I have no idea what this means. I would say no.piyushneo wrote: 1. Do i have to build cross compiler up to stage 1 or 2 ?
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.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.
Use a linker script to lay out your sections. You can tell it what the physical and virtual addresses are for each section.3. As kernel is loaded at 0x00100000. How to set base address with this cross compiler?
Re: Problem in using cross compiler.
Sorry a typo..i meant step 1 or 2 ( given on link above)...though i knew its answer now.1. Do i have to build cross compiler up to stage 1 or 2 ?
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?Use a linker script to lay out your sections. You can tell it what the physical and virtual addresses are for each section.
Thanks for replying..
Re: Problem in using cross compiler.
If I recall correctly the tutorial in the wiki shows you how to build a cross compiler which will output 32-bit ELF files.piyushneo wrote:When i will compile through cross compiler, will the section term still be valid as it is no more efl ?Use a linker script to lay out your sections. You can tell it what the physical and virtual addresses are for each section.
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.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Problem in using cross compiler.
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.
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.