delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/26/23:30:49

Mime-Version: 1.0
To: Guido <guido DOT de DOT jong AT tip DOT nl>, "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
From: Nate Eldredge <nate AT cartsys DOT com>
Subject: Re: Question about "crt0.s"
Date: Sun, 26 Apr 1998 20:23:16 -0700
Message-ID: <19980427032245.AAL5484@ppp100.cartsys.com>

At 09:11  4/26/1998 +-200, Guido wrote:
>Hello everybody!
>
>I'm writing an operating system using DJGPP. I encountered a problem that I
think has something to do with my version of "crt0.s". In the following text
I will supply you with some details. Please read through to the end so you
might be able to give some advice.

>Whenever I try to call a function that expects parameters things go wrong,
that is the function body will not be executed. I copied the body of the
main function described above into a test function. It works fine as long as
it doesn't take parameters. At first I thought it had to do something with
the stack setup. I tried different ways to load SS:ESP and used different
assemblers (AS, coming with DJGPP, and NASM). I checked and double checked
the resulting code, and I can not find any problems. So I thought it might
not be the stack, but maybe it is the whole "crt0.s".
>
>As a result I have the following questions:
>* What is "crt0" supposed to do? In other words: what do I have to do in my
header to make it work for DJGPP?

Most of what it does doesn't apply to a kernel. All you should need to do,
AFAICT, is to set up the stack. You need SS == DS == ES, and CS to be the
same but with the executable bit set. ESP should point to a sufficiently
large amount of memory.

>* Is there a way to get rid of the linker script and the "__main()"
function? I don't intend to use any C++ code in the kernel, so I don't need
them (or do I?).

I think the linker script is what sets up the sections correctly, so you
can't dispense with it completely. You can delete the constructor/destructor
sections. I think __main just calls constructors, so you can dispense with
that. (GCC will however include a call to __main in `main', so including a
dummy is the easiest solution.)

>* What compiler options can I use best? I use "-ansi -Wall -O2
-fomit-frame-pointer" by default.

That should work well. Depending on your GCC version and CPU, `-m486',
`-mpentium' or something similar might help (I expect not a lot). Try it and
see, if you want.

Nate Eldredge
nate AT cartsys DOT com



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019