*************************************************************************************************************
[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.