Code Gen problem calling functions through pointers.
David Williams (davidwilliams@ozemail.com.au)
Thu, 10 Jun 1999 21:17:10 +1000
Hi All,
Thanks for previous help with placing functions in data segment. The
"__attribute__ (section..." solution works fantastic.
I am using ECGS 1.1.1 (binaries from Object Software web site) to cross
compile from win95 to 68K (coff).
I have a problem with calling functions through pointers. I have assigned
some unused vector table entries on 68K as holding places for functions
that are called from applications link at a separate time. To call the
functions (via the vector table entry) I use the following macros
#define TEST_FN_VECTOR 0x100
#define TestFunction() (*(void (*)(void))(TEST_FN_VECTOR<<2))()
I have found that the compiler sometimes generates the correct code. Eg.
move.w #256,%a2
jsr (%a2)
But at other times generates
jsr 256.w
The second case will execute code at the vector address rather than using
the contents of the vector as a pointer to the location to start executing
from.
I have not been able to determine when or why the compiler decides to
generate one form or the other. I did notice that the functions that had
the erroneous code where generally simpler.
This seems like a code generation bug to me.
Is my cast from an integer to a function pointer OK?
If it is a bug has it been fixed in ECGS 1.1.2. ?
TIA
David Williams
DLC Software P/L
Email:davidwilliams@ozemail.com.au
_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.