"Max Bian" <[EMAIL PROTECTED]> wrote in message
news:71546@palm-dev-forum...
>
> I am trying to implemente a software protection scheme where calling
to
> function is via a variable instead of calling directly.  I first
declared a
> variable func as this:
>
> int (*func)();
>
> and later I will assign a function address to it by:
>
> func = MyFunc;
>   where "MyFunc" is something like this:
>
> int MyFunc(...){...};
>
> My question is, is the value (address?) of MyFunc determined as
compile time?
> If so, how do I obtain that value after compilation?  I had some
experience
> with x86 assembly but I am not familiar with m68k.

If MyFunc is in the same segment, the address is computed by adding a
constant offset value from the current PC (program counter) when the
"func = MyFunc" instruction is executed.

If MyFunc is in a different segment, the address is retrieved from the
global jumptable, again using a constant offset, but now from the global
register (usually A5).  The jumptable is structured as a series of JMP
instructions, but the opcode can be skipped to get the actual address.

You can get a relative value after compilation by looking at the linker
map file, but that will only tell you how far into a segment the
function is.  You can't determine the true location until runtime,
because when your application isn't running, its segments are unlocked
and may move around memory.



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to