Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2018-04

Re: Broken frac functioninFPC3.1.1 / Windows x86_64

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

J. Gareth Moreton

I stand corrected.

Normally if I want to write a second epilogue, I simply compile the project and look at the disassembly, and copy what the compiler puts in for the epilogue.  The only one I remember off-hand is for leaf functions with no stack frame and which uses only volatile registers, hence a simple RET.  I'll get it right in the end!

Gareth aka. Kit

P.S. You might want to tell your spam filter that these messages are sound, so we're not put off at the sight of "*** GMX Spamverdacht ***"!

On Sun 29/04/18 12:44 , "Thorsten Engler" sent:

Show quoted text 5 lines
From: fpc-devel On Behalf Of J. Gareth Moreton For functions with a stack frame, either LEAVE or MOV RSP, RBP; POP RBP must precede it.

It's not quite that simple, at least under windows: https://docs.microsoft.com/en-us/cpp/build/prolog-and-epilog [2]

But yes, this documents that there can be multiple epilogues, so the additional ret would be fine in this regard.

Following this exact format is required so that the stack unwinder during processing of SEH (structured exception handling) which is performed by the OS can correctly restore the value of non-volatile registers that has been saved on the stack.

Fortunately, as our function in this case doesn't use the stack at all and doesn't contain calls to other functions, this can be skipped.

So what happens now? Do we submit a patch?

I think Sven Barth was going to fix this up anyway?

Cheers,
Thorsten

Reply by email