Add llvm build support
This commit is contained in:
parent
4c075b8b6f
commit
a8db9b0b08
20
Makefile
20
Makefile
@ -10,6 +10,16 @@ endif
|
|||||||
CFLAGS = -fno-pic -ffreestanding -static -fno-builtin -fno-strict-aliasing \
|
CFLAGS = -fno-pic -ffreestanding -static -fno-builtin -fno-strict-aliasing \
|
||||||
-Wall -ggdb -m32 -Werror -fno-omit-frame-pointer
|
-Wall -ggdb -m32 -Werror -fno-omit-frame-pointer
|
||||||
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
|
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
|
||||||
|
ASMFLAGS = -m32 -ffreestanding -c -g
|
||||||
|
|
||||||
|
ifeq ($(LLVM),on)
|
||||||
|
#AS=llvm-as
|
||||||
|
LD=ld.lld
|
||||||
|
CC=clang
|
||||||
|
CFLAGS += -target elf-i386
|
||||||
|
ASMFLAGS = -target elf-i386 -ffreestanding -c -g
|
||||||
|
LDKERNELFLAGS = --script=script.ld
|
||||||
|
endif
|
||||||
|
|
||||||
run: image.bin
|
run: image.bin
|
||||||
qemu-system-i386 -drive format=raw,file=$< -serial mon:stdio
|
qemu-system-i386 -drive format=raw,file=$< -serial mon:stdio
|
||||||
@ -41,6 +51,12 @@ debug-boot: image.bin mbr.elf
|
|||||||
-ex "break *0x7c00" \
|
-ex "break *0x7c00" \
|
||||||
-ex "continue"
|
-ex "continue"
|
||||||
|
|
||||||
|
debug-server: image.bin
|
||||||
|
qemu-system-i386 -drive format=raw,file=$< -s -S
|
||||||
|
|
||||||
|
debug-server-nox: image.bin
|
||||||
|
qemu-system-i386 -nographic -drive format=raw,file=$< -s -S
|
||||||
|
|
||||||
debug: image.bin
|
debug: image.bin
|
||||||
qemu-system-i386 -drive format=raw,file=$< -s -S &
|
qemu-system-i386 -drive format=raw,file=$< -s -S &
|
||||||
$(GDB) kernel.bin \
|
$(GDB) kernel.bin \
|
||||||
@ -67,13 +83,13 @@ image.bin: mbr.bin fs.img
|
|||||||
cat $^ >$@
|
cat $^ >$@
|
||||||
|
|
||||||
kernel.bin: kernel.o console.o drivers/vga.o drivers/uart.o
|
kernel.bin: kernel.o console.o drivers/vga.o drivers/uart.o
|
||||||
$(LD) $(LDFLAGS) -o $@ -Ttext 0x1000 $^
|
$(LD) $(LDFLAGS) $(LDKERNELFLAGS) -o $@ -Ttext 0x1000 $^
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
%.o: %.S
|
%.o: %.S
|
||||||
$(CC) -m32 -ffreestanding -c -g $^ -o $@
|
$(CC) $(ASMFLAGS) $^ -o $@
|
||||||
|
|
||||||
mbr.bin: mbr.o
|
mbr.bin: mbr.o
|
||||||
$(LD) -m elf_i386 -Ttext=0x7c00 --oformat=binary $^ -o $@
|
$(LD) -m elf_i386 -Ttext=0x7c00 --oformat=binary $^ -o $@
|
||||||
|
|||||||
24
script.ld
Normal file
24
script.ld
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text (0x1000) : {
|
||||||
|
startup.o( .text )
|
||||||
|
}
|
||||||
|
|
||||||
|
.data : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
_DATA_START_ = .;
|
||||||
|
*(.data)
|
||||||
|
_DATA_END_ = .;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
_RODATA_START_ = .;
|
||||||
|
*(.rodata)
|
||||||
|
_RODATA_START_ = .;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bss : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
_BSS_START_ = .;
|
||||||
|
*(.bss)
|
||||||
|
_BSS_END_ = .;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user