Add support for RIP relative addresses on x86_64.
commit4f4f19d78bb91ba7af7e79f86b75d1f67aa1caf6
authorwfh <wfh@chromium.org>
Fri, 20 Mar 2015 06:23:11 +0000 (19 23:23 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 20 Mar 2015 06:24:31 +0000 (20 06:24 +0000)
tree6a21109fa79aac851d93ed0333dafaec6f7bad12
parent870abc95c02e4ac0ae3f14ed4d4178be4ec2f98e
Add support for RIP relative addresses on x86_64.

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}
AUTHORS
courgette/disassembler_win32_x64.cc
courgette/encode_decode_unittest.cc