[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Re: Patch Fix PR35013, PR27192
From: |
Dmitry K. |
Subject: |
Re: [avr-gcc-list] Re: Patch Fix PR35013, PR27192 |
Date: |
Thu, 17 Apr 2008 08:21:41 +1100 |
User-agent: |
KMail/1.5 |
On Thursday 17 April 2008 00:17, Andy wrote:
> Indirect calls - ie simple function pointers are safe!
>
> It is only when you try and do some arithmetic with them that there is
> potential problem. The only reason to use arithmetic is for ASM related
> manipulations. (but very useful!)
>
> For example , (excuse syntax mistakes)
>
> void foo(void) {}
>
> (void * p1) (void);
>
> p1 = &foo; //NO PROBLEM
[...]
Doubtful is avr6 case with binutils.
Look, please, the program below. It uses only simple function
pointers, no arithmetic.
Thanks,
Dmitry.
/* avr-gcc 4.4-20080404 + binutils 2.18 produce incorrect code:
the foo4() function stores 0 value to 'vp' variable.
Options: -W -Wall -Os -mmcu=atmega2560
*/
#define BIGCODE() asm volatile (".rept 30000\n\tnop\n\t.endr")
void (* volatile vp) (void);
__attribute__((noinline)) void foo1 (void) { BIGCODE(); vp = foo1; }
__attribute__((noinline)) void foo2 (void) { BIGCODE(); vp = foo2; }
__attribute__((noinline)) void foo3 (void) { BIGCODE(); vp = foo3; }
__attribute__((noinline)) void foo4 (void) { BIGCODE(); vp = foo4; }
int main ()
{
foo1 ();
foo2 ();
foo3 ();
foo4 ();
return 0;
}
- [avr-gcc-list] Re: Patch Fix PR35013, PR27192, Andy H, 2008/04/15
- Re: [avr-gcc-list] Re: Patch Fix PR35013, PR27192, Dave N6NZ, 2008/04/16
- Re: [avr-gcc-list] Re: Patch Fix PR35013, PR27192, Dmitry K., 2008/04/16
- [avr-gcc-list] RE: Patch Fix PR35013, PR27192, Weddington, Eric, 2008/04/16
- Re: [avr-gcc-list] RE: Patch Fix PR35013, PR27192, Andy H, 2008/04/16
- Re: [avr-gcc-list] RE: Patch Fix PR35013, PR27192, Dave N6NZ, 2008/04/16
- Re: [avr-gcc-list] RE: Patch Fix PR35013, PR27192, Andy H, 2008/04/18
- Re: [avr-gcc-list] RE: Patch Fix PR35013, PR27192, Dave N6NZ, 2008/04/19
- Re: [avr-gcc-list] RE: Patch Fix PR35013, PR27192, Andy H, 2008/04/19
- Re: [avr-gcc-list] RE: Patch Fix PR35013, PR27192, Wouter van Gulik, 2008/04/17
Re: [avr-gcc-list] Re: Patch Fix PR35013, PR27192, Wouter van Gulik, 2008/04/16