Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Development Problem in OS

2 views
Skip to first unread message

abhi

unread,
Apr 26, 2007, 9:31:41 AM4/26/07
to
I am creating a small OS for my end semester project. I start with a
small tutorial found on internet. First i created a Assembly Code as
entry point for my OS. The assembly code is as follows, this code is
used by GRUB to load the kernel. The code is as follows:

*************************************************************************************************************
[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.
dd mboot
dd code
dd bss
dd end
dd start

stublet:
jmp $


SECTION .bss
resb 8192 ; This reserves 8KBytes of memory here
_sys_stack:

**************************************************************************************************************
I save this code in file name start.asm. I compiled this file into
start.o using NASM, using following command
nasm -f aout -o start.o start.asm

Then I created a linker script file named link.ld. Code is as follows
**************************************************************************************************************
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 = .;
}
**************************************************************************************************************
After creating this file i use LD linker using this command

ld -T link.ld -o kernel.bin start.o

The problem is that when use above command it gives me error :

start.o: file not recognized: File format not recognized

I am stuck at this point as i am not very good in Assembly language
and this linker stuff.
Please Help Me with this problem.

0 new messages