OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This is the transformation and adjustment for all executables. | 5 // This is the transformation and adjustment for all executables. |
6 // The executable type is determined by ParseDetectedExecutable function. | 6 // The executable type is determined by ParseDetectedExecutable function. |
7 | 7 |
8 #ifndef COURGETTE_WIN32_X86_GENERATOR_H_ | 8 #ifndef COURGETTE_PATCH_GENERATOR_X86_32_H_ |
9 #define COURGETTE_WIN32_X86_GENERATOR_H_ | 9 #define COURGETTE_PATCH_GENERATOR_X86_32_H_ |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "courgette/assembly_program.h" | 15 #include "courgette/assembly_program.h" |
16 #include "courgette/ensemble.h" | 16 #include "courgette/ensemble.h" |
17 #include "courgette/patcher_x86_32.h" | 17 #include "courgette/patcher_x86_32.h" |
18 #include "courgette/program_detector.h" | 18 #include "courgette/program_detector.h" |
19 | 19 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 Status Transform(SourceStreamSet* corrected_parameters, | 58 Status Transform(SourceStreamSet* corrected_parameters, |
59 SinkStreamSet* old_transformed_element, | 59 SinkStreamSet* old_transformed_element, |
60 SinkStreamSet* new_transformed_element) { | 60 SinkStreamSet* new_transformed_element) { |
61 // Don't expect any corrected parameters. | 61 // Don't expect any corrected parameters. |
62 if (!corrected_parameters->Empty()) | 62 if (!corrected_parameters->Empty()) |
63 return C_GENERAL_ERROR; | 63 return C_GENERAL_ERROR; |
64 | 64 |
65 // Generate old version of program using |corrected_parameters|. | 65 // Generate old version of program using |corrected_parameters|. |
66 // TODO(sra): refactor to use same code from patcher_. | 66 // TODO(sra): refactor to use same code from patcher_. |
67 std::unique_ptr<AssemblyProgram> old_program; | 67 std::unique_ptr<AssemblyProgram> old_program; |
68 Status old_parse_status = | 68 Status old_parse_status = ParseDetectedExecutableWithAnnotation( |
69 ParseDetectedExecutable(old_element_->region().start(), | 69 old_element_->region().start(), old_element_->region().length(), |
70 old_element_->region().length(), | 70 &old_program); |
71 &old_program); | |
72 if (old_parse_status != C_OK) { | 71 if (old_parse_status != C_OK) { |
73 LOG(ERROR) << "Cannot parse an executable " << old_element_->Name(); | 72 LOG(ERROR) << "Cannot parse an executable " << old_element_->Name(); |
74 return old_parse_status; | 73 return old_parse_status; |
75 } | 74 } |
76 | 75 |
77 // TODO(huangs): Move the block below to right before |new_program| gets | 76 // TODO(huangs): Move the block below to right before |new_program| gets |
78 // used, so we can reduce Courgette-gen peak memory. | 77 // used, so we can reduce Courgette-gen peak memory. |
79 std::unique_ptr<AssemblyProgram> new_program; | 78 std::unique_ptr<AssemblyProgram> new_program; |
80 Status new_parse_status = | 79 Status new_parse_status = ParseDetectedExecutableWithAnnotation( |
81 ParseDetectedExecutable(new_element_->region().start(), | 80 new_element_->region().start(), new_element_->region().length(), |
82 new_element_->region().length(), | 81 &new_program); |
83 &new_program); | |
84 if (new_parse_status != C_OK) { | 82 if (new_parse_status != C_OK) { |
85 LOG(ERROR) << "Cannot parse an executable " << new_element_->Name(); | 83 LOG(ERROR) << "Cannot parse an executable " << new_element_->Name(); |
86 return new_parse_status; | 84 return new_parse_status; |
87 } | 85 } |
88 | 86 |
89 std::unique_ptr<EncodedProgram> old_encoded; | 87 std::unique_ptr<EncodedProgram> old_encoded; |
90 Status old_encode_status = Encode(*old_program, &old_encoded); | 88 Status old_encode_status = Encode(*old_program, &old_encoded); |
91 if (old_encode_status != C_OK) | 89 if (old_encode_status != C_OK) |
92 return old_encode_status; | 90 return old_encode_status; |
93 | 91 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 private: | 123 private: |
126 virtual ~PatchGeneratorX86_32() { } | 124 virtual ~PatchGeneratorX86_32() { } |
127 | 125 |
128 ExecutableType kind_; | 126 ExecutableType kind_; |
129 | 127 |
130 DISALLOW_COPY_AND_ASSIGN(PatchGeneratorX86_32); | 128 DISALLOW_COPY_AND_ASSIGN(PatchGeneratorX86_32); |
131 }; | 129 }; |
132 | 130 |
133 } // namespace courgette | 131 } // namespace courgette |
134 | 132 |
135 #endif // COURGETTE_WIN32_X86_GENERATOR_H_ | 133 #endif // COURGETTE_PATCH_GENERATOR_X86_32_H_ |
OLD | NEW |