Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Windows-x64: standard prolog/epilog/seh in leaf functions, why?

124 views
Skip to first unread message

already...@nospicedham.yahoo.com

unread,
Jun 26, 2016, 5:27:47 PM6/26/16
to
So, suppose I am coding leaf function in asm.
Suppose, my leaf function never rises any exception, except possibly page fault, but page fault is not an application exception, so I think we can ignore it.

What do I gain by following Microsoft Prolog/epilog/seh rules and what I potentially lose if I violate the rules?

Alexei A. Frounze

unread,
Jun 26, 2016, 8:13:24 PM6/26/16
to
SEH is needed for you to handle exceptions that the OS can't
handle for you automatically (other than by terminating your
process). Normal page faults due to virtual memory swapping
in and out pages of your process are handled automatically
and transparently by the OS and SEH is not needed here.
However, if your code may do division by zero, use an
instruction not available in your CPU, you may want to catch
that and handle with SEH. Also, if you want to properly log
crashes (and maybe do something before process termination),
you may also need SEH in order to properly unwind the call
stack. But, again, if your leaf assembly function can't cause
any of these, I think, you need not do anything. Unless,
for some reason SEH info is required for every function
for SEH in other places to work properly, which I doubt.

Alex

yuhong...@nospicedham.hotmail.com

unread,
Jul 10, 2016, 4:18:21 AM7/10/16
to
On Sunday, June 26, 2016 at 2:27:47 PM UTC-7, already...@nospicedham.yahoo.com wrote:
If it is a simple leaf function that don't change rsp, you don't need function tables.

already...@nospicedham.yahoo.com

unread,
Jul 10, 2016, 4:08:05 PM7/10/16
to
Yes, I have in mind a simple leaf function. But not *that* simple.
It saves several non-volatile registers on stack so RSP is modified.
0 new messages