Mail Archives: djgpp/2006/03/03/14:15:19
Chris Giese <NoEmailAds AT execpc DOT com> wrote:
Oooh, Chris is back!
> Yes ("ld --oformat binary ..."), but don't do it. If you make a COFF
> file, you can run objdump on it to make sure it's linked properly.
> Also, there's no good way to determine the size of a plain-binary
> kernel (because there's no header that gives you the BSS size).
Well, it's sufficiently good for me with this linker script (you don't
need a header):
ENTRY(start)
SECTIONS
{
.text 0 : {
stack.o(.stack)
entry.o(.text)
*(.text)
etext = . ; _etext = .;
. = ALIGN(0x8);
}
.data ALIGN(0x8) : {
*(.data)
. = ALIGN(0x8);
edata = . ; _edata = .;
}
.bss SIZEOF(.data) + ADDR(.data) :
{
. = ALIGN(0x8);
*(.bss)
*(COMMON)
. = ALIGN(0x1000);
end = . ; _end = .;
}
}
With that you have the size of the BSS (e. g. ) as
unsigned char end[], edata[];
unsigned long size_of_bss(void)
{
unsigned long size = end - edata;
return size;
}
>>> You want a cross compiler, not a native compiler. You probably want
>>> to build an i386-elf compiler that runs on djgpp.
> I disagree. For simple OS development (no dynamic linking),
> ELF has no compelling advantage over COFF.
Indeed, with that linker script (or a variation thereof) plus some
loader and setup 32-bit PM, you're not depending on any output
format.
Obviously you can't call any DJGPP function (except for those that are
OS independed or whatever the term is) and get away with it. But as
you're coding your own OS you need to provide your own functions
anyway.
Right,
MartinS
- Raw text -