build/unix/elfhack/README

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial