| 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 #include "courgette/disassembler_elf_32_arm.h" | 5 #include "courgette/disassembler_elf_32_arm.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 if (!rel32_rva->ComputeRelativeTarget(p)) | 498 if (!rel32_rva->ComputeRelativeTarget(p)) |
| 499 return false; | 499 return false; |
| 500 | 500 |
| 501 target_rva = rel32_rva->rva() + rel32_rva->relative_target(); | 501 target_rva = rel32_rva->rva() + rel32_rva->relative_target(); |
| 502 found = true; | 502 found = true; |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 | 505 |
| 506 if (found && IsValidTargetRVA(target_rva)) { | 506 if (found && IsValidTargetRVA(target_rva)) { |
| 507 uint16_t op_size = rel32_rva->op_size(); | 507 uint16_t op_size = rel32_rva->op_size(); |
| 508 rel32_locations_.push_back(rel32_rva.release()); | 508 rel32_locations_.push_back(std::move(rel32_rva)); |
| 509 #if COURGETTE_HISTOGRAM_TARGETS | 509 #if COURGETTE_HISTOGRAM_TARGETS |
| 510 ++rel32_target_rvas_[target_rva]; | 510 ++rel32_target_rvas_[target_rva]; |
| 511 #endif | 511 #endif |
| 512 p += op_size; | 512 p += op_size; |
| 513 | 513 |
| 514 // A tricky way to update the on_32bit flag. Here is the truth table: | 514 // A tricky way to update the on_32bit flag. Here is the truth table: |
| 515 // on_32bit | on_32bit size is 4 | 515 // on_32bit | on_32bit size is 4 |
| 516 // ---------+--------------------- | 516 // ---------+--------------------- |
| 517 // 1 | 0 0 | 517 // 1 | 0 0 |
| 518 // 0 | 0 1 | 518 // 0 | 0 1 |
| 519 // 0 | 1 0 | 519 // 0 | 1 0 |
| 520 // 1 | 1 1 | 520 // 1 | 1 1 |
| 521 on_32bit = (~(on_32bit ^ (op_size == 4))) != 0; | 521 on_32bit = (~(on_32bit ^ (op_size == 4))) != 0; |
| 522 } else { | 522 } else { |
| 523 // Move 2 bytes at a time, but track 32-bit boundaries | 523 // Move 2 bytes at a time, but track 32-bit boundaries |
| 524 p += 2; | 524 p += 2; |
| 525 on_32bit = ((on_32bit + 1) % 2) != 0; | 525 on_32bit = ((on_32bit + 1) % 2) != 0; |
| 526 } | 526 } |
| 527 } | 527 } |
| 528 | 528 |
| 529 return true; | 529 return true; |
| 530 } | 530 } |
| 531 | 531 |
| 532 } // namespace courgette | 532 } // namespace courgette |
| OLD | NEW |