File tree Expand file tree Collapse file tree 4 files changed +54
-6
lines changed
Expand file tree Collapse file tree 4 files changed +54
-6
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,7 @@ OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o}
77CC = /usr/local/i386elfgcc/bin/i386-elf-gcc
88GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb
99# -g: Use debugging symbols in gcc
10- CFLAGS = -g -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs \
11- -Wall -Wextra -Werror
10+ CFLAGS = -g -ffreestanding -Wall -Wextra -fno-exceptions
1211
1312# First rule is run by default
1413os-image.bin : boot/bootsect.bin kernel.bin
Original file line number Diff line number Diff line change @@ -7,4 +7,50 @@ JamesM's tutorial](http://wiki.osdev.org/James_Molloy%27s_Tutorial_Known_Bugs).
77Since we followed his tutorial for lessons 18-22 (interrupts through malloc), we'll
88need to make sure we fix any of the issues before moving on.
99
10+ 1 . Wrong CFLAGS
11+ ---------------
12+
13+ We add ` -ffreestanding ` when compiling ` .o ` files, which includes ` kernel_entry.o ` and thus
14+ ` kernel.bin ` and ` os-image.bin ` .
15+
16+ Before, we disabled libgcc (not libc) through the use of ` -nostdlib ` and we didn't re-enable
17+ it for linking. Since this is tricky, we'll delete ` -nostdlib `
18+
19+
20+ 2 . Not setting a stack
21+ ----------------------
22+
23+
24+
25+ 3 . kernel.c ` main() ` function
26+ -----------------------------
27+
28+ Modify ` kernel/kernel.c ` and change ` main() ` to ` kernel_main() ` since gcc recognizes "main" as
29+ a special keyword and we don't want to mess with that.
30+
31+ Change ` boot/kernel_entry.asm ` to point to the new name accordingly.
32+
33+ To fix the ` i386-elf-ld: warning: cannot find entry symbol _start; defaulting to 0000000000001000 `
34+ warning message, add a ` global _start; ` and define the ` _start: ` label in ` boot/kernel_entry.asm ` .
35+
36+ 4 . Reinvented datatypes
37+ -----------------------
38+ <stddef.h> to provide size\_ t
39+
40+
41+
42+ 5 . Missing functions
43+ --------------------
44+
45+ 6 . Interrupt handlers
46+ ---------------------
47+ - also cli, sti in interrupt handlers
48+
49+
50+ 7 . Structs and attributes
51+ -------------------------
52+
53+ 8 . Improperly aligned ` kmalloc `
54+ -------------------------------
55+
1056
Original file line number Diff line number Diff line change 1+ global _start ;
12[bits 32]
2- [extern main] ; Define calling point. Must have same name as kernel.c 'main' function
3- call main ; Calls the C function. The linker will know where it is placed in memory
4- jmp $
3+
4+ _start:
5+ [ extern kernel_main ] ; Define calling point. Must have same name as kernel.c 'main' function
6+ call kernel_main ; Calls the C function. The linker will know where it is placed in memory
7+ jmp $
Original file line number Diff line number Diff line change 44#include "../libc/string.h"
55#include "../libc/mem.h"
66
7- void main () {
7+ void kernel_main () {
88 isr_install ();
99 irq_install ();
1010
You can’t perform that action at this time.
0 commit comments