3 # Ascetic x86_64 AT&T to MASM/NASM assembler translator by <appro>.
5 # Why AT&T to MASM and not vice versa? Several reasons. Because AT&T
6 # format is way easier to parse. Because it's simpler to "gear" from
7 # Unix ABI to Windows one [see cross-reference "card" at the end of
8 # file]. Because Linux targets were available first...
10 # In addition the script also "distills" code suitable for GNU
11 # assembler, so that it can be compiled with more rigid assemblers,
12 # such as Solaris /usr/ccs/bin/as.
14 # This translator is not designed to convert *arbitrary* assembler
15 # code from AT&T format to MASM one. It's designed to convert just
16 # enough to provide for dual-ABI OpenSSL modules development...
17 # There *are* limitations and you might have to modify your assembler
18 # code or this script to achieve the desired result...
20 # Currently recognized limitations:
22 # - can't use multiple ops per line;
24 # Dual-ABI styling rules.
26 # 1. Adhere to Unix register and stack layout [see cross-reference
27 # ABI "card" at the end for explanation].
28 # 2. Forget about "red zone," stick to more traditional blended
29 # stack frame allocation. If volatile storage is actually required
30 # that is. If not, just leave the stack as is.
31 # 3. Functions tagged with ".type name,@function" get crafted with
32 # unified Win64 prologue and epilogue automatically. If you want
33 # to take care of ABI differences yourself, tag functions as
34 # ".type name,@abi-omnipotent" instead.
35 # 4. To optimize the Win64 prologue you can specify number of input
36 # arguments as ".type name,@function,N." Keep in mind that if N is
37 # larger than 6, then you *have to* write "abi-omnipotent" code,
38 # because >6 cases can't be addressed with unified prologue.
39 # 5. Name local labels as .L*, do *not* use dynamic labels such as 1:
40 # (sorry about latter).
41 # 6. Don't use [or hand-code with .byte] "rep ret." "ret" mnemonic is
42 # required to identify the spots, where to inject Win64 epilogue!
43 # But on the pros, it's then prefixed with rep automatically:-)
44 # 7. Due to MASM limitations [and certain general counter-intuitivity
45 # of ip-relative addressing] generation of position-independent
46 # code is assisted by synthetic directive, .picmeup, which puts
47 # address of the *next* instruction into target register.
51 # lea .Label-.(%rax),%rax
56 # lea .Label-.Lpic_point(%rcx),%rbp
58 # 8. In order to provide for structured exception handling unified
59 # Win64 prologue copies %rsp value to %rax. For further details
60 # see SEH paragraph at the end.
64 { my ($stddev,$stdino,@junk)=stat(STDOUT);
65 my ($outdev,$outino,@junk)=stat($output);
67 open STDOUT,">$output" || die "can't open $output: $!"
68 if ($stddev!=$outdev || $stdino!=$outino);
71 my $win64=1 if ($output =~ /\.asm$/);
73 my $masmref=8 + 50727*2**-32; # 8.00.50727 shipped with VS2005
81 { if ($ENV{ASM} =~ m/nasm/ && `nasm -v` =~ m/version ([0-9]+)\.([0-9]+)/i)
82 { $nasm = $1 + $2*0.01; $PTR=""; }
83 elsif (`ml64 2>&1` =~ m/Version ([0-9]+)\.([0-9]+)(\.([0-9]+))?/)
84 { $masm = $1 + $2*2**-16 + $4*2**-32; }
85 die "no assembler found on %PATH" if (!($nasm || $masm));
92 { package opcode; # pick up opcodes
94 my $self = shift; # single instance in enough...
98 if ($line =~ /^([a-z][a-z0-9]*)/i) {
101 $line = substr($line,@+[0]); $line =~ s/^\s+//;
104 if ($self->{op} =~ /^(movz)b.*/) { # movz is pain...
107 } elsif ($self->{op} =~ /call|jmp/) {
109 } elsif ($self->{op} =~ /([a-z]{3,})([qlwb])$/) {
119 $self->{sz} = $sz if (defined($sz) && !defined($self->{sz}));
125 if ($self->{op} eq "movz") { # movz is pain...
126 sprintf "%s%s%s",$self->{op},$self->{sz},shift;
127 } elsif ($self->{op} =~ /^set/) {
129 } elsif ($self->{op} eq "ret") {
132 "$self->{op}$self->{sz}";
135 $self->{op} =~ s/^movz/movzx/;
136 if ($self->{op} eq "ret") {
138 if ($current_function->{abi} eq "svr4") {
139 $self->{op} = "mov rdi,QWORD${PTR}[8+rsp]\t;WIN64 epilogue\n\t".
140 "mov rsi,QWORD${PTR}[16+rsp]\n\t";
142 $self->{op} .= "DB\t0F3h,0C3h\t\t;repret";
144 elsif ($self->{op} =~ /^(pop|push)f/) {
145 $self->{op} .= $self->{sz};
150 sub mnemonic { shift->{op}; }
152 { package const; # pick up constants, which start with $
154 my $self = shift; # single instance in enough...
158 if ($line =~ /^\$([^,]+)/) {
161 $line = substr($line,@+[0]); $line =~ s/^\s+//;
169 # Solaris /usr/ccs/bin/as can't handle multiplications
171 $self->{value} =~ s/(?<![0-9a-f])(0[x0-9a-f]+)/oct($1)/egi;
172 $self->{value} =~ s/([0-9]+\s*[\*\/\%]\s*[0-9]+)/eval($1)/eg;
173 sprintf "\$%s",$self->{value};
175 $self->{value} =~ s/0x([0-9a-f]+)/0$1h/ig;
176 sprintf "%s",$self->{value};
180 { package ea; # pick up effective addresses: expr(%reg,%reg,scale)
182 my $self = shift; # single instance in enough...
186 # optional * ---vvv--- appears in indirect jmp/call
187 if ($line =~ /^(\*?)([^\(,]*)\(([%\w,]+)\)/) {
188 $self->{asterisk} = $1;
190 ($self->{base},$self->{index},$self->{scale})=split(/,/,$3);
191 $self->{scale} = 1 if (!defined($self->{scale}));
193 $line = substr($line,@+[0]); $line =~ s/^\s+//;
195 $self->{base} =~ s/^%//;
196 $self->{index} =~ s/^%// if (defined($self->{index}));
205 # Silently convert all EAs to 64-bit. This is required for
206 # elder GNU assembler and results in more compact code,
207 # *but* most importantly AES module depends on this feature!
208 $self->{index} =~ s/^[er](.?[0-9xpi])[d]?$/r\1/;
209 $self->{base} =~ s/^[er](.?[0-9xpi])[d]?$/r\1/;
212 # Solaris /usr/ccs/bin/as can't handle multiplications
214 $self->{label} =~ s/(?<![0-9a-f])(0[x0-9a-f]+)/oct($1)/egi;
215 $self->{label} =~ s/([0-9]+\s*[\*\/\%]\s*[0-9]+)/eval($1)/eg;
217 if (defined($self->{index})) {
218 sprintf "%s%s(%%%s,%%%s,%d)",$self->{asterisk},
219 $self->{label},$self->{base},
220 $self->{index},$self->{scale};
222 sprintf "%s%s(%%%s)", $self->{asterisk},$self->{label},$self->{base};
225 %szmap = ( b=>"BYTE$PTR", w=>"WORD$PTR", l=>"DWORD$PTR", q=>"QWORD$PTR" );
227 $self->{label} =~ s/\.L/\$L\$/g;
228 $self->{label} =~ s/\./\$/g;
229 $self->{label} =~ s/0x([0-9a-f]+)/0$1h/ig;
230 $self->{label} = "($self->{label})" if ($self->{label} =~ /[\*\+\-\/]/);
231 $sz="q" if ($self->{asterisk});
233 if (defined($self->{index})) {
234 sprintf "%s[%s%s*%d+%s]",$szmap{$sz},
235 $self->{label}?"$self->{label}+":"",
236 $self->{index},$self->{scale},
238 } elsif ($self->{base} eq "rip") {
239 sprintf "%s[%s]",$szmap{$sz},$self->{label};
241 sprintf "%s[%s%s]",$szmap{$sz},
242 $self->{label}?"$self->{label}+":"",
248 { package register; # pick up registers, which start with %.
250 my $class = shift; # muliple instances...
255 # optional * ---vvv--- appears in indirect jmp/call
256 if ($line =~ /^(\*?)%(\w+)/) {
258 $self->{asterisk} = $1;
261 $line = substr($line,@+[0]); $line =~ s/^\s+//;
269 if ($self->{value} =~ /^r[\d]+b$/i) { $ret="b"; }
270 elsif ($self->{value} =~ /^r[\d]+w$/i) { $ret="w"; }
271 elsif ($self->{value} =~ /^r[\d]+d$/i) { $ret="l"; }
272 elsif ($self->{value} =~ /^r[\w]+$/i) { $ret="q"; }
273 elsif ($self->{value} =~ /^[a-d][hl]$/i){ $ret="b"; }
274 elsif ($self->{value} =~ /^[\w]{2}l$/i) { $ret="b"; }
275 elsif ($self->{value} =~ /^[\w]{2}$/i) { $ret="w"; }
276 elsif ($self->{value} =~ /^e[a-z]{2}$/i){ $ret="l"; }
282 if (!$win64) { sprintf "%s%%%s",$self->{asterisk},$self->{value}; }
283 else { $self->{value}; }
286 { package label; # pick up labels, which end with :
288 my $self = shift; # single instance is enough...
292 if ($line =~ /(^[\.\w]+\:)/) {
295 $line = substr($line,@+[0]); $line =~ s/^\s+//;
297 $self->{value} =~ s/\.L/\$L\$/ if ($win64);
306 } elsif ($self->{value} ne "$current_function->{name}:") {
307 $self->{value} .= ":" if ($masm && $ret!~m/^\$/);
309 } elsif ($current_function->{abi} eq "svr4") {
310 my $func = "$current_function->{name}" .
311 ($nasm ? ":" : "\tPROC $current_function->{scope}") .
313 $func .= " mov QWORD${PTR}[8+rsp],rdi\t;WIN64 prologue\n";
314 $func .= " mov QWORD${PTR}[16+rsp],rsi\n";
315 $func .= " mov rax,rsp\n";
316 $func .= "\$L\$SEH_begin_$current_function->{name}:";
317 $func .= ":" if ($masm);
319 my $narg = $current_function->{narg};
320 $narg=6 if (!defined($narg));
321 $func .= " mov rdi,rcx\n" if ($narg>0);
322 $func .= " mov rsi,rdx\n" if ($narg>1);
323 $func .= " mov rdx,r8\n" if ($narg>2);
324 $func .= " mov rcx,r9\n" if ($narg>3);
325 $func .= " mov r8,QWORD${PTR}[40+rsp]\n" if ($narg>4);
326 $func .= " mov r9,QWORD${PTR}[48+rsp]\n" if ($narg>5);
329 "$current_function->{name}".
330 ($nasm ? ":" : "\tPROC $current_function->{scope}");
334 { package expr; # pick up expressioins
336 my $self = shift; # single instance is enough...
340 if ($line =~ /(^[^,]+)/) {
343 $line = substr($line,@+[0]); $line =~ s/^\s+//;
345 $self->{value} =~ s/\.L/\$L\$/g if ($win64);
351 if ($nasm && opcode->mnemonic()=~m/^j/) {
352 "NEAR ".$self->{value};
358 { package directive; # pick up directives, which start with .
360 my $self = shift; # single instance is enough...
364 my %opcode = # lea 2f-1f(%rip),%dst; 1: nop; 2:
365 ( "%rax"=>0x01058d48, "%rcx"=>0x010d8d48,
366 "%rdx"=>0x01158d48, "%rbx"=>0x011d8d48,
367 "%rsp"=>0x01258d48, "%rbp"=>0x012d8d48,
368 "%rsi"=>0x01358d48, "%rdi"=>0x013d8d48,
369 "%r8" =>0x01058d4c, "%r9" =>0x010d8d4c,
370 "%r10"=>0x01158d4c, "%r11"=>0x011d8d4c,
371 "%r12"=>0x01258d4c, "%r13"=>0x012d8d4c,
372 "%r14"=>0x01358d4c, "%r15"=>0x013d8d4c );
374 if ($line =~ /^\s*(\.\w+)/) {
377 $line =~ s/\@abi\-omnipotent/\@function/;
378 $line =~ s/\@function.*/\@function/;
379 if ($line =~ /\.picmeup\s+(%r[\w]+)/i) {
380 $self->{value} = sprintf "\t.long\t0x%x,0x90000000",$opcode{$1};
381 } elsif ($line =~ /\.asciz\s+"(.*)"$/) {
382 $self->{value} = ".byte\t".join(",",unpack("C*",$1),0);
383 } elsif ($line =~ /\.extern/) {
384 $self->{value} = ""; # swallow extern
386 $self->{value} = $line;
394 undef $self->{value};
395 $line = substr($line,@+[0]); $line =~ s/^\s+//;
397 /\.text/ && do { my $v=undef;
399 $v="section .text code align=64\n";
401 $v="$current_segment\tENDS\n" if ($current_segment);
402 $current_segment = ".text\$";
403 $v.="$current_segment\tSEGMENT ";
404 $v.=$masm>=$masmref ? "ALIGN(64)" : "PAGE";
410 /\.data/ && do { my $v=undef;
412 $v="section .data data align=8\n";
414 $v="$current_segment\tENDS\n" if ($current_segment);
415 $current_segment = "_DATA";
416 $v.="$current_segment\tSEGMENT";
421 /\.section/ && do { my $v=undef;
424 if ($line=~/\.([px])data/) {
426 $v.=$1 eq "p"? 4 : 8;
429 $v="$current_segment\tENDS\n" if ($current_segment);
430 $v.="$line\tSEGMENT";
431 if ($line=~/\.([px])data/) {
433 $v.=" ALIGN(".($1 eq "p" ? 4 : 8).")" if ($masm>=$masmref);
436 $current_segment = $line;
440 /\.extern/ && do { $self->{value} = "EXTERN\t".$line;
441 $self->{value} .= ":NEAR" if ($masm);
445 && do { $self->{value} = $masm?"PUBLIC":"global";
446 $self->{value} .= "\t".$line;
447 $globals{$line} = $line;
450 /\.type/ && do { ($sym,$type,$narg) = split(',',$line);
451 if ($type eq "\@function") {
452 undef $current_function;
453 $current_function->{name} = $sym;
454 $current_function->{abi} = "svr4";
455 $current_function->{narg} = $narg;
456 $current_function->{scope} = defined($globals{$sym})?"PUBLIC":"PRIVATE";
457 } elsif ($type eq "\@abi-omnipotent") {
458 undef $current_function;
459 $current_function->{name} = $sym;
460 $current_function->{scope} = defined($globals{$sym})?"PUBLIC":"PRIVATE";
464 /\.size/ && do { if (defined($current_function)) {
465 undef $self->{value};
466 if ($current_function->{abi} eq "svr4") {
467 $self->{value}="\$L\$SEH_end_$current_function->{name}:";
468 $self->{value}.=":\n" if($masm);
470 $self->{value}.="$current_function->{name}\tENDP" if($masm);
471 undef $current_function;
475 /\.align/ && do { $self->{value} = "ALIGN\t".$line; last; };
476 /\.(byte|value|long|quad)/
477 && do { my $sz = substr($1,0,1);
478 my @arr = split(',',$line);
479 my $last = pop(@arr);
480 my $conv = sub { my $var=shift;
481 $var=~s/0x([0-9a-f]+)/0$1h/ig;
483 if ($current_segment=~/.[px]data/)
484 { $var=~s/([_a-z\$\@][_a-z0-9\$\@]*)/$nasm?"$1 wrt ..imagebase":"imagerel $1"/egi; }
488 $sz =~ tr/bvlq/BWDQ/;
489 $self->{value} = "\tD$sz\t";
490 for (@arr) { $self->{value} .= &$conv($_).","; }
491 $self->{value} .= &$conv($last);
494 /\.picmeup/ && do { $self->{value} = sprintf"\tDD\t0%Xh,090000000h",$opcode{$line};
497 /\.asciz/ && do { if ($line =~ /^"(.*)"$/) {
498 my @str=unpack("C*",$1);
501 $self->{value}.="DB\t"
502 .join(",",@str[0..15])."\n";
503 foreach (0..15) { shift @str; }
505 $self->{value}.="DB\t"
506 .join(",",@str) if (@str);
535 $line =~ s|[#!].*$||; # get rid of asm-style comments...
536 $line =~ s|/\*.*\*/||; # ... and C-style comments...
537 $line =~ s|^\s+||; # ... and skip white spaces in beginning
545 if ($label=label->re(\$line)) { print $label->out(); }
547 if (directive->re(\$line)) {
548 printf "%s",directive->out();
549 } elsif ($opcode=opcode->re(\$line)) { ARGUMENT: {
551 if ($src=register->re(\$line)) { opcode->size($src->size()); }
552 elsif ($src=const->re(\$line)) { }
553 elsif ($src=ea->re(\$line)) { }
554 elsif ($src=expr->re(\$line)) { }
556 last ARGUMENT if ($line !~ /^,/);
558 $line = substr($line,1); $line =~ s/^\s+//;
560 if ($dst=register->re(\$line)) { opcode->size($dst->size()); }
561 elsif ($dst=const->re(\$line)) { }
562 elsif ($dst=ea->re(\$line)) { }
570 printf "\t%s\t%s,%s", $opcode->out($dst->size()),
571 $src->out($sz),$dst->out($sz);
573 undef $sz if ($nasm && $opcode->mnemonic() eq "lea");
574 printf "\t%s\t%s,%s", $opcode->out(),
575 $dst->out($sz),$src->out($sz);
577 } elsif (defined($src)) {
578 printf "\t%s\t%s",$opcode->out(),$src->out($sz);
580 printf "\t%s",$opcode->out();
587 print "\n$current_segment\tENDS\nEND\n" if ($current_segment && $masm);
591 \f#################################################
592 # Cross-reference x86_64 ABI "card"
612 # (*) volatile register
613 # (-) preserved by callee
614 # (#) Nth argument, volatile
616 # In Unix terms top of stack is argument transfer area for arguments
617 # which could not be accomodated in registers. Or in other words 7th
618 # [integer] argument resides at 8(%rsp) upon function entry point.
619 # 128 bytes above %rsp constitute a "red zone" which is not touched
620 # by signal handlers and can be used as temporal storage without
621 # allocating a frame.
623 # In Win64 terms N*8 bytes on top of stack is argument transfer area,
624 # which belongs to/can be overwritten by callee. N is the number of
625 # arguments passed to callee, *but* not less than 4! This means that
626 # upon function entry point 5th argument resides at 40(%rsp), as well
627 # as that 32 bytes from 8(%rsp) can always be used as temporal
628 # storage [without allocating a frame]. One can actually argue that
629 # one can assume a "red zone" above stack pointer under Win64 as well.
630 # Point is that at apparently no occasion Windows kernel would alter
631 # the area above user stack pointer in true asynchronous manner...
633 # All the above means that if assembler programmer adheres to Unix
634 # register and stack layout, but disregards the "red zone" existense,
635 # it's possible to use following prologue and epilogue to "gear" from
636 # Unix to Win64 ABI in leaf functions with not more than 6 arguments.
638 # omnipotent_function:
642 # movq %rcx,%rdi ; if 1st argument is actually present
643 # movq %rdx,%rsi ; if 2nd argument is actually ...
644 # movq %r8,%rdx ; if 3rd argument is ...
645 # movq %r9,%rcx ; if 4th argument ...
646 # movq 40(%rsp),%r8 ; if 5th ...
647 # movq 48(%rsp),%r9 ; if 6th ...
656 \f#################################################
657 # Win64 SEH, Structured Exception Handling.
659 # Unlike on Unix systems(*) lack of Win64 stack unwinding information
660 # has undesired side-effect at run-time: if an exception is raised in
661 # assembler subroutine such as those in question (basically we're
662 # referring to segmentation violations caused by malformed input
663 # parameters), the application is briskly terminated without invoking
664 # any exception handlers, most notably without generating memory dump
665 # or any user notification whatsoever. This poses a problem. It's
666 # possible to address it by registering custom language-specific
667 # handler that would restore processor context to the state at
668 # subroutine entry point and return "exception is not handled, keep
669 # unwinding" code. Writing such handler can be a challenge... But it's
670 # doable, though requires certain coding convention. Consider following
673 # .type function,@function
675 # movq %rsp,%rax # copy rsp to volatile register
676 # pushq %r15 # save non-volatile registers
680 # subq %rdi,%r11 # prepare [variable] stack frame
682 # movq %rax,0(%r11) # check for exceptions
683 # movq %r11,%rsp # allocate [variable] stack frame
684 # movq %rax,0(%rsp) # save original rsp value
687 # movq 0(%rsp),%rcx # pull original rsp value
688 # movq -24(%rcx),%rbp # restore non-volatile registers
689 # movq -16(%rcx),%rbx
691 # movq %rcx,%rsp # restore original rsp
693 # .size function,.-function
695 # The key is that up to magic_point copy of original rsp value remains
696 # in chosen volatile register and no non-volatile register, except for
697 # rsp, is modified. While past magic_point rsp remains constant till
698 # the very end of the function. In this case custom language-specific
699 # exception handler would look like this:
701 # EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
702 # CONTEXT *context,DISPATCHER_CONTEXT *disp)
703 # { ULONG64 *rsp = (ULONG64 *)context->Rax;
704 # if (context->Rip >= magic_point)
705 # { rsp = ((ULONG64 **)context->Rsp)[0];
706 # context->Rbp = rsp[-3];
707 # context->Rbx = rsp[-2];
708 # context->R15 = rsp[-1];
710 # context->Rsp = (ULONG64)rsp;
711 # context->Rdi = rsp[1];
712 # context->Rsi = rsp[2];
714 # memcpy (disp->ContextRecord,context,sizeof(CONTEXT));
715 # RtlVirtualUnwind(UNW_FLAG_NHANDLER,disp->ImageBase,
716 # dips->ControlPc,disp->FunctionEntry,disp->ContextRecord,
717 # &disp->HandlerData,&disp->EstablisherFrame,NULL);
718 # return ExceptionContinueSearch;
721 # It's appropriate to implement this handler in assembler, directly in
722 # function's module. In order to do that one has to know members'
723 # offsets in CONTEXT and DISPATCHER_CONTEXT structures and some constant
724 # values. Here they are:
743 # sizeof(CONTEXT) 1232
744 # DISPATCHER_CONTEXT.ControlPc 0
745 # DISPATCHER_CONTEXT.ImageBase 8
746 # DISPATCHER_CONTEXT.FunctionEntry 16
747 # DISPATCHER_CONTEXT.EstablisherFrame 24
748 # DISPATCHER_CONTEXT.TargetIp 32
749 # DISPATCHER_CONTEXT.ContextRecord 40
750 # DISPATCHER_CONTEXT.LanguageHandler 48
751 # DISPATCHER_CONTEXT.HandlerData 56
752 # UNW_FLAG_NHANDLER 0
753 # ExceptionContinueSearch 1
755 # In order to tie the handler to the function one has to compose
756 # couple of structures: one for .xdata segment and one for .pdata.
758 # UNWIND_INFO structure for .xdata segment would be
760 # function_unwind_info:
764 # This structure designates exception handler for a function with
765 # zero-length prologue, no stack frame or frame register.
767 # To facilitate composing of .pdata structures, auto-generated "gear"
768 # prologue copies rsp value to rax and denotes next instruction with
769 # $L$SEH_begin_{function_name} label. This essentially defines the SEH
770 # styling rule mentioned in the beginning. Position of this label is
771 # chosen in such manner that possible exceptions raised in the "gear"
772 # prologue would be accounted to caller and unwound from latter's frame.
773 # End of function is marked with respective $L$SEH_end_{function_name}
774 # label. To summarize, .pdata segment would contain
776 # .long $L$SEH_begin_function
777 # .long $L$SEH_end_function
778 # .long function_unwind_info
780 # Reference to functon_unwind_info from .xdata segment is the anchor.
781 # In case you wonder why references are 32-bit .longs and not 64-bit
782 # .quads. References put into these two segments are required to be
783 # *relative* to the base address of the current binary module, a.k.a.
784 # image base. No Win64 module, be it .exe or .dll, can be larger than
785 # 2GB and thus such relative references can be and are accommodated in
788 # Having reviewed the example function code, one can argue that "movq
789 # %rsp,%rax" above is redundant. It is not! Keep in mind that on Unix
790 # rax would contain an undefined value. If this "offends" you, use
791 # another register and refrain from modifying rax till magic_point is
792 # reached, i.e. as if it was a non-volatile register. If more registers
793 # are required prior [variable] frame setup is completed, note that
794 # nobody says that you can have only one "magic point." You can
795 # "liberate" non-volatile registers by denoting last stack off-load
796 # instruction and reflecting it in finer grade unwind logic in handler.
797 # After all, isn't it why it's called *language-specific* handler...
799 # Attentive reader can notice that exceptions would be mishandled in
800 # auto-generated "gear" epilogue. Well, exception effectively can't
801 # occur there, because if memory area used by it was subject to
802 # segmentation violation, then it would be raised upon call to the
803 # function (and as already mentioned be accounted to caller, which is
804 # not a problem). If you're still not comfortable, then define tail
805 # "magic point" just prior ret instruction and have handler treat it...
807 # (*) Note that we're talking about run-time, not debug-time. Lack of
808 # unwind information makes debugging hard on both Windows and
809 # Unix. "Unlike" referes to the fact that on Unix signal handler
810 # will always be invoked, core dumped and appropriate exit code
811 # returned to parent (for user notification).