I have written some code that I expected to be dead-stripped, but is
actually being output into my final app. It's for a utility library;
some clients want to use a small subset of the library, and I've
written it so that the pieces ought to stand alone, but it seems that
the linker doesn't want to dead-strip enough of it. Making matters
worse, the actual dead-stripping behavior seems to vary on a project-
by-project basis; some apps I've written dead-strip fine, while
others won't.
I've actually tried modifying the app so that it won't reference my
library at all; I did a search-and-replace for all the function names
in the code and commented them out. Even still, in some apps, the
linker was unable to do the dead-stripping. At that point it seems
like it would have to be a linker bug, but I'm not really versed in
the ways of GCC yet, and some of its "normal" behaviors still seem a
little screwy to me. I have experimented with the target settings
repeatedly; I think I've tried almost every permutation of options
that seemed remotely promising.
Is there any way to ask the linker "what references function X? why
did it get included in the final output?"