Merge pull request #1 from dubr0vin/main
Добавить возможность собирать ядро через llvm.
This commit is contained in:
commit
d5e48ba5ef
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 \
|
||||||
@ -68,13 +84,13 @@ image.bin: mbr.bin fs.img
|
|||||||
|
|
||||||
kernel.bin: kernel.o console.o drivers/vga.o drivers/uart.o drivers/keyboard.o \
|
kernel.bin: kernel.o console.o drivers/vga.o drivers/uart.o drivers/keyboard.o \
|
||||||
cpu/idt.o cpu/vectors.o lib/mem.o
|
cpu/idt.o cpu/vectors.o lib/mem.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 $@
|
||||||
|
|||||||
19
README.md
19
README.md
@ -1,12 +1,25 @@
|
|||||||
Yet Another BootLoader, OS Kernel and Other stuff
|
# Yet Another BootLoader, OS Kernel and Other stuff
|
||||||
|
|
||||||
Quickstart:
|
## Quickstart:
|
||||||
```
|
```
|
||||||
$ ./setup.sh
|
$ ./setup.sh
|
||||||
$ make
|
$ make
|
||||||
```
|
```
|
||||||
|
## How to run using llvm
|
||||||
|
|
||||||
Includes code from:
|
You can use this way even if you have windows. You need to install llvm and qemu.
|
||||||
|
Check that executables `clang`, `ld.lld`, `qemu-system-i386` available from your terminal/console.
|
||||||
|
|
||||||
|
```
|
||||||
|
make LLVM=on
|
||||||
|
```
|
||||||
|
|
||||||
|
## How to debug in my favorite IDE
|
||||||
|
|
||||||
|
Start debug server using command `make debug-server` or `make debug-server-nox` if you don't want to see gui, and
|
||||||
|
then connect using remote gdb option to localhost:1234 (symbols file is kernel.bin)
|
||||||
|
|
||||||
|
## Includes code from:
|
||||||
* https://github.com/mit-pdos/xv6-public
|
* https://github.com/mit-pdos/xv6-public
|
||||||
* https://github.com/FRosner/FrOS
|
* https://github.com/FRosner/FrOS
|
||||||
* https://github.com/dhavalhirdhav/LearnOS
|
* https://github.com/dhavalhirdhav/LearnOS
|
||||||
|
|||||||
25
script.ld
Normal file
25
script.ld
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text (0x1000) : {
|
||||||
|
*( .text )
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata : {
|
||||||
|
_RODATA_START_ = .;
|
||||||
|
*(.rodata)
|
||||||
|
_RODATA_START_ = .;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
_DATA_START_ = .;
|
||||||
|
*(.data)
|
||||||
|
_DATA_END_ = .;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.bss : ALIGN(CONSTANT(MAXPAGESIZE)) {
|
||||||
|
_BSS_START_ = .;
|
||||||
|
*(.bss)
|
||||||
|
_BSS_END_ = .;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user