So I'm following this tutorial on rolling out your own toy unix.
I'm stuck at compiling the sample source on this page. This is a download link to the sample source code
The Makefile looks like this:
SOURCES=boot.o main.o
CC=gcc
CFLAGS=-nostdlib -nostdinc -fno-builtin -fno-stack-protector
LDFLAGS=-Tlink.ld
ASFLAGS=-felf
all: $(SOURCES) link
clean:
-rm *.o kernel
link:
ld $(LDFLAGS) -o kernel $(SOURCES)
.s.o:
nasm $(ASFLAGS) $<
On OSX I couldn't manage to make
because Apple's ld doesn't support a -T
switch. I tried compiling on CentOS and I got this:
[gideon@centosbox src]$ make
nasm -felf boot.s
cc -nostdlib -nostdinc -fno-builtin -fno-stack-protector -c -o main.o main.c
main.c:4: warning: 'struct multiboot' declared inside parameter list
main.c:4: warning: its scope is only this definition or declaration, which is probably not what you want
ld -Tlink.ld -o kernel boot.o main.o
boot.o: could not read symbols: File in wrong format
make: *** [link] Error 1
Of course my only problem is File in wrong format.
What does this mean? How do I correct it?
objdump -f
with the objects*.o
to see what format they are. about the -T flag – Alex Oct 16 '13 at 20:46-segaddr
-seg_page_size
-sectalign
ld – Alex Oct 16 '13 at 20:55