Problems with const static initializations
Unfortunately I spoke too soon about developing an airtight dead code finder. The technique of processing file scope variables I mentioned in my previous post has a serious drawback: it doesn’t work for const static data. This is a show stopper when it comes to peeking into most jump tables.
I’ve been able to print type information for all globals using the dehydra hooks placed into c-common.c however it seems like const initializations are not even handled at this level. I have my suspicions that there’s no way to recover the FUNCTION_DECL node in this case, likely because gcc has no use for the info at this level.
Although I may be able to make do by simply manually filtering as many callback functions as I can this approach is not quite ideal. I’ll have to think more about this but I’m now thinking that the lto streamer might be of use. There’s also the chance that there’s another way of using the cgraph to get at this data.
The other possibility is ditching gcc entirely and using elsa to dump the data. I’ll report back when I know more.
Sad! I was so excited about the previous blogpost. File a bug with gcc about it. Mention that we need that for a Mozilla static analysis and CC me and jason at redhat com. GCC devs have indicated that they are very interested in improving gcc for static analysis.