DeadStrip Utility Documentation

Version 1.1

Frequently Asked Questions

  1. What's all this about?
    • DeadStrip is a tool designed to perform dependency analysis and dead function/data removal on MinGW/gcc generated object files.

  2. But doesn't the compiler do this already?
    • No. The compiler doesn't know enough about the global contexts an object file might be linked into to do a reasonable strip of unreferenced code and data. It does however perform local optimization, i.e. in each object file.

  3. Okay, what about the linker?
    • Yes, the linker would be able to do dependency analysis, because it's got a global view onto the data. There's even a command line switch that enables this sort of global optimization; unfortunately it doesn't work under Windows.

  4. What is 'dead code stripping' anyway?
    • Removing code from your executable file that can be proven not to be in use. This reduces the total size of your apps.

  5. Couldn't I just remove all the unused functions by commenting them out?
    • You could, of course. But you're likely to forget some dependencies on larger projects, resulting in loads of linker errors and many hours of fun. Just imagine a larger framework you'd like to include in your project. You use just one function, because you're too lazy to reinvent the wheel. The compiler won't complain and the linker will link a nice XXL executable, not only including the PNG-loader but also a whole database management system, to manage your images in C++. This is the gap DeadStrip aims to fill.

  6. Then DeadStrip is an alternative linker?
    • No. You still use whatever linker you like to use. DeadStrip only hooks into the compiler-linker toolchain and analyses the object files before the linker sees them, removing all unused sections. When it's done, it calls the linker.

  7. Aren't there any other tools, that do the same already?
    • I've searched about one month for some tool like this, reading nearly every newsgroup entry containing the word GCC (there's a lot of them, trust me) and all I found, was some alternative linker contained in a large compiler-IDE framework that said it could do what I wanted. The final executable was larger than before when I was still linking using ld. Additionally ld has much more options when it comes down to fine tuning. So I decided to write that tool myself and still be able to use my favourite linker.

  8. I'm missing feature XY.
    • Then you've got a couple of options. If this feature is of major importance to you and you're not able to write it for yourself, ask me. If I like the idea, I might be implementing it and provide an update.
      But more reliable than me, is you. If you're able to write it for yourself, either by attaching another tool to the output of DeadStrip, or by contributing to the tools code, feel free to do so. DeadStrip provides XML-like output of various computed information and comes with full platform independent C source code. I would be happy to hear from you in those cases. Although I strictly encourage you to contribute to the source, please don't provide links on your site to your modified version saying that this is the "official" one (that is, my one). You can, however, modify your own version and present it as a modification from you. Credits aren't necessary.

  9. I found a bug.
    • Mail me with a detailed description of the error and provide some source code, if necessary, or try to fix it yourself and mail me afterwards :). My e-mail address is weber ät informatik.hu-berlin.de.

Syntax

 deadstrip [Options] file...
   Options:
     --help                display this help
     --dcmd                dumps the command line
     --ddis                dumps discarted sections
     --duse                dumps used sections
     --dmap                dump the dependency map
     --linker <filename>   use alternative linker (default: ld)
     --dnrm                do not remove any sections
     --save <item>         save an item and its dependencies
       > just pass the decorated variable/function name, not the section
       > the main function gets saved by default
 

Additional Notes

Installation

Just drop the executable into the directory of your binutils, then configure your IDE or makefile to call DeadStrip instead of the linker, but provide the original linker using the --linker-switch. Finally enable -ffunction-sections and/or -fdata-sections in your compiler for your release builds.

Downloads

Example output

Program related

Version History

Version 1.1

Version 1.0


Generated on Fri Jun 5 15:31:57 2009 for DeadStrip Utility by  doxygen 1.5.8