Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!samsung!munnari.oz.au!csource!david From: david@csource.oz.au (david nugent) Newsgroups: comp.lang.c Subject: Re: An Ubiquitous C bug Message-ID: <851@csource.oz.au> Date: 22 Jan 91 03:36:54 GMT References: <1991Jan21.083106.7297@tkou02.enet.dec.com> <2831@casbah.acns.nwu.edu> Organization: Unique Computing Pty Ltd, Melb, Aust. Lines: 32 In <2831@casbah.acns.nwu.edu> hpa@casbah.acns.nwu.edu (Peter Anvin) writes: > >>This sort of program CAN print the message if x() happens to be > >>loaded by the linker at the start of the code segment (address 0). > All DOS compilers I know of use, in small-code models, the beginning of the > code segment to store their startup code. This is link order dependant; nothing whatever to do with the compiler. > Thus, functions cannot be allocated to CS:0000h, and thus no > functions correspond to NULL. Yes they can, and often are. > The startup cod, which is written in assembler, sets up the stack, > local heap, floating point emulation and the arguments to main(), > as appropriate. main() just acts like a subroutine to the startup code. ... and can be wherever you like in the executable. > Should NULL be all ones? It, or an equivant, could be. # define NULLFUNC (int (*)()-1) david