Question

I'm trying to write some "free standing" (What is the name for a program running directly without an OS?) code, and seeing as the OS-X linker has no support for linker scripts or flat binary output, I assume it would be best to use the GNU linker instead.

Is there a way to install/compile just the GNU linker without all of GCC?

Will a compiled GNU linker be able to understand the object files output by the OS-X version of the GAS assembler?

What is the best way to compile GCC if I can't just compile the linker?

Note: I want to compile, not use a package system.

Was it helpful?

Solution

I'm using the cross/i386-elf-gcc and cross/i386-elf-binutils ports from MacPorts for this purpose in an experimental pet kernel project of mine, using these in my Makefile:

CC=             i386-elf-gcc-4.3.2
AS=             i386-elf-as
LD=             i386-elf-ld

I have not even attempted to mix and match components from different toolchains. You may be able to get it to work somehow, but it does not seem to be worth the trouble if you can just install a "clean" set of cross-compiling tools and be reasonably sure that they will play nicely with each other.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top