• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..30-Mar-2022-

inject/H30-Mar-2022-5234

Makefile.inH A D30-Mar-20221.5 KiB4528

READMEH A D30-Mar-20221.3 KiB2925

dummy.cH A D30-Mar-2022317 82

elf.cppH A D30-Mar-202231.2 KiB936768

elfhack.cppH A D30-Mar-202254.6 KiB1,4311,077

elfxx.hH A D30-Mar-202219 KiB702564

inject.cH A D30-Mar-20225.1 KiB13796

moz.buildH A D30-Mar-2022816 3527

test-array.cH A D30-Mar-2022326 93

test-ctors.cH A D30-Mar-2022602 179

test.cH A D30-Mar-20224.2 KiB200165

README

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