| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sandbox/linux/seccomp-bpf/codegen.h" |
| 6 |
| 5 #include <stdio.h> | 7 #include <stdio.h> |
| 6 | 8 |
| 9 #include <set> |
| 10 |
| 7 #include "base/logging.h" | 11 #include "base/logging.h" |
| 8 #include "sandbox/linux/seccomp-bpf/codegen.h" | 12 #include "sandbox/linux/seccomp-bpf/basicblock.h" |
| 13 #include "sandbox/linux/seccomp-bpf/die.h" |
| 14 #include "sandbox/linux/seccomp-bpf/instruction.h" |
| 15 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h" |
| 9 | 16 |
| 10 namespace { | 17 namespace { |
| 11 | 18 |
| 12 // Helper function for Traverse(). | 19 // Helper function for Traverse(). |
| 13 void TraverseRecursively(std::set<sandbox::Instruction*>* visited, | 20 void TraverseRecursively(std::set<sandbox::Instruction*>* visited, |
| 14 sandbox::Instruction* instruction) { | 21 sandbox::Instruction* instruction) { |
| 15 if (visited->find(instruction) == visited->end()) { | 22 if (visited->find(instruction) == visited->end()) { |
| 16 visited->insert(instruction); | 23 visited->insert(instruction); |
| 17 switch (BPF_CLASS(instruction->code)) { | 24 switch (BPF_CLASS(instruction->code)) { |
| 18 case BPF_JMP: | 25 case BPF_JMP: |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 CutGraphIntoBasicBlocks(instructions, branch_targets, &all_blocks); | 768 CutGraphIntoBasicBlocks(instructions, branch_targets, &all_blocks); |
| 762 MergeTails(&all_blocks); | 769 MergeTails(&all_blocks); |
| 763 BasicBlocks basic_blocks; | 770 BasicBlocks basic_blocks; |
| 764 TopoSortBasicBlocks(first_block, all_blocks, &basic_blocks); | 771 TopoSortBasicBlocks(first_block, all_blocks, &basic_blocks); |
| 765 ComputeRelativeJumps(&basic_blocks, all_blocks); | 772 ComputeRelativeJumps(&basic_blocks, all_blocks); |
| 766 ConcatenateBasicBlocks(basic_blocks, program); | 773 ConcatenateBasicBlocks(basic_blocks, program); |
| 767 return; | 774 return; |
| 768 } | 775 } |
| 769 | 776 |
| 770 } // namespace sandbox | 777 } // namespace sandbox |
| OLD | NEW |