• wfh's avatar
    Add support for RIP relative addresses on x86_64. · 4f4f19d7
    wfh authored
    Visual studio uses rip-relative addressing (rra) extensively in 64 bit binaries. ParseRel32RelocsFromSection does not find these addresses, which causes courgette to miss a lot of rva pointers, and thus missing a lot of compresssion opportunities.
    
    This patch makes the ParseRel32RelocsFromSection find rip relative call/jmp/lea. It also finds mov's that load from memory using rra's.
    
    Based on CL by niels.werensteijn.teamspeak@gmail.com in crrev.com/212563003
    
    This change gives a noticeable improvement on 64-bit binaries. Against test binaries (64-bit chrome.dll 40.0.2214.115->43.0.2317.0) the patch sizes were:
    
    Uncompressed:
    before: 10,948,152
    after: 9,948,442 (9.1% reduction)
    
    Compressed (7z ultra):
    before: 6,084,670
    after: 5,581,502 (8.3% reduction)
    
    BUG=459064
    TEST=courgette_unittests
    
    Review URL: https://codereview.chromium.org/878043002
    
    Cr-Commit-Position: refs/heads/master@{#321524}
    4f4f19d7
encode_decode_unittest.cc 2.8 KB