The first problem is that Mac OS X executables have Mach-O header and Linux executables have an ELF header. Also, Mac OS X is a 64-bit operating system and James's tutorials are based on x86. The linker that is installed by default is not the GNU Linker and thus does not support various options such as -T.
To fix this we should first install Mac Ports to make installing some ports a bit easier. Mac ports can be found here:
http://www.macports.org/
Now we need to install i386-elf-gcc and i386-elf-ld by issuing the following command:
Code: Select all
sudo port install i386-elf-gcc i386-elf-ld
We now need to modify the makefile:
Code: Select all
SOURCES=boot.o main.o
CC=i386-elf-gcc-4.3.2
CFLAGS=-nostdlib -nostdinc -fno-builtin -fno-stack-protector -m32 -c
LDFLAGS=-Tlink.ld -melf_i386
ASFLAGS=-felf
all: $(SOURCES) link
clean:
-rm *.o kernel
link:
i386-elf-ld $(LDFLAGS) -o kernel $(SOURCES)
.s.o:
nasm $(ASFLAGS) $<
Code: Select all
loc=`hdid -nomount ../bin/floppy.img`
`sudo mount -t fuse-ext2 $loc /mnt2`
cp ../bin/kernel /mnt2/kernel
umount /mnt2
Code: Select all
loc=`hdid -nomount ../bin/floppy.img`
`sudo mount -t fuse-ext2 $loc /mnt2`
sudo bochs -f bochsrc.txt
Code: Select all
http://sourceforge.net/projects/fuse-ext2/
Code: Select all
OPTIONS="auto_xattr,defer_permissions"
Code: Select all
OPTIONS="auto_xattr,defer_permissions,rw+"
Code: Select all
memory: guest=32, host=32
romimage: file=/usr/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/share/bochs/VGABIOS-elpin-2.40
floppya: 1_44=floppy.img, status=inserted
boot: a
log: bochsout.txt
mouse: enabled=0
clock: sync=realtime
cpu: ips=500000
https://github.com/larsr/bochs/tree/master/bios
If you are using Mac OS X Mountain Lion (10. you should install XQuartz as a replacement for x-11:
Code: Select all
http://xquartz.macosforge.org/landing/
Instead of using /dev/loop0 you could also refer directly to the floppy image. Also vgaromimage: must start with file=. And megs is outdated and is
replaced by memory.