Page 1 of 1

Help with COFF Images.

Posted: Fri Mar 19, 2004 10:38 am
by astrocrep
Im not new to the os scene... ive been hacking away at MMURTL for sometime now... and Ive come to the point where theres alot of things I don't like... (some I do... but thats another story). Anyway Ive decided I want to start from scratch and design my own OS from the ground up. Taking one task at a time.

This is what I want to do.

Bootsect (realmode) -> Loader (realmode) -> kernel (pmode)

I am using A.A. Frounze's Simple bootsector and the OSLoader 4 Dummies (I dunno if its a good Idea, but I really like the work he's done, and It would save me time later on as I want to go straight into kernel programming)

Following his instructions step by step I build a coff file. The code is a simple C file that sets a pointer to video mem and sets a couple of bytes. It compiles fine... without errors or warnings... and links fine... I am using his predefined link script:

Code: Select all

/* Adapted from /djgpp/lib/djgpp.djl */
OUTPUT_FORMAT("coff-go32")
ENTRY(_main)
SECTIONS
{   .text 0x00110000 :
    { *(.text)
 . = ALIGN(4096);
 etext = .; _etext = .; }
    .data :
    { *(.data)
 . = ALIGN(4096);
 edata = .; _edata = .; }
    .bss :
    { *(.bss)
 *(COMMON)
 . = ALIGN(4096);
 end = .; _end = .; }}
Everything goes fine but when I am in the loader program and I try to run my coff file I get the following:

Loading COFF file header
magic : 0x14C
number of sections : 4
symbol table offset : 0x2014
number of symtab entries : 17
size of optional header : 0x1C
flags : 0x107
File must have 3 sections (.text, .data and .bss).

Im not to sure whats going on with this but...

If you guys feel that I am better off using grub and not the 2 stage loader approach... please let me know. Thanks for the help!

Rich

Re:Help with COFF Images.

Posted: Fri Mar 19, 2004 11:44 am
by ASHLEY4
Hi
I like you am a A.A. Frounze fan,I use the bootprog it loads a com/exe from a floppy, and am amazed that more people do not use it.
KEEP IT SIMPLE.
I have not used grub,but i read that it will not work with a kernel that starts in real mode and move to pmode.

ASHLEY4.

Re:Help with COFF Images.

Posted: Fri Mar 19, 2004 1:28 pm
by Therx
i haven't used that loader myself but 0x110000 seems to be a weird load address. Are you sure its not 0x100000

Re:Help with COFF Images.

Posted: Fri Mar 19, 2004 2:41 pm
by astrocrep
ASHLEY4: How do you boot your OS... I mean from Bootsector to ... pmode kernel, do you use gcc ??

Ohh the reason its 0x110000 (Don't count my zeros) is because it loads the kernel at 1mb + 64kb.

Anyway Whats wrong with my coff file? I have all 3 segments declared in the text file... why won't it boot?

Thanks Alot,

Rich

Re:Help with COFF Images.

Posted: Fri Mar 19, 2004 4:35 pm
by aladdin
I have a question about this subject.
how do u do to load ur code at 1Mb ?? coze when boot sector runs in real mod ad can't adresse memoy up to 1Mb ??

I had the same problem but I "temporary" fixed it bymoving bootsector to 0x9000 at boot time the loading kernel to 0x1000.

Re:Help with COFF Images.

Posted: Fri Mar 19, 2004 4:46 pm
by astrocrep
Well the way it works is the bootsect loads the realmode osloader. The osloader reads the kernel from the floppy, setups up pmode, and copies the kernel to the proper mem addr. The problem is The loader claims my kernel isn't a proper coff file, I honestly don't care it I use the os loader but I really like the idea of a 2 stage loading system. However my primary objective which has been thus far unattainable, is using djgpp to compile and link a simplistic kernel, and then gettng the kernel to run (well atleast the first part is done, I just can't get it to run)

** Question **
My real question is what I said in the first post, How the loader says that I must have a .data .text and .bss section Do I actually Define these in a file or just in the linking script?
** Question **
Thanks Alot

Rich P.

Re:Help with COFF Images.

Posted: Fri Mar 19, 2004 10:55 pm
by ASHLEY4
astrocrep wrote: ASHLEY4: How do you boot your OS... I mean from Bootsector to ... pmode kernel, do you use gcc ??
Hi astrocrep
I do not use gcc,I use fasm i assemble the file as a exe or i could assemble it as a com, This assembler has no linker, you just put the extension ,For a exe you would eg:

Code: Select all

 
c:\fasm kernel.asm kernel.exe
It's that easy,I just do the normal things to go from real to pmode.
All the boot load does is looks for a file on the floppy, of a certain name ,
This file can be any where on the floppy, There can be other files on the floppy too, Because it is fat 12 it can be read from windows ,linux, dos etc.
The best bit is that because it is in the 512byte bootsector
and i can still use the floppy as normal,i can make all my floppy's like this,just grab one and put my kernel.exe on and boot it to test it :).
All the Major things for the OS are put include file including a 32 bit atapi driver, now i can put the floppy image on the CD, boot it as if it were a floppy drive load the atapi driver, Fill the rest of the cd with file and load them into memory.
I want keep the kernel very small and keep it in conventional memory, The cd will be used for loading large things like bmp, mp3, etc.

You can get this loader from here:
http://alexfru.chat.ru/epm.html

Called "bootprog.zip"

ASHLEY4.