Page 1 of 1

coff header

Posted: Tue Jan 27, 2004 10:28 pm
by shaz
i'm trying to write loader for coff-go32 format.
in the linker script i specify 3 sections.but when i read coff header,it shows that there are 4 sections.
here are commands for compiling and linking c and asm files.

Code: Select all

gcc  -c kernel_c.c
NASM -f coff kernel.asm
ld  -o k.o -Tlinker.ld kernel.o kernel_c.o
here is my linker script.

Code: Select all

OUTPUT_FORMAT("coff-go32")
ENTRY(_start)
SECTIONS
{
  .text 0x100000 : {
    *(.text)
  }
  .data  : {
    *(.data)
  }
  .bss  :
  {                
    *(.bss)
  }
}

please tell why it is showing 4 sections and what might be the 4th section.

Re:coff header

Posted: Tue Jan 27, 2004 11:48 pm
by shaz
the 4th section added is .comment section.
what does this section contain.is it added by default because in limker script there is nothing about .comment section.

Re:coff header

Posted: Wed Jan 28, 2004 2:23 am
by df
.comment == comment.

nasm adds comments to its objects, basically saying what something like 'nasm 0.98' or something. you can strip it out if you want. it wont be loaded either.

Re:coff header

Posted: Wed Jan 28, 2004 3:15 am
by shaz
here are steps which i'll follow to load statically linked coff kernel.
1) i'll get no.of sections from coff file header

2)then i'll read initial entry point from a.out file header

3)by using the "section offset" fields,i'll load .code,.data and .bss sections to desired physical addresses(pointed to by "physical addresses of sections" field in section header.

4)then i'll jump to initial entry point obtained from a.out header.

are these steps correct to load a statically linked coff kernel.