A few days ago I bought a laptop (Windows 8, Intel Pentium N3530, 64-bit), also I have another laptop (Windows 8 and 64-bit too, but on Intel Core i5), and an old computer (Ubuntu 12.04 32-bit, AMD Athlon 64 3000+ as BIOS says when booting).
I'm using VirtualBox on laptops to run Linux Mint 17 64-bit, and I'm writing a 32-bit operating system, so I compile it using Clang or GCC with -m32 flag and NASM with -elf32.
More to the point. The problem is that my OS runs differently on computer&laptop and new laptop. On computer and laptop it runs successfully, but on the new laptop it stops after page fault. I use the same compiler (Clang) on these three machines, also tried cross-compiler (i686-elf-*), but on the new laptop the OS stops with strange page fault. After debugging with printing messages, I concluded that the page fault is caused after returning from some function.
I think that the problem is not in the code, but in compiling and/or linking. So, my Makefile on the new laptop:
Code: Select all
# This Makefile compiles files in "src" directory.
CROSS = i686-elf-
CC = $(CROSS)gcc
CC = clang # I know... But the result is the same as without this string.
CFLAGS = -Wall -m32 -c -ffreestanding -Iinclude/ -nostdlib
ASOURCES = $(wildcard src/*.asm)
AOBJECTS = $(ASOURCES:.asm=.o)
CSOURCES = $(wildcard src/*.c)
COBJECTS = $(CSOURCES:.c=.o)
ASOURCES2 = $(wildcard src/*/*.asm)
AOBJECTS2 = $(ASOURCES2:.asm=.o)
CSOURCES2 = $(wildcard src/*/*.c)
COBJECTS2 = $(CSOURCES2:.c=.o)
OBJECTS = $(AOBJECTS) $(AOBJECTS2) $(COBJECTS) $(COBJECTS2)
OUTPUT = ../bin/kernel.bin
ALLOBJECTS1 = $(wildcard src/*.o)
ALLOBJECTS2 = $(wildcard src/*/*.o)
ALLOBJECTS = $(ALLOBJECTS1) $(ALLOBJECTS2)
ASM = nasm
AFLAGS = -f elf32
LN = $(CROSS)ld
LFLAGS = -T linker.ld -o $(OUTPUT) $(OBJECTS)
all: build
build: $(OBJECTS)
$(LN) $(LFLAGS)
@../disk.sh ../
%.o: %.asm
$(ASM) $(AFLAGS) $< -o $@
%.o: %.c
$(CC) $(CFLAGS) $< -o $@
clean:
rm -rf $(ALLOBJECTS) $(OUTPUT)
Code: Select all
$ qemu-system-i386 -boot cd -cdrom disk/ouros.iso -m 64