-----Original Message-----
From: John Marshall [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 20 December 2001 9:28 AM
To: Palm Developer Forum
Subject: Re: Reference to function address
> Initialisation 1 is done at application startup by a compile-time
> constant relocation (and it doesn't matter at all which section the
> function you're assigning to func is in).
> Assignment 2 is calculated as a compile-time constant offset from %pc.
> Assignment 3, when the function whose address you're taking is in a
> different section from the place where you're doing it, is calculated as
> a compile-time constant offset from a section pointer, which you find at
> a compile-time constant offset from the global pointer (usually %a5).
> (Oh, and the section pointer lookup can be optimised away by CSE if a
> function makes a lot of references to things in the same other section.)
Hi John.
Sorry for probably a silly question.
What the above paragraph means (as far as I understand that) that GCC
uses different patterns for keeping a pointer to a function depending
on whether or not it belongs to current segmnent.
Let me extend your example (I put on-line comments for convenience):
extern void MyFunc ();
extern void MyFunc2 () __attribute__ ((section ("othersec")));
void (*func)();
void same_section_as_MyFunc_but_not_as_MyFunc2 () {
func = MyFunc; /* Stores an offset from program
counter (%pc) */
(*func)(); /* Needs a "near" call - Added by M.G. */
func = MyFunc2; /* Stores an offset from the
appropriate segment */
(*func)(); /* Needs a cross-segment call - Added by M.G.
*/
}
Two (*func)(); look really identical, so should be the generated code.
Why there is no confusion between local and cross-segment calls ?
Regs,
M.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/