[fpc-devel] CFI

Joost van der Sluis joost at cnoc.nl
Tue Jun 7 14:42:01 CEST 2022


Op 07-06-2022 om 14:07 schreef Jonas Maebe via fpc-devel:
> On 2022-06-07 11:09, Joost van der Sluis via fpc-devel wrote:
> 
>> This is a snippet of the information that the compiler typically
>> generates: (x86_64-linux)
>>
>> fde:
>> <    0><0x00401090:0x004010c1><JoJo><cie offset 0x00000000::cie index
>> 0><fde offset 0x00000014 length: 0x00000024><eh offset none>
>>         0x00401090: <off cfa=08(r7) > <off r16=-8(cfa) >
>>         0x00401091: <off cfa=16(r7) > <off r3=-16(cfa) > <off 
>> r16=-8(cfa) >
>>         0x004010c0: <off cfa=08(r7) > <off r16=-8(cfa) >
>>
>> This basically means that when the instruction-pointer is at
>> 0x00401090, the CFA (frame) can be obtained by taking register 7 (rsp)
>> and add 8 to it.
>> The return address (called r16 here) if obtained by taking the CFA,
>> substract 8 and then read the value at that memory location.
>>
>> So far so good. But then I need the next frame. So use the return
>> address, substract one (To obtain the call address). And start over...
>> but, the value of r7 is not available anymore.
> 
> The CFA (call frame address) is defined as "the value of %rsp at the 
> call site in the previous frame" (*). So the value you calculated above 
> in the first rule is the value of r7 in the previous frame and the call 
> site address.

Thanks, also for the link. Good to know that it is defined officially 
that way.

Regards,

Joost


More information about the fpc-devel mailing list