开了/EHa编译选项,并没有生成汇编级别的保护代码,为何?解决方法
开了/EHa编译选项,并没有生成汇编级别的保护代码,为何?
一个程序:
用VC2010的命令行编译:
D:\>cl /FAsc /EHa my.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
my.cpp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:my.exe
my.obj
发现.cod文件的内容如下,并没有让编译器生成SEH相关的保护代码。为什么呢?
------解决方案--------------------
最近出现过好几次这个问题
一个程序:
- C/C++ code
int main(void){ int i=1; return 0; }
用VC2010的命令行编译:
D:\>cl /FAsc /EHa my.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
my.cpp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:my.exe
my.obj
发现.cod文件的内容如下,并没有让编译器生成SEH相关的保护代码。为什么呢?
- Assembly code
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.30319.01 TITLE D:\my.cpp .686P .XMM include listing.inc .model flat INCLUDELIB LIBCMT INCLUDELIB OLDNAMES PUBLIC _main ; Function compile flags: /Odtp ; File d:\my.cpp _TEXT SEGMENT _i$ = -4 ; size = 4 _main PROC ; 1 : int main(void){ 00000 55 push ebp 00001 8b ec mov ebp, esp 00003 51 push ecx ; 2 : int i=1; 00004 c7 45 fc 01 00 00 00 mov DWORD PTR _i$[ebp], 1 ; 3 : return 0; 0000b 33 c0 xor eax, eax ; 4 : } 0000d 8b e5 mov esp, ebp 0000f 5d pop ebp 00010 c3 ret 0 _main ENDP _TEXT ENDS END
------解决方案--------------------
最近出现过好几次这个问题