[fpc-devel] Linux assembler start-up: rtl/linux/*/*.as

Sergei Gorelkin sergei_gorelkin at mail.ru
Thu May 28 11:09:20 CEST 2015


28.05.2015 10:49, Marco van de Voort пишет:
> In our previous episode, Edmund Grimley Evans said:
>
>> - How to do the equivalent of C longjmp in Pascal, used in
>>    x86_64/gprt0.as, for example?
>
> There are fpc_longjmp and fpc_setjmp symbols but they are related to
> exception handling. In an emergency, simply asm jmp $x end;
>
It is not an emergency case. Libc expects 'main' to return and then executes finalization code. 
FPC's PASCALMAIN terminates the process and does not return. So in order to get correct library 
finalization (including profiling with grpof) we have to simulate a return using something like longjmp.
It's basically a dirty hack. A much cleaner solution could be to change code generation so it calls 
FPC_LIB_EXIT instead of FPC_EXIT at the end of PASCALMAIN (so that _haltproc is not called and 
PASCALMAIN normally returns), and call _haltproc explicitly in code of prt0.as. But whoever goes for 
that will have to change and test all startup files for all targets, which is pretty time-consuming.

Regards,
Sergei




More information about the fpc-devel mailing list