_Unwind_Personality_Fn p = get_handler_function(&frameInfo); // ....
_Unwind_Reason_Code personalityResult =(*p)( 1, action, exception_object->exception_class, exception_object, (struct _Unwind_Context *)(cursor)
);
_Unwind_Personality_Fn p = get_handler_function(&frameInfo); // ....
_Unwind_Reason_Code personalityResult =(*p)( 1, action, exception_object->exception_class, exception_object, (struct _Unwind_Context *)(cursor)
);
_Unwind_Personality_Fn p = get_handler_function(&frameInfo); // ....
_Unwind_Reason_Code personalityResult =(*p)( 1, action, exception_object->exception_class, exception_object, (struct _Unwind_Context *)(cursor)
);
int bar()
{ throw -1;
} int foo()
{ try { return bar(); } catch (...) { return -1; }
} int main()
{ return foo();
}
int bar()
{ throw -1;
} int foo()
{ try { return bar(); } catch (...) { return -1; }
} int main()
{ return foo();
}
int bar()
{ throw -1;
} int foo()
{ try { return bar(); } catch (...) { return -1; }
} int main()
{ return foo();
}
bar(): push rbp mov rbp, rsp mov edi, 4 call __cxa_allocate_exception@PLT mov rdi, rax mov dword ptr [rdi], -1 mov rsi, qword ptr [rip + typeinfo for int@GOTPCREL] xor eax, eax mov edx, eax call __cxa_throw@PLT foo(): push rbp mov rbp, rsp sub rsp, 16 call bar() mov dword ptr [rbp - 16], eax jmp .LBB1_1
.LBB1_1: mov eax, dword ptr [rbp - 16] add rsp, 16 pop rbp ret mov rcx, rax mov eax, edx mov qword ptr [rbp - 8], rcx mov dword ptr [rbp - 12], eax mov rdi, qword ptr [rbp - 8] call __cxa_begin_catch@PLT mov edi, 4 call __cxa_allocate_exception@PLT mov rdi, rax mov dword ptr [rdi], -1 mov rsi, qword ptr [rip + typeinfo for int@GOTPCREL] xor eax, eax mov edx, eax call __cxa_throw@PLT jmp .LBB1_8 mov rcx, rax mov eax, edx mov qword ptr [rbp - 8], rcx mov dword ptr [rbp - 12], eax call __cxa_end_catch@PLT jmp .LBB1_5
.LBB1_5: jmp .LBB1_6
.LBB1_6: mov rdi, qword ptr [rbp - 8] call _Unwind_Resume@PLT mov rdi, rax call __clang_call_terminate
.LBB1_8: __clang_call_terminate: push rbp mov rbp, rsp call __cxa_begin_catch@PLT call std::terminate()@PLT main: push rbp mov rbp, rsp sub rsp, 16 mov dword ptr [rbp - 4], 0 call foo() add rsp, 16 pop rbp ret DW.ref.__gxx_personality_v0: .quad __gxx_personality_v0
bar(): push rbp mov rbp, rsp mov edi, 4 call __cxa_allocate_exception@PLT mov rdi, rax mov dword ptr [rdi], -1 mov rsi, qword ptr [rip + typeinfo for int@GOTPCREL] xor eax, eax mov edx, eax call __cxa_throw@PLT foo(): push rbp mov rbp, rsp sub rsp, 16 call bar() mov dword ptr [rbp - 16], eax jmp .LBB1_1
.LBB1_1: mov eax, dword ptr [rbp - 16] add rsp, 16 pop rbp ret mov rcx, rax mov eax, edx mov qword ptr [rbp - 8], rcx mov dword ptr [rbp - 12], eax mov rdi, qword ptr [rbp - 8] call __cxa_begin_catch@PLT mov edi, 4 call __cxa_allocate_exception@PLT mov rdi, rax mov dword ptr [rdi], -1 mov rsi, qword ptr [rip + typeinfo for int@GOTPCREL] xor eax, eax mov edx, eax call __cxa_throw@PLT jmp .LBB1_8 mov rcx, rax mov eax, edx mov qword ptr [rbp - 8], rcx mov dword ptr [rbp - 12], eax call __cxa_end_catch@PLT jmp .LBB1_5
.LBB1_5: jmp .LBB1_6
.LBB1_6: mov rdi, qword ptr [rbp - 8] call _Unwind_Resume@PLT mov rdi, rax call __clang_call_terminate
.LBB1_8: __clang_call_terminate: push rbp mov rbp, rsp call __cxa_begin_catch@PLT call std::terminate()@PLT main: push rbp mov rbp, rsp sub rsp, 16 mov dword ptr [rbp - 4], 0 call foo() add rsp, 16 pop rbp ret DW.ref.__gxx_personality_v0: .quad __gxx_personality_v0
bar(): push rbp mov rbp, rsp mov edi, 4 call __cxa_allocate_exception@PLT mov rdi, rax mov dword ptr [rdi], -1 mov rsi, qword ptr [rip + typeinfo for int@GOTPCREL] xor eax, eax mov edx, eax call __cxa_throw@PLT foo(): push rbp mov rbp, rsp sub rsp, 16 call bar() mov dword ptr [rbp - 16], eax jmp .LBB1_1
.LBB1_1: mov eax, dword ptr [rbp - 16] add rsp, 16 pop rbp ret mov rcx, rax mov eax, edx mov qword ptr [rbp - 8], rcx mov dword ptr [rbp - 12], eax mov rdi, qword ptr [rbp - 8] call __cxa_begin_catch@PLT mov edi, 4 call __cxa_allocate_exception@PLT mov rdi, rax mov dword ptr [rdi], -1 mov rsi, qword ptr [rip + typeinfo for int@GOTPCREL] xor eax, eax mov edx, eax call __cxa_throw@PLT jmp .LBB1_8 mov rcx, rax mov eax, edx mov qword ptr [rbp - 8], rcx mov dword ptr [rbp - 12], eax call __cxa_end_catch@PLT jmp .LBB1_5
.LBB1_5: jmp .LBB1_6
.LBB1_6: mov rdi, qword ptr [rbp - 8] call _Unwind_Resume@PLT mov rdi, rax call __clang_call_terminate
.LBB1_8: __clang_call_terminate: push rbp mov rbp, rsp call __cxa_begin_catch@PLT call std::terminate()@PLT main: push rbp mov rbp, rsp sub rsp, 16 mov dword ptr [rbp - 4], 0 call foo() add rsp, 16 pop rbp ret DW.ref.__gxx_personality_v0: .quad __gxx_personality_v0
unw_context_t uc; unw_cursor_t cursor; __unw_getcontext(&uc);
unw_context_t uc; unw_cursor_t cursor; __unw_getcontext(&uc);
unw_context_t uc; unw_cursor_t cursor; __unw_getcontext(&uc);
static _Unwind_Reason_Code
unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object)
{ __unw_init_local(cursor, uc); ....
}
static _Unwind_Reason_Code
unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object)
{ __unw_init_local(cursor, uc); ....
}
static _Unwind_Reason_Code
unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object)
{ __unw_init_local(cursor, uc); ....
}
// Use "placement new" to allocate UnwindCursor in the cursor buffer.
new (reinterpret_cast<UnwindCursor<LocalAddressSpace, REGISTER_KIND> *>(cursor)) UnwindCursor<LocalAddressSpace, REGISTER_KIND>( context, LocalAddressSpace::sThisAddressSpace );
// Use "placement new" to allocate UnwindCursor in the cursor buffer.
new (reinterpret_cast<UnwindCursor<LocalAddressSpace, REGISTER_KIND> *>(cursor)) UnwindCursor<LocalAddressSpace, REGISTER_KIND>( context, LocalAddressSpace::sThisAddressSpace );
// Use "placement new" to allocate UnwindCursor in the cursor buffer.
new (reinterpret_cast<UnwindCursor<LocalAddressSpace, REGISTER_KIND> *>(cursor)) UnwindCursor<LocalAddressSpace, REGISTER_KIND>( context, LocalAddressSpace::sThisAddressSpace );
_Unwind_Personality_Fn p = get_handler_function(&frameInfo); // ....
_Unwind_Reason_Code personalityResult =(*p)( 1, action, exception_object->exception_class, exception_object, (struct _Unwind_Context *)(cursor)
);
_Unwind_Personality_Fn p = get_handler_function(&frameInfo); // ....
_Unwind_Reason_Code personalityResult =(*p)( 1, action, exception_object->exception_class, exception_object, (struct _Unwind_Context *)(cursor)
);
_Unwind_Personality_Fn p = get_handler_function(&frameInfo); // ....
_Unwind_Reason_Code personalityResult =(*p)( 1, action, exception_object->exception_class, exception_object, (struct _Unwind_Context *)(cursor)
);
unw_proc_info_t frameInfo;
if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS)
{ // ....
}
unw_proc_info_t frameInfo;
if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS)
{ // ....
}
unw_proc_info_t frameInfo;
if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS)
{ // ....
}
$ readelf -w main
Contents of the .eh_frame section: 00000000 0000000000000014 00000000 CIE Version: 1 Augmentation: "zR" Code alignment factor: 1 Data alignment factor: -8 Return address column: 16 Augmentation data: 1b DW_CFA_def_cfa: r7 (rsp) ofs 8 DW_CFA_offset: r16 (rip) at cfa-8 DW_CFA_nop DW_CFA_nop 00000018 0000000000000014 0000001c FDE cie=00000000
pc=00000000000010a0..00000000000010c6 DW_CFA_advance_loc: 4 to 00000000000010a4 DW_CFA_undefined: r16 (rip) DW_CFA_nop DW_CFA_nop DW_CFA_nop DW_CFA_nop 00000030 0000000000000024 00000034 FDE cie=00000000
pc=0000000000001020..0000000000001090 DW_CFA_def_cfa_offset: 16 DW_CFA_advance_loc: 6 to 0000000000001026 DW_CFA_def_cfa_offset: 24 DW_CFA_advance_loc: 10 to 0000000000001030 DW_CFA_def_cfa_expression ; ... DW_CFA_nop DW_CFA_nop DW_CFA_nop DW_CFA_nop
$ readelf -w main
Contents of the .eh_frame section: 00000000 0000000000000014 00000000 CIE Version: 1 Augmentation: "zR" Code alignment factor: 1 Data alignment factor: -8 Return address column: 16 Augmentation data: 1b DW_CFA_def_cfa: r7 (rsp) ofs 8 DW_CFA_offset: r16 (rip) at cfa-8 DW_CFA_nop DW_CFA_nop 00000018 0000000000000014 0000001c FDE cie=00000000
pc=00000000000010a0..00000000000010c6 DW_CFA_advance_loc: 4 to 00000000000010a4 DW_CFA_undefined: r16 (rip) DW_CFA_nop DW_CFA_nop DW_CFA_nop DW_CFA_nop 00000030 0000000000000024 00000034 FDE cie=00000000
pc=0000000000001020..0000000000001090 DW_CFA_def_cfa_offset: 16 DW_CFA_advance_loc: 6 to 0000000000001026 DW_CFA_def_cfa_offset: 24 DW_CFA_advance_loc: 10 to 0000000000001030 DW_CFA_def_cfa_expression ; ... DW_CFA_nop DW_CFA_nop DW_CFA_nop DW_CFA_nop
$ readelf -w main
Contents of the .eh_frame section: 00000000 0000000000000014 00000000 CIE Version: 1 Augmentation: "zR" Code alignment factor: 1 Data alignment factor: -8 Return address column: 16 Augmentation data: 1b DW_CFA_def_cfa: r7 (rsp) ofs 8 DW_CFA_offset: r16 (rip) at cfa-8 DW_CFA_nop DW_CFA_nop 00000018 0000000000000014 0000001c FDE cie=00000000
pc=00000000000010a0..00000000000010c6 DW_CFA_advance_loc: 4 to 00000000000010a4 DW_CFA_undefined: r16 (rip) DW_CFA_nop DW_CFA_nop DW_CFA_nop DW_CFA_nop 00000030 0000000000000024 00000034 FDE cie=00000000
pc=0000000000001020..0000000000001090 DW_CFA_def_cfa_offset: 16 DW_CFA_advance_loc: 6 to 0000000000001026 DW_CFA_def_cfa_offset: 24 DW_CFA_advance_loc: 10 to 0000000000001030 DW_CFA_def_cfa_expression ; ... DW_CFA_nop DW_CFA_nop DW_CFA_nop DW_CFA_nop
foo():
.Lfunc_begin1: .loc 1 7 0 .cfi_startproc .cfi_personality 155, DW.ref.__gxx_personality_v0 .cfi_lsda 27, .Lexception0
foo():
.Lfunc_begin1: .loc 1 7 0 .cfi_startproc .cfi_personality 155, DW.ref.__gxx_personality_v0 .cfi_lsda 27, .Lexception0
foo():
.Lfunc_begin1: .loc 1 7 0 .cfi_startproc .cfi_personality 155, DW.ref.__gxx_personality_v0 .cfi_lsda 27, .Lexception0
DW.ref.__gxx_personality_v0: .quad __gxx_personality_v0 .ident "clang version 21.1.0 .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym bar() .addrsig_sym __cxa_allocate_exception .addrsig_sym __cxa_throw .addrsig_sym foo() .addrsig_sym __gxx_personality_v0 .addrsig_sym __cxa_begin_catch .addrsig_sym __cxa_end_catch .addrsig_sym __clang_call_terminate .addrsig_sym _ZSt9terminatev .addrsig_sym _Unwind_Resume .addrsig_sym _ZTIi .section .debug_line,"",@progbits
DW.ref.__gxx_personality_v0: .quad __gxx_personality_v0 .ident "clang version 21.1.0 .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym bar() .addrsig_sym __cxa_allocate_exception .addrsig_sym __cxa_throw .addrsig_sym foo() .addrsig_sym __gxx_personality_v0 .addrsig_sym __cxa_begin_catch .addrsig_sym __cxa_end_catch .addrsig_sym __clang_call_terminate .addrsig_sym _ZSt9terminatev .addrsig_sym _Unwind_Resume .addrsig_sym _ZTIi .section .debug_line,"",@progbits
DW.ref.__gxx_personality_v0: .quad __gxx_personality_v0 .ident "clang version 21.1.0 .section ".note.GNU-stack","",@progbits .addrsig .addrsig_sym bar() .addrsig_sym __cxa_allocate_exception .addrsig_sym __cxa_throw .addrsig_sym foo() .addrsig_sym __gxx_personality_v0 .addrsig_sym __cxa_begin_catch .addrsig_sym __cxa_end_catch .addrsig_sym __clang_call_terminate .addrsig_sym _ZSt9terminatev .addrsig_sym _Unwind_Resume .addrsig_sym _ZTIi .section .debug_line,"",@progbits
GCC_except_table1:
.Lexception0: .byte 255 .byte 155 .uleb128 .Lttbase0-.Lttbaseref0
.Lttbaseref0: .byte 1 .uleb128 .Lcst_end0-.Lcst_begin0
; ...
GCC_except_table1:
.Lexception0: .byte 255 .byte 155 .uleb128 .Lttbase0-.Lttbaseref0
.Lttbaseref0: .byte 1 .uleb128 .Lcst_end0-.Lcst_begin0
; ...
GCC_except_table1:
.Lexception0: .byte 255 .byte 155 .uleb128 .Lttbase0-.Lttbaseref0
.Lttbaseref0: .byte 1 .uleb128 .Lcst_end0-.Lcst_begin0
; ...
if (actions == (_UA_CLEANUP_PHASE | _UA_HANDLER_FRAME) && native_exception) { // Reload the results from the phase 1 cache. __cxa_exception* exception_header = (__cxa_exception*)(unwind_exception + 1) - 1; results.ttypeIndex = exception_header->handlerSwitchValue; results.actionRecord = exception_header->actionRecord; results.languageSpecificData = exception_header->languageSpecificData; set_landing_pad(results, exception_header->catchTemp); results.adjustedPtr = exception_header->adjustedPtr; set_registers(unwind_exception, context, results); if (results.ttypeIndex < 0) { exception_header->catchTemp = 0; } return _URC_INSTALL_CONTEXT;
}
if (actions == (_UA_CLEANUP_PHASE | _UA_HANDLER_FRAME) && native_exception) { // Reload the results from the phase 1 cache. __cxa_exception* exception_header = (__cxa_exception*)(unwind_exception + 1) - 1; results.ttypeIndex = exception_header->handlerSwitchValue; results.actionRecord = exception_header->actionRecord; results.languageSpecificData = exception_header->languageSpecificData; set_landing_pad(results, exception_header->catchTemp); results.adjustedPtr = exception_header->adjustedPtr; set_registers(unwind_exception, context, results); if (results.ttypeIndex < 0) { exception_header->catchTemp = 0; } return _URC_INSTALL_CONTEXT;
}
if (actions == (_UA_CLEANUP_PHASE | _UA_HANDLER_FRAME) && native_exception) { // Reload the results from the phase 1 cache. __cxa_exception* exception_header = (__cxa_exception*)(unwind_exception + 1) - 1; results.ttypeIndex = exception_header->handlerSwitchValue; results.actionRecord = exception_header->actionRecord; results.languageSpecificData = exception_header->languageSpecificData; set_landing_pad(results, exception_header->catchTemp); results.adjustedPtr = exception_header->adjustedPtr; set_registers(unwind_exception, context, results); if (results.ttypeIndex < 0) { exception_header->catchTemp = 0; } return _URC_INSTALL_CONTEXT;
}
scan_eh_tab(results, actions, native_exception, unwind_exception, context);
scan_eh_tab(results, actions, native_exception, unwind_exception, context);
scan_eh_tab(results, actions, native_exception, unwind_exception, context);
if (results.reason == _URC_CONTINUE_UNWIND || results.reason == _URC_FATAL_PHASE1_ERROR) return results.reason; if (actions & _UA_SEARCH_PHASE)
{ assert(results.reason == _URC_HANDLER_FOUND); if (native_exception) { __cxa_exception* exc = (__cxa_exception*)(unwind_exception + 1) - 1; exc->handlerSwitchValue = static_cast<int>(results.ttypeIndex); exc->actionRecord = results.actionRecord; exc->languageSpecificData = results.languageSpecificData; get_landing_pad(exc->catchTemp, results); exc->adjustedPtr = results.adjustedPtr; } return _URC_HANDLER_FOUND;
}
if (results.reason == _URC_CONTINUE_UNWIND || results.reason == _URC_FATAL_PHASE1_ERROR) return results.reason; if (actions & _UA_SEARCH_PHASE)
{ assert(results.reason == _URC_HANDLER_FOUND); if (native_exception) { __cxa_exception* exc = (__cxa_exception*)(unwind_exception + 1) - 1; exc->handlerSwitchValue = static_cast<int>(results.ttypeIndex); exc->actionRecord = results.actionRecord; exc->languageSpecificData = results.languageSpecificData; get_landing_pad(exc->catchTemp, results); exc->adjustedPtr = results.adjustedPtr; } return _URC_HANDLER_FOUND;
}
if (results.reason == _URC_CONTINUE_UNWIND || results.reason == _URC_FATAL_PHASE1_ERROR) return results.reason; if (actions & _UA_SEARCH_PHASE)
{ assert(results.reason == _URC_HANDLER_FOUND); if (native_exception) { __cxa_exception* exc = (__cxa_exception*)(unwind_exception + 1) - 1; exc->handlerSwitchValue = static_cast<int>(results.ttypeIndex); exc->actionRecord = results.actionRecord; exc->languageSpecificData = results.languageSpecificData; get_landing_pad(exc->catchTemp, results); exc->adjustedPtr = results.adjustedPtr; } return _URC_HANDLER_FOUND;
}
assert(actions & _UA_CLEANUP_PHASE);
assert(results.reason == _URC_HANDLER_FOUND);
assert(actions & _UA_CLEANUP_PHASE);
assert(results.reason == _URC_HANDLER_FOUND);
assert(actions & _UA_CLEANUP_PHASE);
assert(results.reason == _URC_HANDLER_FOUND);
set_registers(unwind_exception, context, results);
if (results.ttypeIndex < 0) { __cxa_exception* exception_header = (__cxa_exception*)(unwind_exception + 1) - 1; exception_header->catchTemp = 0;
}
return _URC_INSTALL_CONTEXT;
set_registers(unwind_exception, context, results);
if (results.ttypeIndex < 0) { __cxa_exception* exception_header = (__cxa_exception*)(unwind_exception + 1) - 1; exception_header->catchTemp = 0;
}
return _URC_INSTALL_CONTEXT;
set_registers(unwind_exception, context, results);
if (results.ttypeIndex < 0) { __cxa_exception* exception_header = (__cxa_exception*)(unwind_exception + 1) - 1; exception_header->catchTemp = 0;
}
return _URC_INSTALL_CONTEXT;
========================
Lsda header
LPStart Encoding
LPStart (optional)
TType Encoding
TType Offset (optional)
Call-Site Encoding
Call-Site Table Length
========================
Call-Site Table
------------------------
start of a call site
length of a call site
landingPad (handler) offset (from landingPad base)
actionEntry (1-based offset)
------------------------
------------------------
start of a call site
length of a call site
landingPad (handler) offset (from landingPad base)
actionEntry (1-based offset)
------------------------
========================
Action Table
------------------------
ttypeIndex = 3
nextOffset = -3 ------------------------
------------------------
ttypeIndex = 2
nextOffset = -3 ------------------------
------------------------
ttypeIndex = 1
nextOffset = 0
------------------------
========================
Type Table (RTTI)
------------------------
index 1 ──> typeinfo(float)
------------------------
------------------------
index 2 ──> typeinfo(int)
------------------------
------------------------
index 3 ──> typeinfo(T)
------------------------
========================
========================
Lsda header
LPStart Encoding
LPStart (optional)
TType Encoding
TType Offset (optional)
Call-Site Encoding
Call-Site Table Length
========================
Call-Site Table
------------------------
start of a call site
length of a call site
landingPad (handler) offset (from landingPad base)
actionEntry (1-based offset)
------------------------
------------------------
start of a call site
length of a call site
landingPad (handler) offset (from landingPad base)
actionEntry (1-based offset)
------------------------
========================
Action Table
------------------------
ttypeIndex = 3
nextOffset = -3 ------------------------
------------------------
ttypeIndex = 2
nextOffset = -3 ------------------------
------------------------
ttypeIndex = 1
nextOffset = 0
------------------------
========================
Type Table (RTTI)
------------------------
index 1 ──> typeinfo(float)
------------------------
------------------------
index 2 ──> typeinfo(int)
------------------------
------------------------
index 3 ──> typeinfo(T)
------------------------
========================
========================
Lsda header
LPStart Encoding
LPStart (optional)
TType Encoding
TType Offset (optional)
Call-Site Encoding
Call-Site Table Length
========================
Call-Site Table
------------------------
start of a call site
length of a call site
landingPad (handler) offset (from landingPad base)
actionEntry (1-based offset)
------------------------
------------------------
start of a call site
length of a call site
landingPad (handler) offset (from landingPad base)
actionEntry (1-based offset)
------------------------
========================
Action Table
------------------------
ttypeIndex = 3
nextOffset = -3 ------------------------
------------------------
ttypeIndex = 2
nextOffset = -3 ------------------------
------------------------
ttypeIndex = 1
nextOffset = 0
------------------------
========================
Type Table (RTTI)
------------------------
index 1 ──> typeinfo(float)
------------------------
------------------------
index 2 ──> typeinfo(int)
------------------------
------------------------
index 3 ──> typeinfo(T)
------------------------
========================
#include <stdlib.h> int bar() throw (int)
{ return (rand() % 2) ? throw -1 : -666;
} int foo()
{ try { return bar(); } catch(float) { return 69; } catch(int) { return 42; } catch (...) { //skiped intentionally } return 666;
} int main()
{ return foo();
}
#include <stdlib.h> int bar() throw (int)
{ return (rand() % 2) ? throw -1 : -666;
} int foo()
{ try { return bar(); } catch(float) { return 69; } catch(int) { return 42; } catch (...) { //skiped intentionally } return 666;
} int main()
{ return foo();
}
#include <stdlib.h> int bar() throw (int)
{ return (rand() % 2) ? throw -1 : -666;
} int foo()
{ try { return bar(); } catch(float) { return 69; } catch(int) { return 42; } catch (...) { //skiped intentionally } return 666;
} int main()
{ return foo();
}
bar(): push rbp mov rbp, rsp sub rsp, 32 call rand@PLT mov ecx, 2 cdq idiv ecx mov byte ptr [rbp - 9], 0 cmp edx, 0 je .LBB0_2 mov edi, 4 call __cxa_allocate_exception@PLT mov rdi, rax mov qword ptr [rbp - 8], rdi mov byte ptr [rbp - 9], 1 mov dword ptr [rdi], -1 mov rsi, qword ptr [rip + typeinfo for int@GOTPCREL] xor eax, eax mov edx, eax call __cxa_throw@PLT jmp .LBB0_8
.LBB0_2: jmp .LBB0_3
.LBB0_3: mov eax, 4294966630 add rsp, 32 pop rbp ret mov rcx, rax mov eax, edx mov qword ptr [rbp - 24], rcx mov dword ptr [rbp - 28], eax cmp dword ptr [rbp - 28], 0 jge .LBB0_7 mov rdi, qword ptr [rbp - 24] call __cxa_call_unexpected@PLT
.LBB0_7: mov rdi, qword ptr [rbp - 24] call _Unwind_Resume@PLT
.LBB0_8: foo(): push rbp mov rbp, rsp sub rsp, 48 call bar() mov dword ptr [rbp - 32], eax jmp .LBB1_1
.LBB1_1: mov eax, dword ptr [rbp - 32] mov dword ptr [rbp - 4], eax jmp .LBB1_9 mov rcx, rax mov eax, edx mov qword ptr [rbp - 16], rcx mov dword ptr [rbp - 20], eax mov eax, dword ptr [rbp - 20] mov dword ptr [rbp - 36], eax mov ecx, 3 cmp eax, ecx jne .LBB1_5 mov rdi, qword ptr [rbp - 16] call __cxa_begin_catch@PLT movss xmm0, dword ptr [rax] movss dword ptr [rbp - 28], xmm0 mov dword ptr [rbp - 4], 69 call __cxa_end_catch@PLT jmp .LBB1_9
.LBB1_5: mov eax, dword ptr [rbp - 36] mov ecx, 2 cmp eax, ecx jne .LBB1_7 mov rdi, qword ptr [rbp - 16] call __cxa_begin_catch@PLT mov eax, dword ptr [rax] mov dword ptr [rbp - 24], eax mov dword ptr [rbp - 4], 42 call __cxa_end_catch@PLT jmp .LBB1_9
.LBB1_7: mov rdi, qword ptr [rbp - 16] call __cxa_begin_catch@PLT call __cxa_end_catch@PLT mov dword ptr [rbp - 4], 666
.LBB1_9: mov eax, dword ptr [rbp - 4] add rsp, 48 pop rbp ret main: push rbp mov rbp, rsp sub rsp, 16 mov dword ptr [rbp - 4], 0 call foo() add rsp, 16 pop rbp ret DW.ref.__gxx_personality_v0: .quad __gxx_personality_v0
bar(): push rbp mov rbp, rsp sub rsp, 32 call rand@PLT mov ecx, 2 cdq idiv ecx mov byte ptr [rbp - 9], 0 cmp edx, 0 je .LBB0_2 mov edi, 4 call __cxa_allocate_exception@PLT mov rdi, rax mov qword ptr [rbp - 8], rdi mov byte ptr [rbp - 9], 1 mov dword ptr [rdi], -1 mov rsi, qword ptr [rip + typeinfo for int@GOTPCREL] xor eax, eax mov edx, eax call __cxa_throw@PLT jmp .LBB0_8
.LBB0_2: jmp .LBB0_3
.LBB0_3: mov eax, 4294966630 add rsp, 32 pop rbp ret mov rcx, rax mov eax, edx mov qword ptr [rbp - 24], rcx mov dword ptr [rbp - 28], eax cmp dword ptr [rbp - 28], 0 jge .LBB0_7 mov rdi, qword ptr [rbp - 24] call __cxa_call_unexpected@PLT
.LBB0_7: mov rdi, qword ptr [rbp - 24] call _Unwind_Resume@PLT
.LBB0_8: foo(): push rbp mov rbp, rsp sub rsp, 48 call bar() mov dword ptr [rbp - 32], eax jmp .LBB1_1
.LBB1_1: mov eax, dword ptr [rbp - 32] mov dword ptr [rbp - 4], eax jmp .LBB1_9 mov rcx, rax mov eax, edx mov qword ptr [rbp - 16], rcx mov dword ptr [rbp - 20], eax mov eax, dword ptr [rbp - 20] mov dword ptr [rbp - 36], eax mov ecx, 3 cmp eax, ecx jne .LBB1_5 mov rdi, qword ptr [rbp - 16] call __cxa_begin_catch@PLT movss xmm0, dword ptr [rax] movss dword ptr [rbp - 28], xmm0 mov dword ptr [rbp - 4], 69 call __cxa_end_catch@PLT jmp .LBB1_9
.LBB1_5: mov eax, dword ptr [rbp - 36] mov ecx, 2 cmp eax, ecx jne .LBB1_7 mov rdi, qword ptr [rbp - 16] call __cxa_begin_catch@PLT mov eax, dword ptr [rax] mov dword ptr [rbp - 24], eax mov dword ptr [rbp - 4], 42 call __cxa_end_catch@PLT jmp .LBB1_9
.LBB1_7: mov rdi, qword ptr [rbp - 16] call __cxa_begin_catch@PLT call __cxa_end_catch@PLT mov dword ptr [rbp - 4], 666
.LBB1_9: mov eax, dword ptr [rbp - 4] add rsp, 48 pop rbp ret main: push rbp mov rbp, rsp sub rsp, 16 mov dword ptr [rbp - 4], 0 call foo() add rsp, 16 pop rbp ret DW.ref.__gxx_personality_v0: .quad __gxx_personality_v0
bar(): push rbp mov rbp, rsp sub rsp, 32 call rand@PLT mov ecx, 2 cdq idiv ecx mov byte ptr [rbp - 9], 0 cmp edx, 0 je .LBB0_2 mov edi, 4 call __cxa_allocate_exception@PLT mov rdi, rax mov qword ptr [rbp - 8], rdi mov byte ptr [rbp - 9], 1 mov dword ptr [rdi], -1 mov rsi, qword ptr [rip + typeinfo for int@GOTPCREL] xor eax, eax mov edx, eax call __cxa_throw@PLT jmp .LBB0_8
.LBB0_2: jmp .LBB0_3
.LBB0_3: mov eax, 4294966630 add rsp, 32 pop rbp ret mov rcx, rax mov eax, edx mov qword ptr [rbp - 24], rcx mov dword ptr [rbp - 28], eax cmp dword ptr [rbp - 28], 0 jge .LBB0_7 mov rdi, qword ptr [rbp - 24] call __cxa_call_unexpected@PLT
.LBB0_7: mov rdi, qword ptr [rbp - 24] call _Unwind_Resume@PLT
.LBB0_8: foo(): push rbp mov rbp, rsp sub rsp, 48 call bar() mov dword ptr [rbp - 32], eax jmp .LBB1_1
.LBB1_1: mov eax, dword ptr [rbp - 32] mov dword ptr [rbp - 4], eax jmp .LBB1_9 mov rcx, rax mov eax, edx mov qword ptr [rbp - 16], rcx mov dword ptr [rbp - 20], eax mov eax, dword ptr [rbp - 20] mov dword ptr [rbp - 36], eax mov ecx, 3 cmp eax, ecx jne .LBB1_5 mov rdi, qword ptr [rbp - 16] call __cxa_begin_catch@PLT movss xmm0, dword ptr [rax] movss dword ptr [rbp - 28], xmm0 mov dword ptr [rbp - 4], 69 call __cxa_end_catch@PLT jmp .LBB1_9
.LBB1_5: mov eax, dword ptr [rbp - 36] mov ecx, 2 cmp eax, ecx jne .LBB1_7 mov rdi, qword ptr [rbp - 16] call __cxa_begin_catch@PLT mov eax, dword ptr [rax] mov dword ptr [rbp - 24], eax mov dword ptr [rbp - 4], 42 call __cxa_end_catch@PLT jmp .LBB1_9
.LBB1_7: mov rdi, qword ptr [rbp - 16] call __cxa_begin_catch@PLT call __cxa_end_catch@PLT mov dword ptr [rbp - 4], 666
.LBB1_9: mov eax, dword ptr [rbp - 4] add rsp, 48 pop rbp ret main: push rbp mov rbp, rsp sub rsp, 16 mov dword ptr [rbp - 4], 0 call foo() add rsp, 16 pop rbp ret DW.ref.__gxx_personality_v0: .quad __gxx_personality_v0
.LBB0_3: mov eax, 4294966630 add rsp, 32 pop rbp ret mov rcx, rax mov eax, edx mov qword ptr [rbp - 24], rcx mov dword ptr [rbp - 28], eax cmp dword ptr [rbp - 28], 0 jge .LBB0_7 mov rdi, qword ptr [rbp - 24] call __cxa_call_unexpected@PLT
.LBB0_3: mov eax, 4294966630 add rsp, 32 pop rbp ret mov rcx, rax mov eax, edx mov qword ptr [rbp - 24], rcx mov dword ptr [rbp - 28], eax cmp dword ptr [rbp - 28], 0 jge .LBB0_7 mov rdi, qword ptr [rbp - 24] call __cxa_call_unexpected@PLT
.LBB0_3: mov eax, 4294966630 add rsp, 32 pop rbp ret mov rcx, rax mov eax, edx mov qword ptr [rbp - 24], rcx mov dword ptr [rbp - 28], eax cmp dword ptr [rbp - 28], 0 jge .LBB0_7 mov rdi, qword ptr [rbp - 24] call __cxa_call_unexpected@PLT
.LBB1_5: mov eax, dword ptr [rbp - 36] mov ecx, 2 cmp eax, ecx jne .LBB1_7 mov rdi, qword ptr [rbp - 16] call __cxa_begin_catch@PLT mov eax, dword ptr [rax] mov dword ptr [rbp - 24], eax mov dword ptr [rbp - 4], 42 call __cxa_end_catch@PLT jmp .LBB1_9
; ...
.LBB1_9: mov eax, dword ptr [rbp - 4] add rsp, 48 pop rbp ret
.LBB1_5: mov eax, dword ptr [rbp - 36] mov ecx, 2 cmp eax, ecx jne .LBB1_7 mov rdi, qword ptr [rbp - 16] call __cxa_begin_catch@PLT mov eax, dword ptr [rax] mov dword ptr [rbp - 24], eax mov dword ptr [rbp - 4], 42 call __cxa_end_catch@PLT jmp .LBB1_9
; ...
.LBB1_9: mov eax, dword ptr [rbp - 4] add rsp, 48 pop rbp ret
.LBB1_5: mov eax, dword ptr [rbp - 36] mov ecx, 2 cmp eax, ecx jne .LBB1_7 mov rdi, qword ptr [rbp - 16] call __cxa_begin_catch@PLT mov eax, dword ptr [rax] mov dword ptr [rbp - 24], eax mov dword ptr [rbp - 4], 42 call __cxa_end_catch@PLT jmp .LBB1_9
; ...
.LBB1_9: mov eax, dword ptr [rbp - 4] add rsp, 48 pop rbp ret
mov eax, dword ptr [rbp - 36] mov ecx, 2 cmp eax, ecx jne .LBB1_7
mov eax, dword ptr [rbp - 36] mov ecx, 2 cmp eax, ecx jne .LBB1_7
mov eax, dword ptr [rbp - 36] mov ecx, 2 cmp eax, ecx jne .LBB1_7 - .cfi_personality specifies the address of the exception handler (the personality routine) for the function;
- .cfi_lsda points to the Language Specific Data Area (LSDA)—function-specific metadata that tells the runtime how to handle an exception when it processes a particular stack frame.