summaryrefslogtreecommitdiffstats
path: root/courgette/disassembler_win32_x86.cc
Commit message (Collapse)AuthorAgeFilesLines
* [Courgette] Add and use AddressTranslator::PointerToTargetRVA(); Update ↵huangs2016-03-231-20/+28
| | | | | | | | | | | | | | | | | | | comments. Addresses in Courgette (abs32 and rel32) are represented in these forms: (1) Location RVA. (2) Location FileOffset. (3) Pointer in image. (4) Target VA. (5) Target RVA. We already have (1) -> (2), (2) -> (1), (2) -> (3), (1) -> (3) for existing usage. Now we add (3) -> (5) and refactor accordingly (with helpers to do (4) -> (5) for PE files). PointerToTargetRVA() will be used again we apply LabelManager to save 25% peak RAM. Review URL: https://codereview.chromium.org/1807293003 Cr-Commit-Position: refs/heads/master@{#382920}
* [Courgette] Clean up Disassembler; fix ELF Memory leaks.huangs2016-03-141-109/+108
| | | | | | | | | | | | | | | | | | | | | Cleaning up code surrounding Disassembler: - Extract AddressTranslator interface to be used across subclasses. - Use FileOffset = size_t by context. - Detailed comments & TODOs in DisassemblerElf32ARM. - Fix DisassemblerElf32ARM memory leaks. - Lots of superficial stylistic changes. Except for AddressTranslator routines and unit tests, shying away from control flow and logic changes. BUG=579206 Committed: https://crrev.com/58b822d441f5c982e879e536fa3c1cbac8fd339a Cr-Commit-Position: refs/heads/master@{#380881} Review URL: https://codereview.chromium.org/1676683002 Cr-Commit-Position: refs/heads/master@{#380987}
* Revert of [Courgette] Clean up Disassembler; fix ELF Memory leaks. (patchset ↵scottmg2016-03-121-105/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #15 id:270001 of https://codereview.chromium.org/1676683002/ ) Reason for revert: Regressed linux sizes (iostream maybe?) https://build.chromium.org/p/chromium/builders/Linux/builds/72899/steps/sizes/logs/stdio Original issue's description: > [Courgette] Clean up Disassembler; fix ELF Memory leaks. > > Cleaning up code surrounding Disassembler: > - Extract AddressTranslator interface to be used across subclasses. > - Use FileOffset = size_t by context. > - Detailed comments & TODOs in DisassemblerElf32ARM. > - Fix DisassemblerElf32ARM memory leaks. > - Lots of superficial stylistic changes. > > Except for AddressTranslator routines and unit tests, shying away > from control flow and logic changes. > > BUG=579206 > > Committed: https://crrev.com/58b822d441f5c982e879e536fa3c1cbac8fd339a > Cr-Commit-Position: refs/heads/master@{#380881} TBR=grt@chromium.org,wfh@chromium.org,chrisha@chromium.org,andrewhayden@chromium.org,huangs@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=579206 Review URL: https://codereview.chromium.org/1792603006 Cr-Commit-Position: refs/heads/master@{#380885}
* [Courgette] Clean up Disassembler; fix ELF Memory leaks.huangs2016-03-121-109/+105
| | | | | | | | | | | | | | | | | | Cleaning up code surrounding Disassembler: - Extract AddressTranslator interface to be used across subclasses. - Use FileOffset = size_t by context. - Detailed comments & TODOs in DisassemblerElf32ARM. - Fix DisassemblerElf32ARM memory leaks. - Lots of superficial stylistic changes. Except for AddressTranslator routines and unit tests, shying away from control flow and logic changes. BUG=579206 Review URL: https://codereview.chromium.org/1676683002 Cr-Commit-Position: refs/heads/master@{#380881}
* [Courgette] Simplify EncodedProgram Label addition code; removed "1.01 x" ↵huangs2016-01-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | memory fix. This CL simplifies how Labels get flattened to a list of RVAs. In the past EncodedProgram used DefineAbs32Label() / DefineRel32Label(), which let callers add one Label at a time. Complexity arose from: - Function pointer usage to avoid duplicate code for abs32 and rel32. - Need for EncodedProgram to dynamically adjust size of RVA list. This led to inefficient array resizing, which was fixed by the "1.01 x" memory growth. Change: We now pass the collection of abs32 and rel32 Labels to EncodedProgram. This simplifies the interface, and allows EncodedProgram to find the max indexes and preallocated buffers. The trade-off is increased test code complexity, since we'd need to create Label collection. Other changes: - Update namespace{} for EncodedProgram and its tests. - Add more Label constructors (for testing). - Add LabelManager::GetIndexBound(), for LabelVector and RVAToLabel. - Add kUnassignedRVA in image_utils.h, with checks for its absence in images. Review URL: https://codereview.chromium.org/1571913003 Cr-Commit-Position: refs/heads/master@{#370200}
* Switch to standard integer types in courgette/.avi2015-12-211-45/+47
| | | | | | | | | | BUG=138542 TBR=wfh@chromium.org NOPRESUBMIT=true Review URL: https://codereview.chromium.org/1543643002 Cr-Commit-Position: refs/heads/master@{#366439}
* [Courgette] Refactor: Adding Rel32FinderWin32X86_Basic and Unittestshuangs2015-09-181-67/+9
| | | | | | | | | | | | | | | | We're planning to improve heuristic to find Rel32 addresses for Win32 x86. First refactor by by extraacting the feature into its own class. This also lead to the extraction of RVA and various helpers from disassembler.h to image_utils.h. Also adding unittests for Rel32FinderWin32X86_Basic. The test is data-driven by adding a simple parser for test data. BUG= Review URL: https://codereview.chromium.org/1344173003 Cr-Commit-Position: refs/heads/master@{#349727}
* Courgette: Remove 2 duplicates calls to std::sort.sebmarchand2015-08-111-2/+0
| | | | | | | | | | There's already a call to std::sort at the end of ParseRelocs. It's a small improvement, but it's still better than nothing :) BUG= Review URL: https://codereview.chromium.org/1284733002 Cr-Commit-Position: refs/heads/master@{#342865}
* Courgette: Skip the relocs that live outside of the image.sebmarchand2015-08-071-0/+8
| | | | | | | | BUG=517475 Review URL: https://codereview.chromium.org/1277583004 Cr-Commit-Position: refs/heads/master@{#342241}
* Make ParseNonSectionFileRegion a bit simplier and faster.halyavin2015-03-121-8/+4
| | | | | | | | | | TEST=courgette_unittests BUG= none R=wfh@chromium.org Review URL: https://codereview.chromium.org/998443002 Cr-Commit-Position: refs/heads/master@{#320252}
* Add PE64 support to courgettewfh@chromium.org2013-09-251-5/+1
| | | | | | | | | | | Add tests for PE64 BUG=38784 NOTRY=true Review URL: https://chromiumcodereview.appspot.com/23600063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225224 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 224789 "Add PE64 support to courgette"piman@chromium.org2013-09-231-1/+5
| | | | | | | | | | | | | | | | | | Caused failures: http://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/23037/steps/courgette_unittests/logs/stdio > Add PE64 support to courgette > > Add tests for PE64 > > BUG=38784 > > Review URL: https://chromiumcodereview.appspot.com/23600063 TBR=wfh@chromium.org Review URL: https://codereview.chromium.org/23591065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224806 0039d316-1c4b-4281-b951-d872f2087c98
* Add PE64 support to courgettewfh@chromium.org2013-09-231-5/+1
| | | | | | | | | | Add tests for PE64 BUG=38784 Review URL: https://chromiumcodereview.appspot.com/23600063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224789 0039d316-1c4b-4281-b951-d872f2087c98
* Fix two pointer arithmetic errors.dgarrett@chromium.org2011-11-091-3/+3
| | | | | | | | | | | | | In the heuristic for detecting relative references, we had two non-fatal, but sub-optimal mistakes with pointer arithmetic. This fixes them for both ELF 32 and Win 32. BUG=chromiumos:22677 Review URL: http://codereview.chromium.org/8501023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109172 0039d316-1c4b-4281-b951-d872f2087c98
* Replace "bool ok" style with early returns.dgarrett@chromium.org2011-11-091-25/+26
| | | | | | | | | | | | | | | Stephen pointed out that he doesn't like the "bool ok" style and prefers the early return style during an earlier code review. I agree, but was using this style to match existing code. This CL switches a number of methods over to the early return style. BUG=None Review URL: http://codereview.chromium.org/8499034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109137 0039d316-1c4b-4281-b951-d872f2087c98
* Add Elf 32 Support to Courgette.dgarrett@chromium.org2011-11-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This change takes advantage of recent refactoring and adds support for Elf X86 32 executables to courgette. It should have no effect on handling of Windows PE executables. We have planned ahead to be able to restrict the code size of the courgette library in different cases to reduce patcher sizes, but this change does not yet take advantage of that (all platforms are supported everywhere). Also, the patcher class currently contains a very small amount of Elf/PE specific code for recreating relocation tables that cannot (currently) be compiled out. BUG=chromium-os:22149 TEST=Please verify that Chrome/Chromium patches can still be generated and work. Also, please see how much the updater executable which is downloaded to users has changed in size since R16. Review URL: http://codereview.chromium.org/8477045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109089 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 108929 - Add Elf 32 Support to Courgette.csilv@chromium.org2011-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This change takes advantage of recent refactoring and adds support for Elf X86 32 executables to courgette. It should have no effect on handling of Windows PE executables. We have planned ahead to be able to restrict the code size of the courgette library in different cases to reduce patcher sizes, but this change does not yet take advantage of that (all platforms are supported everywhere). Also, the patcher class currently contains a very small amount of Elf/PE specific code for recreating relocation tables that cannot (currently) be compiled out. BUG=chromium-os:22149 TEST=Please verify that Chrome/Chromium patches can still be generated and work. Also, please see how much the updater executable which is downloaded to users has changed in size since R16. Review URL: http://codereview.chromium.org/8428009 TBR=dgarrett@chromium.org Review URL: http://codereview.chromium.org/8490023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108934 0039d316-1c4b-4281-b951-d872f2087c98
* Add Elf 32 Support to Courgette.dgarrett@chromium.org2011-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This change takes advantage of recent refactoring and adds support for Elf X86 32 executables to courgette. It should have no effect on handling of Windows PE executables. We have planned ahead to be able to restrict the code size of the courgette library in different cases to reduce patcher sizes, but this change does not yet take advantage of that (all platforms are supported everywhere). Also, the patcher class currently contains a very small amount of Elf/PE specific code for recreating relocation tables that cannot (currently) be compiled out. BUG=chromium-os:22149 TEST=Please verify that Chrome/Chromium patches can still be generated and work. Also, please see how much the updater executable which is downloaded to users has changed in size since R16. Review URL: http://codereview.chromium.org/8428009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108929 0039d316-1c4b-4281-b951-d872f2087c98
* Further refactoring, move ImageInfo into Disassembler/DisassemblerWin32X86.dgarrett@chromium.org2011-10-261-61/+419
| | | | | | | | | | | | | | | | This means that all PE specific knowledge is now contained in a single class which leaves us in pretty good shape for supporting ELF 32. There are still widespread assumptions about being 32 bit, but those can be addressed at a much later date. BUG=None TEST=Unittests Review URL: http://codereview.chromium.org/8166013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107260 0039d316-1c4b-4281-b951-d872f2087c98
* Start refactoring to reduce executable type knowledge.dgarrett@chromium.org2011-10-211-0/+377
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This creates executable detection functions, a globally shared enum for describing an executable type, and reduces the number of classes and locations with executable specific knowledge. These changes, along with moving architecture specific classes into their own files should make it easier to produce special purpose clients that only contain the code required to apply their own form of patch. DisassemblerWin32EXE, ImagePE, CourgetteWin32X86PatchGenerator, and CourgetteWin32X86Patcher, and ensemble handling are all heavily affected here. This should have no effect on the behavior of the system yet, and is instead all prep-work. This is the same as an earlier CL, except that ParseHeader will now return an error for 64 bit PE executables, and resource only DLLs. This is because the detection factories depend on ParseHeader to decide if a given file is supported. BUG=None TEST=Unittests Review URL: http://codereview.chromium.org/7920004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103879 0039d316-1c4b-4281-b951-d872f2087c98 Review URL: http://codereview.chromium.org/8344037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106793 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 103879 - Start refactoring to reduce executable type knowledge.laforge@chromium.org2011-10-111-377/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | This creates executable detection functions, a globally shared enum for describing an executable type, and reduces the number of classes and locations with executable specific knowledge. These changes, along with moving architecture specific classes into their own files should make it easier to produce special purpose clients that only contain the code required to apply their own form of patch. DisassemblerWin32EXE, ImagePE, CourgetteWin32X86PatchGenerator, and CourgetteWin32X86Patcher, and ensemble handling are all heavily affected here. This should have no effect on the behavior of the system yet, and is instead all prep-work. BUG=None TEST=Unittests Review URL: http://codereview.chromium.org/7920004 TBR=dgarrett@chromium.org Review URL: http://codereview.chromium.org/8234012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104926 0039d316-1c4b-4281-b951-d872f2087c98
* Start refactoring to reduce executable type knowledge.dgarrett@chromium.org2011-10-041-0/+377
This creates executable detection functions, a globally shared enum for describing an executable type, and reduces the number of classes and locations with executable specific knowledge. These changes, along with moving architecture specific classes into their own files should make it easier to produce special purpose clients that only contain the code required to apply their own form of patch. DisassemblerWin32EXE, ImagePE, CourgetteWin32X86PatchGenerator, and CourgetteWin32X86Patcher, and ensemble handling are all heavily affected here. This should have no effect on the behavior of the system yet, and is instead all prep-work. BUG=None TEST=Unittests Review URL: http://codereview.chromium.org/7920004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103879 0039d316-1c4b-4281-b951-d872f2087c98