README 1.3 KB

1234567891011121314151617181920212223242526272829
  1. Elfhack is a program to optimize ELF binaries for size and cold startup
  2. speed.
  3. Presently, it is quite experimental, though it works well for the target
  4. it was created for: Firefox's libxul.so.
  5. Elfhack currently only does one thing: packing dynamic relocations ;
  6. which ends up being a quite complex task, that can be summarized this
  7. way:
  8. - Remove RELATIVE relocations from the .rel.dyn/.rela.dyn section.
  9. - Inject a small code able to apply relative relocations "by hand"
  10. after the .rel.dyn/.rela.dyn section.
  11. - Inject a section containing relocative relocations in a different
  12. and more packed format, after the small code.
  13. - Register the small code as DT_INIT function. Make the small code call
  14. what was initially the DT_INIT function, if there was one.
  15. - Remove the hole between the new section containing relative
  16. relocations and the following sections, adjusting offsets and base
  17. addresses accordingly.
  18. - Adjust PT_LOAD entries to fit new offsets, and add an additional
  19. PT_LOAD entry when that is necessary to handle the discrepancy between
  20. offsets and base addresses, meaning the section offsets may yet again
  21. need adjustments.
  22. - Adjust various DT_* dynamic tags to fit the new ELF layout.
  23. - Adjust section headers.
  24. - Adjust ELF headers.
  25. See http://glandium.org/blog/?p=1177#relocations for some figures.