Can I see what is eliminated by the Visual C ++ / OPT: REF option?

Option /OPT:REF

causes the linker to Visual C ++

Exclude functions and / or data that are never referenced

( MSDN )

This seems to be a good way to identify legacy code in a legacy codebase. Is there a way to get the linker to output what is fixed?

+2


source to share


2 answers


The / OPT (Optimization) in the Notes section states:

You can use the VERBOSE option to see functions removed with / OPT: REF and functions folded with / OPT: ICF.



I haven't tried using it for your purposes yet.

Alternatively, you can refer to SO Question 641826 to exclude compiler generated characters if you take the route given by @JamesMcNellis' answer .

+5


source


It's not perfect, but ...

You can make two assemblies, one with /OPT:REF

and one without, then run dumpbin /symbols

on the resulting binaries, parse the symbols, and strip the results. The trick will weed out the library symbols, so you're left with just symbols. Since you will have a list of mutilated names, it won't be pretty.



I don't know how to get the linker to just tell you what it is deleting.

+2


source







All Articles