1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/build/unix/elfhack/README Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,28 @@ 1.4 +Elfhack is a program to optimize ELF binaries for size and cold startup 1.5 +speed. 1.6 + 1.7 +Presently, it is quite experimental, though it works well for the target 1.8 +it was created for: Firefox's libxul.so. 1.9 + 1.10 +Elfhack currently only does one thing: packing dynamic relocations ; 1.11 +which ends up being a quite complex task, that can be summarized this 1.12 +way: 1.13 +- Remove RELATIVE relocations from the .rel.dyn/.rela.dyn section. 1.14 +- Inject a small code able to apply relative relocations "by hand" 1.15 + after the .rel.dyn/.rela.dyn section. 1.16 +- Inject a section containing relocative relocations in a different 1.17 + and more packed format, after the small code. 1.18 +- Register the small code as DT_INIT function. Make the small code call 1.19 + what was initially the DT_INIT function, if there was one. 1.20 +- Remove the hole between the new section containing relative 1.21 + relocations and the following sections, adjusting offsets and base 1.22 + addresses accordingly. 1.23 +- Adjust PT_LOAD entries to fit new offsets, and add an additional 1.24 + PT_LOAD entry when that is necessary to handle the discrepancy between 1.25 + offsets and base addresses, meaning the section offsets may yet again 1.26 + need adjustments. 1.27 +- Adjust various DT_* dynamic tags to fit the new ELF layout. 1.28 +- Adjust section headers. 1.29 +- Adjust ELF headers. 1.30 + 1.31 +See http://glandium.org/blog/?p=1177#relocations for some figures.