Here is the output from make:
Code: Select all
aurdal@tree:~/Dev/OS$ make
nasm -f elf -o start.o start.asm
gcc -m32 -fno-stack-protector -fno-builtin -nostdinc -O -g -Wall -I. -c -o main.o main.c
gcc -m32 -fno-stack-protector -fno-builtin -nostdinc -O -g -Wall -I. -c -o scrn.o scrn.c
gcc -m32 -fno-stack-protector -fno-builtin -nostdinc -O -g -Wall -I. -c -o gdt.o gdt.c
ld -melf_i386 -nostdlib -N -Ttext 100000 -T link.ld -o kernel.bin start.o main.o scrn.o gdt.o
ld: warning: cannot find entry symbol start; defaulting to 0000000000100000
gdt.o: In function `gdt_install':
/aurdal/Desktop/Dev/gdt.c:77: undefined reference to `gdt_flush'
make: *** [kernel.bin] Error 1
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(phys + (data - code)) {
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code)) {
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
Code: Select all
; This is the kernel's entry point. We could either call main here,
; or we can use this to setup the stack or other nice stuff, like
; perhaps setting up the GDT and segments. Please note that interrupts
; are disabled at this point: More on interrupts later!
[BITS 32]
[global start]
start:
mov esp, _sys_stack ; This points the stack to our new stack area
jmp stublet
; This part MUST be 4byte aligned, so we solve that issue using 'ALIGN 4'
ALIGN 4
mboot:
; Multiboot macros to make a few lines later more readable
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
EXTERN code, bss, end
; This is the GRUB Multiboot header. A boot signature
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; AOUT kludge - must be physical addresses. Make a note of these:
; The linker script fills in the data for these ones!
dd mboot
dd code
dd bss
dd end
dd start
stublet:
extern cmain
call cmain
jmp $
; Code for loading the GDT.
global gdt_flush ; Allows the C code to link to this
extern gp ; Says that '_gp' is in another file
gdt_flush:
lgdt [gp] ; Load the GDT with our '_gp' which is a special pointer
mov ax, 0x10 ; 0x10 is the offset in the GDT to our data segment
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp 0x08:flush2 ; 0x08 is the offset to our code segment: Far jump!
flush2:
ret ; Returns back to the C code!
; Here is the definition of our BSS section. R
SECTION .bss
resb 8192 ; This reserves 8KBytes of memory here
_sys_stack:
I thank you all in advance.