| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_ELF_32_H_ | 5 #ifndef COURGETTE_DISASSEMBLER_ELF_32_H_ |
| 6 #define COURGETTE_DISASSEMBLER_ELF_32_H_ | 6 #define COURGETTE_DISASSEMBLER_ELF_32_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 // Parsing code for Disassemble(). | 173 // Parsing code for Disassemble(). |
| 174 | 174 |
| 175 virtual CheckBool ParseRelocationSection(const Elf32_Shdr* section_header, | 175 virtual CheckBool ParseRelocationSection(const Elf32_Shdr* section_header, |
| 176 InstructionReceptor* receptor) const | 176 InstructionReceptor* receptor) const |
| 177 WARN_UNUSED_RESULT = 0; | 177 WARN_UNUSED_RESULT = 0; |
| 178 | 178 |
| 179 virtual CheckBool ParseRel32RelocsFromSection(const Elf32_Shdr* section) | 179 virtual CheckBool ParseRel32RelocsFromSection(const Elf32_Shdr* section) |
| 180 WARN_UNUSED_RESULT = 0; | 180 WARN_UNUSED_RESULT = 0; |
| 181 | 181 |
| 182 CheckBool ParseAbs32Relocs() WARN_UNUSED_RESULT; |
| 183 |
| 184 // Extracts all rel32 TypedRVAs. Does not sort the result. |
| 185 CheckBool ParseRel32RelocsFromSections() WARN_UNUSED_RESULT; |
| 186 |
| 182 // Disassembler interfaces. | 187 // Disassembler interfaces. |
| 183 RvaVisitor* CreateAbs32TargetRvaVisitor() override; | 188 RvaVisitor* CreateAbs32TargetRvaVisitor() override; |
| 184 RvaVisitor* CreateRel32TargetRvaVisitor() override; | 189 RvaVisitor* CreateRel32TargetRvaVisitor() override; |
| 185 void RemoveUnusedRel32Locations(AssemblyProgram* program) override; | 190 void RemoveUnusedRel32Locations(AssemblyProgram* program) override; |
| 186 | 191 |
| 187 CheckBool ParseFile(AssemblyProgram* target, | 192 CheckBool ParseFile(AssemblyProgram* target, |
| 188 InstructionReceptor* receptor) const WARN_UNUSED_RESULT; | 193 InstructionReceptor* receptor) const WARN_UNUSED_RESULT; |
| 189 | 194 |
| 190 CheckBool ParseProgbitsSection( | 195 CheckBool ParseProgbitsSection( |
| 191 const Elf32_Shdr* section_header, | 196 const Elf32_Shdr* section_header, |
| 192 std::vector<FileOffset>::iterator* current_abs_offset, | 197 std::vector<FileOffset>::iterator* current_abs_offset, |
| 193 std::vector<FileOffset>::iterator end_abs_offset, | 198 std::vector<FileOffset>::iterator end_abs_offset, |
| 194 std::vector<std::unique_ptr<TypedRVA>>::iterator* current_rel, | 199 std::vector<std::unique_ptr<TypedRVA>>::iterator* current_rel, |
| 195 std::vector<std::unique_ptr<TypedRVA>>::iterator end_rel, | 200 std::vector<std::unique_ptr<TypedRVA>>::iterator end_rel, |
| 196 AssemblyProgram* program, | 201 AssemblyProgram* program, |
| 197 InstructionReceptor* receptor) const WARN_UNUSED_RESULT; | 202 InstructionReceptor* receptor) const WARN_UNUSED_RESULT; |
| 198 | 203 |
| 199 CheckBool ParseSimpleRegion(FileOffset start_file_offset, | 204 CheckBool ParseSimpleRegion(FileOffset start_file_offset, |
| 200 FileOffset end_file_offset, | 205 FileOffset end_file_offset, |
| 201 InstructionReceptor* receptor) const | 206 InstructionReceptor* receptor) const |
| 202 WARN_UNUSED_RESULT; | 207 WARN_UNUSED_RESULT; |
| 203 | 208 |
| 204 CheckBool ParseAbs32Relocs() WARN_UNUSED_RESULT; | |
| 205 | |
| 206 CheckBool CheckSection(RVA rva) WARN_UNUSED_RESULT; | 209 CheckBool CheckSection(RVA rva) WARN_UNUSED_RESULT; |
| 207 | 210 |
| 208 // Extracts all rel32 TypedRVAs. Does not sort the result. | |
| 209 CheckBool ParseRel32RelocsFromSections() WARN_UNUSED_RESULT; | |
| 210 | |
| 211 const Elf32_Ehdr* header_; | 211 const Elf32_Ehdr* header_; |
| 212 | 212 |
| 213 Elf32_Half section_header_table_size_; | 213 Elf32_Half section_header_table_size_; |
| 214 | 214 |
| 215 // Section header table, ordered by section id. | 215 // Section header table, ordered by section id. |
| 216 std::vector<Elf32_Shdr> section_header_table_; | 216 std::vector<Elf32_Shdr> section_header_table_; |
| 217 | 217 |
| 218 // An ordering of |section_header_table_|, sorted by file offset. | 218 // An ordering of |section_header_table_|, sorted by file offset. |
| 219 std::vector<Elf32_Half> section_header_file_offset_order_; | 219 std::vector<Elf32_Half> section_header_file_offset_order_; |
| 220 | 220 |
| 221 const Elf32_Phdr* program_header_table_; | 221 const Elf32_Phdr* program_header_table_; |
| 222 Elf32_Half program_header_table_size_; | 222 Elf32_Half program_header_table_size_; |
| 223 | 223 |
| 224 // Pointer to string table containing section names. | 224 // Pointer to string table containing section names. |
| 225 const char* default_string_section_; | 225 const char* default_string_section_; |
| 226 size_t default_string_section_size_; | 226 size_t default_string_section_size_; |
| 227 | 227 |
| 228 // Sorted abs32 and reel32 RVAs. These are mutable because ParseFile() needs | 228 // Sorted abs32 and reel32 RVAs. These are mutable because ParseFile() needs |
| 229 // to sort these by file offsets. | 229 // to sort these by file offsets. |
| 230 mutable std::vector<RVA> abs32_locations_; | 230 mutable std::vector<RVA> abs32_locations_; |
| 231 mutable std::vector<std::unique_ptr<TypedRVA>> rel32_locations_; | 231 mutable std::vector<std::unique_ptr<TypedRVA>> rel32_locations_; |
| 232 | 232 |
| 233 private: | 233 private: |
| 234 DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32); | 234 DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32); |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 } // namespace courgette | 237 } // namespace courgette |
| 238 | 238 |
| 239 #endif // COURGETTE_DISASSEMBLER_ELF_32_H_ | 239 #endif // COURGETTE_DISASSEMBLER_ELF_32_H_ |
| OLD | NEW |