----- Ursprüngliche Nachricht -----
Von: conrado...@gmail.com
Gesendet am: 08 Mrz 2012 17:40:34
> I understand your reasoning, but I really think it should jump to the
> dummy label rather then executing unrelated code.
I totally agree. And that is what MSPGCC 3.23 did ( I just checked):
225:ez3.c **** int main(void){
1682 .LM178:
1683 /* prologue: frame size = 0 */
1686 0000 3140 0000 mov #(__stack-0), r1
1687 /* prologue end (size=2) */
1688
226:ez3.c **** if (dummy() == 1) {
1693 0004 B012 0000 call #dummy
1694 0008 1F93 cmp #llo(1), r15
1695 000a 0224 jeq .L193
227:ez3.c **** foo();
228:ez3.c **** return 1;
229:ez3.c **** }
230:ez3.c **** return 0;
1699 000c 0F43 mov #llo(0), r15
1700 000e 033C jmp .L151
1703 .L193:
1706 0010 B012 0000 call #foo
1709 0014 1F43 mov #llo(1), r15
1728 .L151:
1733 /* epilogue: frame size=0 */
1734 0016 3040 0000 br #__stop_progExec__
1735 /* epilogue end (size=4) */
1736 /* function main size 16 (10) */
> 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.
Right. However, not knowing where main returns to means not knowing what
happens next.
I met several people who assumed on 'return' from main, the program ends,
without
even thinking about what 'program ends' will mean for a microcontroller in
general
and for their program in detail.
> 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).
MAY be. Or not. LPM0 is definitely better than an endless loop or running wild.
But ISRs are still executed. Is this intended? Is it safe?
Some of the mentioned people were surprised that the ISRs still
execute after 'the program ended'.
> 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).
Unless you encounter obvious oddities like this, it is often not clear
to the people that a microcontroller program (or rather: a firmware!)
is unlike a PC program.
Often the MSP is recognized as some sort of 'tiny PC without monitor
and keyboard'. Understanding the target rather than just how to use the
tools is the point where playing ends and engineering begins.
> It could easily turn into a security issue, imagine that main is something
> like:
indeed. And Peter already confirmed that it is a severe bug and it is
on the todo list.
JMGross
------------------------------------------------------------------------------
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