[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Re: More interrupt oddity

From: Chris Baugher
Subject: Re: [avr-gcc-list] Re: More interrupt oddity
Date: Sun, 21 Oct 2001 19:48:39 -0500 (CDT)

On Sun, 21 Oct 2001, Peter N Lewis wrote:

> >On 21 Oct 2001, at 12:01, address@hidden wrote:
> >  > The goofy part is that the linker didn't give any errors or warnings
> >>  that something may be wrong. Shouldn't it fail with an undefined
> >  > symbol or something?
> If you look in the docs, aka sig-avr.h, you see that:
> #define SIG_INTERRUPT0 _interrupt0_
> SIG_INTERRUPT0 is just defined to be the name of the routine 
> (_interrupt0_), and that name (_interrupt0_) happens to be used in 
> the jump table, so the linker knows it can be called.
> #define SIGNAL(signame)                                       \
> void signame (void) __attribute__ ((signal));         \
> void signame (void)
> So your code just ended up being:
> void SIG_INTERRUPT0 (void) __attribute__ ((signal));
> void SIG_INTERRUPT0 (void)
> This is just a function which preserves more registers and flags than 
> normal.  And it is never called, so I guess the linker would be free 
> to remove it entirely or optimize away all the code which has no 
> effect.

Ahh. Actually I DID look at the headers and I saw the macro expansion but
I was thinking that the linker would see the "__attribute__ ((signal))"
and flag this function as an ISR. But it wouldn't be able to figure out
what interrupt to tie it to because the function name wasn't in the list
of "functions that are interrupts".

Basically this all just demonstrates my lack of understanding of how
the linker works:-/

Ahh well... onward.


> There isn't ny good way for the code to defend against this problem, 
> unless there was perhaps some what to add to the #define a warning if 
> the input parameter was SIG_* since that would presumably indicate a 
> misspelling.
> Enjoy,
>     Peter.
> -- 
> Sungroper Solar Car Association <http://www.sungroper.asn.au/>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://avr.jpk.co.nz/mailman/listinfo/avr-gcc-list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]