home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 4,594 of 4,675   
   Thorsten Glaser to All   
   Re: Please explain exception handling in   
   26 Apr 23 13:43:27   
   
   From: tg@nospicedham.mirbsd.de   
      
   Frederick Virchanza Gotham dixit:   
      
   >(1) Why does Func save and restore the RBX register if it never changes it?   
      
   Compilers tend to do that (frame pointer things).   
      
   >(2)  If 'LibFunc' throws an exception, how does it know where to jump   
   >back to? In normal circumstances if the function returned normally, it   
   >would jump back to the 'jmp .L1' instruction, but instead it has to   
   >jump back to one instruction after that. How does it know what offset   
   >of the return address to jump back to?   
      
   This is only one form of exception handling: it uses unwind information   
   from a separate part of the executable to know where to jump back to.   
      
   In normal operation, the call returns normally, then the jmp is   
   executed terminating the function. If an exception is thrown, the   
   handler walks back the call stack then changes the return address.   
      
   There’s also setjmp/longjmp-based exception handling (“sjlj” if you   
   ever compile GCC) which uses these libc functions instead of relying   
   on magic debugging information to unwind. That may be easier to   
   understand so I suggest having a look at that.   
      
   >(3) I don't know why those last four lines are there. They look like   
   >unreachable code to me.   
      
   As above, they’ll be reached by changing the return address. Your   
   compiler probably added some .cfi_* pseudo-ops for the assembler   
   there which would have the corresponding debugging info.   
      
   bye,   
   //mirabilos   
   --    
   15:41⎜ Somebody write a testsuite for helloworld :-)   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca