How to turn off gcc compiler optimization to enable buffer overflow

后端 未结 6 681
野趣味
野趣味 2020-11-28 01:01

I\'m working on a homework problem that requires disabling compiler optimization protection for it to work. I\'m using gcc 4.4.1 on ubuntu linux, but can\'t figure out which

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 01:28

    I won't quote the entire page but the whole manual on optimisation is available here: http://gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/Optimize-Options.html#Optimize-Options

    From the sounds of it you want at least -O0, the default, and:

    -fmudflap -fmudflapth -fmudflapir

    For front-ends that support it (C and C++), instrument all risky pointer/array dereferencing operations, some standard library string/heap functions, and some other associated constructs with range/validity tests. Modules so instrumented should be immune to buffer overflows, invalid heap use, and some other classes of C/C++ programming errors. The instrumentation relies on a separate runtime library (libmudflap), which will be linked into a program if -fmudflap is given at link time. Run-time behavior of the instrumented program is controlled by the MUDFLAP_OPTIONS environment variable. See env MUDFLAP_OPTIONS=-help a.out for its options.

提交回复
热议问题