c++ - Using GCC to find unreachable functions ("dead code") -
hey guys, looking way of finding statically unreachable functions in (very) big c++ project. had tried using doxygen , other static analysis tools suggested here seemed project complicated them handle. decided using gcc tools (g++, gprof, gcov, etc.) safest option, although couldn't figure out how it. think g++ optimizations eliminate statically unreachable functions i'm not sure how names of functions eliminates.
do have suggestions?
thanks!
dead code optimization typically done linker - compiler doesn't have overview. however, compiler might have eliminated unused static
functions (as have internal linkage).
therefore, shouldn't looking @ gcc options, @ ld options. seems want --print-gc-sections
. however, note want gcc put each function in own section, -ffunction-sections
. default gcc put functions in same section, , ld isn't smart enough eliminate unused functions - can eliminate unused sections.
Comments
Post a Comment