Carlo Kok via llvm-dev
2016-Apr-04 21:27 UTC
[llvm-dev] How to call an (x86) cleanup/catchpad funclet
I've modified llvm to emit vc++ compatible SEH structures for my personality on x86/Windows and my handler works fine, but the only thing I can't figure out is how to call these funclets, they look like: Catch: "?catch$3@?0?m3 at 4HA": LBB4_3: # %BasicBlock26 pushl %ebp pushl %eax addl $12, %ebp movl %esp, -28(%ebp) movl $LBB4_5, %eax addl $4, %esp popl %ebp retl # CATCHRET cleanup: "?dtor$2@?0?m2 at 4HA": LBB3_2: pushl %ebp subl $8, %esp addl $12, %ebp movl %ebp, %eax movl %esp, %ecx movl %eax, 4(%ecx) movl $1, (%ecx) calll m2$Fin addl $8, %esp popl %ebp retl # CLEANUPRET What do I pass to these to get a valid frame on the other end? The cleanup one calls the finally and properly returns, but what about the catch? -- Carlo Kok
Reid Kleckner via llvm-dev
2016-Apr-04 23:35 UTC
[llvm-dev] How to call an (x86) cleanup/catchpad funclet
For 32-bit x86, set EBP to the address of the end of the SEH registration node before calling any funclet. The prologue does 'addl $12, %ebp' to recompute the real frame pointer from that address. The return value of the catch handler is the label that you should jump to with EBP set in the same manner. The code at that label will take care of restoring other registers. Also, unless you absolutely need to be compatible with MSVC exceptions, don't use funclets for your new personality. Use landingpads. They are better and will get you better code. On Mon, Apr 4, 2016 at 2:27 PM, Carlo Kok via llvm-dev < llvm-dev at lists.llvm.org> wrote:> I've modified llvm to emit vc++ compatible SEH structures for my > personality on x86/Windows and my handler works fine, but the only thing I > can't figure out is how to call these funclets, they look like: > > > Catch: > > "?catch$3@?0?m3 at 4HA": > LBB4_3: # %BasicBlock26 > pushl %ebp > pushl %eax > addl $12, %ebp > movl %esp, -28(%ebp) > movl $LBB4_5, %eax > addl $4, %esp > popl %ebp > retl # CATCHRET > > > cleanup: > "?dtor$2@?0?m2 at 4HA": > LBB3_2: > pushl %ebp > subl $8, %esp > addl $12, %ebp > movl %ebp, %eax > movl %esp, %ecx > movl %eax, 4(%ecx) > movl $1, (%ecx) > calll m2$Fin > addl $8, %esp > popl %ebp > retl # CLEANUPRET > > > What do I pass to these to get a valid frame on the other end? > > The cleanup one calls the finally and properly returns, but what about the > catch? > > -- > Carlo Kok > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160404/cdf01418/attachment.html>
Carlo Kok via llvm-dev
2016-Apr-05 07:57 UTC
[llvm-dev] How to call an (x86) cleanup/catchpad funclet
Op 2016-04-05 om 01:35 schreef Reid Kleckner:> For 32-bit x86, set EBP to the address of the end of the SEH > registration node before calling any funclet. The prologue does 'addl > $12, %ebp' to recompute the real frame pointer from that address. The > return value of the catch handler is the label that you should jump to > with EBP set in the same manner. The code at that label will take care > of restoring other registers.thanks! that works.> > Also, unless you absolutely need to be compatible with MSVC exceptions, > don't use funclets for your new personality. Use landingpads. They are > better and will get you better code.ah ke, but landingpads won't let me catch SEH exceptions will they? -- Carlo Kok RemObjects Software
Apparently Analagous Threads
- [RFC] [Windows SEH] Local_Unwind (Jumping out of a _finally) and -EHa (Hardware Exception Handling)
- LLVM SEH docs -- enregistration of locals in nonvolatile registers?
- Potential missed optimisation with SEH funclets
- Incorrect code generation when using -fprofile-generate on code which contains exception handling (Windows target)
- LLVM SEH docs -- enregistration of locals in nonvolatile registers?