1 : // Copyright 2012 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 : // Utilities for dealing with block-graphs and blocks generated over a PE
16 : // binary.
17 :
18 : #ifndef SYZYGY_PE_BLOCK_UTIL_H_
19 : #define SYZYGY_PE_BLOCK_UTIL_H_
20 :
21 : #include "syzygy/block_graph/block_graph.h"
22 :
23 m : namespace pe {
24 :
25 : // Determines if this code block's references are consistent with CL.EXE
26 : // compiled code. The following criteria must hold: all references from this
27 : // block to any code block (including self-references) must be direct.
28 : //
29 : // @param block the code block whose references are to be inspected.
30 : // @returns true if the block's references are consistent with CL.EXE compiled
31 : // code, false otherwise.
32 : // @pre block has type CODE_BLOCK.
33 m : bool CodeBlockReferencesAreClConsistent(
34 m : const block_graph::BlockGraph::Block* block);
35 :
36 : // Determines if this code block's referrers are consistent with CL.EXE compiled
37 : // code. This will be true if all the intra- and inter-block references are
38 : // of valid types, depending on their origins and destinations (see
39 : // implementation for full details). It also requires that all data labels be
40 : // directly referenced, and that if the block has data, it be strictly at the
41 : // end of the block.
42 : //
43 : // @param block the block whose referrers are to be inspected.
44 : // @returns true if the block's referrers are consistent with CL.EXE compiled
45 : // code, false otherwise.
46 : // @pre block has type CODE_BLOCK.
47 m : bool CodeBlockReferrersAreClConsistent(
48 m : const block_graph::BlockGraph::Block* block);
49 :
50 : // Determines if a code block is consistent with CL.EXE compiled code. This is
51 : // true iff CodeBlockAttributesAreClConsistent,
52 : // CodeBlockReferencesAreClConsistent and CodeBlockReferrersAreClConsistent
53 : // all return true.
54 : // @returns true if this code block is consistent with CL.EXE compiled code,
55 : // false otherwise.
56 : // @pre block has type CODE_BLOCK.
57 m : bool CodeBlockIsClConsistent(
58 m : const block_graph::BlockGraph::Block* block);
59 :
60 : // Determines if a code block is basic-block decomposable. This is possible if
61 : // CodeBlockIsClConsistent passes, or if the block has the BUILT_BY_SYZYGY
62 : // attribute.
63 : // @returns true if this code block is BB decomposable, false otherwise.
64 : // @pre block has type CODE_BLOCK.
65 m : bool CodeBlockIsBasicBlockDecomposable(
66 m : const block_graph::BlockGraph::Block* block);
67 :
68 m : } // namespace pe
69 :
70 : #endif // SYZYGY_PE_BLOCK_UTIL_H_
|