[pisa] unused code in C programs

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: hipl-dev@xxxxxxxxxxxxx, pisa@xxxxxxxxxxxxx
  • Date: Tue, 29 Mar 2011 17:39:16 +0200

We've discussed this before, so I thought it is worth sharing:

Locating unused functions in C programs is simple if the functions
are static; gcc complains about them.  For non-static functions,
however, it is entirely nontrivial.  Since the compiler compiles
file-by-file it cannot tell us if an exported symbol is really
used outside of a file or not.

Enter Ruby-Elf, a library and set of tools to analyze ELF object files
written by my friend Diego Petteno aka Flameeyes:

http://www.flameeyes.eu/projects/ruby-elf

It contains the program `missingstatic´, which prints out the list of
exported symbols for a given object file.

With the help of this program and a bit of shell scripting I have found
some unused code in HIPL.  I will propose a branch with that code
removed for merging in a moment, which will address bug 592206.


On a (related) side note: Flameeyes has previously helped me a lot with
rewriting the autotools build systems for HIPL and PISA, both by being
the author of the excellent and free Autotools Mythbuster documentation
and by assisting me directly on many occasions with questions on IRC and
by doing a full review of Makefile.am and configure.ac.

I have already expressed my gratitude through Flattr[1], but if we have
the means to do it as a project or through the university, maybe we could
give a token of appreciation to Flameeyes directly:

http://www.flameeyes.eu/donations

Note that I'm not thinking of anything big here, but something like a book
gift certificate or similar could go a long way.

just a thought, Diego

[1] http://flattr.com/
-- 
This is the main pisa mailing list. Please also subscribe to the pisa-dev list 
at:
//www.freelists.org/list/pisa-src

Other related posts:

  • » [pisa] unused code in C programs - Diego Biurrun