[fpc-pascal] How to get address of MyFunction in MyFunction?

Žilvinas Ledas zilvinas.ledas at dict.lt
Sun Jul 18 13:14:58 CEST 2010


On 2010-07-18 13:51, Jonas Maebe wrote:
> On 18 Jul 2010, at 12:50, Jonas Maebe wrote:
>
>    
>> On 18 Jul 2010, at 12:11, Žilvinas Ledas wrote:
>>
>>      
>>> to get address of function I can use @MyFunction, but if I use it within MyFunction - I get address of Result. How can I get address of current function?
>>>        
>> @unitname.function (or @programname.function if you are in the main program file)
>>      
> PS: if you want to use this to calculate the size of functions: don't. The linker can reorder the functions compared to how they are declared in your source file.
>    
Thanks, I'll try it.

I want to use it this way:
1) Gel all @unitname.function addresses.
2) Use disassembler to find nearest next RET.
3) Then I assume that I have start and end of the function in the binary 
file.

It works at least for the concept-showing app with some functions and 
enabled optimizations when compiling. Do I have some conceptual flaw?
And maybe there is an easier way to get function RET addresses in the 
binary file?

Regards
Žilvinas




More information about the fpc-pascal mailing list