On Thu, Mar 8, 2012 at 12:35, JMGross <msp...@grossibaer.de> wrote:
> Well, I must admit I had expected some jump to a dummy
> 'end of main' label or such. But thinking over it, it is obvious, that
> on a naked function you're responsible for exiting the function properly
> A return statement sets the return value, but that's it.
> i foyu don't add your own jmp/ret/whatever code after the return statement,
> it just continues executing what follows.
>
> Returning something form main (or returning from main in general) doesn't make
> any sense at all for a microcontroller program that isn't hosted by an OS. :)

I understand your reasoning, but I really think it should jump to the
dummy label rather then executing unrelated code. When main returns,
you may not have any guarantee what happens next, but is seems that it
is perfectly fine to assume that it won't run any further code from
main. Maybe the developer really wants to "return from main" (right
now mspgcc issues code to set CPUOFF when main finishes, which may be
what the developer wants). While the current behavior may be obvious
if you are aware of main being naked and so on, I can imagine that
many developers may have no idea what is happening (I didn't). It
could easily turn into a security issue, imagine that main is
something like:

int main(void) {
   if (check_signature() == 1) {
       run_application();
       return 0;
   }
   return 1;
}

Then this bug would cause the application to run even if the signature
is invalid!

Conrado

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to