Sender: nate AT cartsys DOT com Message-ID: <35F744ED.AEEB7D22@cartsys.com> Date: Wed, 09 Sep 1998 20:18:05 -0700 From: Nate Eldredge MIME-Version: 1.0 To: Florian Janoschek CC: djgpp AT delorie DOT com Subject: Re: stub ? References: <35f6b251 DOT 0 AT news DOT zeitung-online DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Florian Janoschek wrote: > > Hello, > > since I use djgpp I read quite often the word "stub" and everything I > (believe to) know about it is that it has something to do with the startup > code and PM. Could someone give me a short definition of "stub" please... The code generated by GCC expects to start in protected mode, and is in COFF format. DOS expects the programs it loads to start in real mode, and be in EXE format. The stub is the way of reconciling the two. When an executable is created, it gets a 2K chunk of code and data prepended to the beginning. This is the stub. It contains an EXE header which tells DOS to load only the first 2K of the file (which is of course the stub). It also has real-mode code to load a DPMI server if necessary, switch to protected mode, allocate the necessary DPMI memory, and load the actual COFF image from its location in the file. You can look at its source with the DJLSR archive (though be warned that much of it is difficult to understand. The `test ax, ax' bit, for example.) -- Nate Eldredge nate AT cartsys DOT com