[fpc-pascal] Get all caller adresses of a procedure/function
jonas.maebe at elis.ugent.be
Mon Aug 6 21:26:24 CEST 2012
On 06 Aug 2012, at 21:06, Rainer Stratmann wrote:
> Am Monday 06 August 2012 20:12:41 schrieb Sven Barth:
>> problem now is that without knowing the context of a found location
>> 0xCA11 you don't know whether it is really a call opcode or some
>> immediate data that was passed to some previous opcode. This is also an
>> obstacle experienced by VM developers for x86 instructions (or CISC
>> instructions in general). For RISC instruction sets this is less
>> complex, but the problem exists there as well.
> If I have the opcode 0xCA11 and the adress of p1 (suppose) 0x6EF7CAB0 then I
> have 6 bytes (0xCA116EF7CAB0). That reduces drastically the possibility of
> some immediate random data
It doesn't work like that. Regular calls use relative offsets on most (if not all) architectures we support. And in some cases we generate position-independent code, so then you'll have look at GOT entries to figure out the address. Then there are of course calls via procedure variables. And there's probably a ton more special cases I'm not thinking of right now.
>> Out of curiosity: why don't you use resourcestrings?
> It seems that is has not the flexibility and simplicity (in its entirety) that
> I want.
I would not call your method "simple" and would also strongly recommend to use resourcestrings instead. Their purpose is exactly to make it easy to translate the strings in a program.
More information about the fpc-pascal