Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: courgette/disassembler.cc

Issue 2055343002: Courgette: Add static method QuickDetect() to optimize program detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit cleanup Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "courgette/disassembler.h" 5 #include "courgette/disassembler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "courgette/assembly_program.h" 10 #include "courgette/assembly_program.h"
(...skipping 15 matching lines...) Expand all
26 const std::vector<RVA>& rva_locations, 26 const std::vector<RVA>& rva_locations,
27 const AddressTranslator& translator) 27 const AddressTranslator& translator)
28 : VectorRvaVisitor<RVA>(rva_locations), translator_(translator) { 28 : VectorRvaVisitor<RVA>(rva_locations), translator_(translator) {
29 } 29 }
30 30
31 RVA Disassembler::RvaVisitor_Rel32::Get() const { 31 RVA Disassembler::RvaVisitor_Rel32::Get() const {
32 // For Rel32 targets, only handle 32-bit offsets. 32 // For Rel32 targets, only handle 32-bit offsets.
33 return *it_ + 4 + Read32LittleEndian(translator_.RVAToPointer(*it_)); 33 return *it_ + 4 + Read32LittleEndian(translator_.RVAToPointer(*it_));
34 } 34 }
35 35
36 Disassembler::Disassembler(const void* start, size_t length) 36 Disassembler::Disassembler(const uint8_t* start, size_t length)
37 : failure_reason_("uninitialized") { 37 : failure_reason_("uninitialized") {
38 start_ = reinterpret_cast<const uint8_t*>(start); 38 start_ = reinterpret_cast<const uint8_t*>(start);
Will Harris 2016/06/13 19:15:21 no need for this cast now?
etiennep 2016/06/14 21:16:37 Done.
39 length_ = length; 39 length_ = length;
40 end_ = start_ + length_; 40 end_ = start_ + length_;
41 }; 41 };
42 42
43 Disassembler::~Disassembler() {}; 43 Disassembler::~Disassembler() {};
44 44
45 const uint8_t* Disassembler::FileOffsetToPointer(FileOffset file_offset) const { 45 const uint8_t* Disassembler::FileOffsetToPointer(FileOffset file_offset) const {
46 CHECK_LE(file_offset, static_cast<FileOffset>(end_ - start_)); 46 CHECK_LE(file_offset, static_cast<FileOffset>(end_ - start_));
47 return start_ + file_offset; 47 return start_ + file_offset;
48 } 48 }
(...skipping 22 matching lines...) Expand all
71 program->PrecomputeLabels(abs32_visitor.get(), rel32_visitor.get()); 71 program->PrecomputeLabels(abs32_visitor.get(), rel32_visitor.get());
72 } 72 }
73 73
74 void Disassembler::ReduceLength(size_t reduced_length) { 74 void Disassembler::ReduceLength(size_t reduced_length) {
75 CHECK_LE(reduced_length, length_); 75 CHECK_LE(reduced_length, length_);
76 length_ = reduced_length; 76 length_ = reduced_length;
77 end_ = start_ + length_; 77 end_ = start_ + length_;
78 } 78 }
79 79
80 } // namespace courgette 80 } // namespace courgette
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698