编译器会自动优化代码结构,对于不可到达的代码,编译器不会对其进行汇编,比如通过C写一个Crackme:
C++ 源代码:
#include <iostream>
using namespace std;
int main()
{
if (!(1 != 1) || 123 != 123)
{
cout << "ERROR" << endl;
exit(1);
}
cout << "okok" << endl;
}
虽然代码中体现了输出 okok
的语句,但实际上编译器并没有将其写入.out
文件:
IDA 反编译代码:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
std::__ostream_insert<char,std::char_traits<char>>(&std::cout, "ERROR", 5LL);
std::endl<char,std::char_traits<char>>(&std::cout);
exit(1);
}
参与讨论
(Participate in the discussion)
参与讨论