On Tue, Feb 21, 2012 at 9:48 AM, Michael Richardson <m...@sandelman.ca> wrote:
>
>>>>>> "Peter" == Peter Bigot <big...@acm.org> writes:
>    Peter> see if I can figure something out.  My patience with this feature is
>    Peter> about at its end, though, so the solution may be to stop
>    Peter> treating main
>    Peter> as special unless the user adds the magic fairy dust around the
>    Peter> declaration that makes it work this way.
>
> Would the solution be to have _msp_main in the libgcc, as assembly,
> and for it to set up the stack and jmp to main?

The CRT init* code sets up the stack and does other things before main
gets invoked, then the fini* stuff gets run.  How main gets invoked is
the question.  Jumping to it (as opposed to calling it) would still
make it special, which is the basic problem.

As I recall, the original approach was to have __jump_to_main in
.init9, and have main terminate with a jump to __stop_progExec__ in
.fini9.  main was special: no caller-saved registers, no return
operation, end with a jump.

The current solution just puts main directly in .init9, letting it
fall through to __stop_progExec__ or whatever's in .fini9.  main is
automatically marked "naked", but is otherwise the same as any other
naked function (no "jump to wherever" added to it).

If I were to change this, there'd be a _main or __main in .init9 that
does nothing but call main then fall through to .fini9.  main would no
longer be special.  Determining the appropriate name for the stub that
calls main would require research.  The current behavior could be
obtained by renaming the user function _main and marking it naked.

But I'm pretty sure the problem in this case is the lack of the
referenced patch, so I'm not likely to do this.  Fixing the gdb issue
3420924 (whenever I get to that) will probably be less effort/impact.

Peter

> --
> ]       He who is tired of Weird Al is tired of life!           |  firewalls  
> [
> ]   Michael Richardson, Sandelman Software Works, Ottawa, ON    |net 
> architect[
> ] m...@sandelman.ottawa.on.ca http://www.sandelman.ottawa.on.ca/ |device 
> driver[
>   Kyoto Plus: watch the video <http://www.youtube.com/watch?v=kzx1ycLXQSE>
>                       then sign the petition.

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to