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 #ifndef COURGETTE_DISASSEMBLER_H_ | 5 #ifndef COURGETTE_DISASSEMBLER_H_ |
6 #define COURGETTE_DISASSEMBLER_H_ | 6 #define COURGETTE_DISASSEMBLER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // because we may remove rel32 Labels along the way. As a result the matching | 84 // because we may remove rel32 Labels along the way. As a result the matching |
85 // rel32 addresses become unused. Removing them saves space. | 85 // rel32 addresses become unused. Removing them saves space. |
86 virtual void RemoveUnusedRel32Locations(AssemblyProgram* program) = 0; | 86 virtual void RemoveUnusedRel32Locations(AssemblyProgram* program) = 0; |
87 | 87 |
88 // Extracts structural data from the main image. Returns true if the image | 88 // Extracts structural data from the main image. Returns true if the image |
89 // appears to be a valid executable of the expected type, or false otherwise. | 89 // appears to be a valid executable of the expected type, or false otherwise. |
90 // This needs to be called before Disassemble(). | 90 // This needs to be called before Disassemble(). |
91 virtual bool ParseHeader() = 0; | 91 virtual bool ParseHeader() = 0; |
92 | 92 |
93 // Extracts and stores references from the main image. Returns a new | 93 // Extracts and stores references from the main image. Returns a new |
94 // AssemblyProgram initialized using data parsed from the main image, or null | 94 // AssemblyProgram initialized using data parsed from the main image and |
95 // on failure. | 95 // |annotate_labels|, or null on failure. |
96 std::unique_ptr<AssemblyProgram> Disassemble(); | 96 std::unique_ptr<AssemblyProgram> Disassemble(bool annotate_labels); |
97 | 97 |
98 // ok() may always be called but returns true only after ParseHeader() | 98 // ok() may always be called but returns true only after ParseHeader() |
99 // succeeds. | 99 // succeeds. |
100 bool ok() const { return failure_reason_ == nullptr; } | 100 bool ok() const { return failure_reason_ == nullptr; } |
101 | 101 |
102 // Returns the length of the image. May reduce after ParseHeader(). | 102 // Returns the length of the image. May reduce after ParseHeader(). |
103 size_t length() const { return length_; } | 103 size_t length() const { return length_; } |
104 const uint8_t* start() const { return start_; } | 104 const uint8_t* start() const { return start_; } |
105 const uint8_t* end() const { return end_; } | 105 const uint8_t* end() const { return end_; } |
106 | 106 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 size_t length_; // In current memory. | 138 size_t length_; // In current memory. |
139 const uint8_t* start_; // In current memory, base for 'file offsets'. | 139 const uint8_t* start_; // In current memory, base for 'file offsets'. |
140 const uint8_t* end_; // In current memory. | 140 const uint8_t* end_; // In current memory. |
141 | 141 |
142 DISALLOW_COPY_AND_ASSIGN(Disassembler); | 142 DISALLOW_COPY_AND_ASSIGN(Disassembler); |
143 }; | 143 }; |
144 | 144 |
145 } // namespace courgette | 145 } // namespace courgette |
146 | 146 |
147 #endif // COURGETTE_DISASSEMBLER_H_ | 147 #endif // COURGETTE_DISASSEMBLER_H_ |
OLD | NEW |