不需要。现在编译器基本都是基于异常表的异常处理,gcc是Itanium ABI,也是基于表的。
int main() {
try {
std::vector<char> buffer;
buffer.resize(10);
}catch(...) {
printf ("caught\n");
}
return 0;
}
上面这个poc的汇编代码:
0000000000401222 <main>:
401222: 55 push %rbp
401223: 48 89 e5 mov %rsp,%rbp
401226: 53 push %rbx
401227: 48 83 ec 28 sub $0x28,%rsp
40122b: 48 8d 45 d0 lea -0x30(%rbp),%rax
40122f: 48 89 c7 mov %rax,%rdi
401232: e8 bd 00 00 00 callq 4012f4 <std::vector<char, std::allocator<char> >::vector()>
401237: 48 8d 45 d0 lea -0x30(%rbp),%rax
40123b: be 0a 00 00 00 mov $0xa,%esi
401240: 48 89 c7 mov %rax,%rdi
401243: e8 0c 01 00 00 callq 401354 <std::vector<char, std::allocator<char> >::resize(unsigned long)>
401248: 48 8d 45 d0 lea -0x30(%rbp),%rax
40124c: 48 89 c7 mov %rax,%rdi
40124f: e8 bc 00 00 00 callq 401310 <std::vector<char, std::allocator<char> >::~vector()>
401254: b8 00 00 00 00 mov $0x0,%eax
401259: eb 3e jmp 401299 <main+0x77>
40125b: 48 89 c3 mov %rax,%rbx
40125e: 48 8d 45 d0 lea -0x30(%rbp),%rax
401262: 48 89 c7 mov %rax,%rdi
401265: e8 a6 00 00 00 callq 401310 <std::vector<char, std::allocator<char> >::~vector()>
40126a: 48 89 d8 mov %rbx,%rax
40126d: 48 89 c7 mov %rax,%rdi
401270: e8 db fd ff ff callq 401050 <__cxa_begin_catch@plt>
401275: bf 05 20 40 00 mov $0x402005,%edi
40127a: e8 51 fe ff ff callq 4010d0 <puts@plt>
40127f: e8 6c fe ff ff callq 4010f0 <__cxa_end_catch@plt>
401284: eb ce jmp 401254 <main+0x32>
401286: 48 89 c3 mov %rax,%rbx
401289: e8 62 fe ff ff callq 4010f0 <__cxa_end_catch@plt>
40128e: 48 89 d8 mov %rbx,%rax
401291: 48 89 c7 mov %rax,%rdi
401294: e8 87 fe ff ff callq 401120 <_Unwind_Resume@plt>
401299: 48 83 c4 28 add $0x28,%rsp
40129d: 5b pop %rbx
40129e: 5d pop %rbp
40129f: c3 retq
【 在 stub 的大作中提到: 】
: gcc进入try块需要建frame吧
--
修改:z16166 FROM 222.128.162.*
FROM 222.128.162.*