This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Unwinding stack past main() when it has another name
> From: Richard Earnshaw <rearnsha@gcc.gnu.org>
> Cc: Steven Johnson <sjohnson@sakuraindustries.com>, gdb@sources.redhat.com
> Date: Fri, 17 Jun 2005 12:20:41 +0100
>
> > > This isnt always the case for embedded targets. There is no RULE that C
> > > programs must have a main() function. It may be that most do by
> > > convention, but they dont have to. In fact, main() can be a pain for
> > > small embedded targets because it wants a return value and arguments,
> > > which mean nothing for a program that isnt "launched" by a user on
> > > demand, but the C compiler detects the special function name main() and
> > > objects if it doesnt have the standard format. Programs dont even need
> > > to have an entry point called _start. It all depends on how you set up
> > > your link map.
> >
> > In fact you're wrong: there is a rule that C programs must have a
> > main() function. It's in the language standard.
>
> You are both right, and both wrong. In fact the standard says that two
> things are permitted.
>
> In a hosted environment the entry point to the application shall be
> 'main'. In a free-standing environment there is no constraint on the
> entry point -- there may even be multiple entry points.
I added a footnote in the manual about this.