Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22009

Necessity of building a cross compiler

$
0
0

I am using a 64 bit linux machine I was doing some operating system development, where it is said that you need to use a cross compiler to generate code for the target system. The barebones tutorial (https://wiki.osdev.org/Bare_bones) instructs one to build a i686-gcc compiler using the native compiler of the host operating system (I believe that it is gcc 7.4.0).

However, one can generate code for other target platforms using gcc itself, eg.

gcc -ffreestanding -c -fno-pie -m32 source.c -o source.o        
ld source.o -o flatbinary.bin -m elf_i386 -Ttext 0x10000 --oformat binary

I believe that the first command creates an ELF object for a 32 bit machine. (Using no standard library? I think that -ffreestanding stands for that) The second command creates a flat binary image where the absolute (virtual?) addresses are offset by 0x10000.

Isn't this what a cross compiler does? Why do I need a separate cross compiler??

Note: I have just ventured into this vast world of compilers, object files, etc. and am just beginning to get an understanding. I might have some concepts fundamentally incorrect. :(


Viewing all articles
Browse latest Browse all 22009

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>