1 : // Copyright 2013 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 : // Declares the COFF-specific transform policy object. This guides decisions
16 : // made during image decomposition, basic-block decomposition, transforms and
17 : // block building.
18 :
19 : #ifndef SYZYGY_PE_COFF_TRANSFORM_POLICY_H_
20 : #define SYZYGY_PE_COFF_TRANSFORM_POLICY_H_
21 :
22 : #include "syzygy/block_graph/transform_policy.h"
23 : #include "syzygy/pe/pe_transform_policy.h"
24 :
25 : namespace pe {
26 :
27 : // The interface that guides image and basic-block transform decisions for COFF
28 : // files.
29 : class CoffTransformPolicy : public block_graph::TransformPolicyInterface {
30 : public:
31 E : CoffTransformPolicy() { }
32 E : virtual ~CoffTransformPolicy() { }
33 :
34 : // @name TransformPolicyInterface implementation
35 : // @{
36 : virtual bool BlockIsSafeToBasicBlockDecompose(
37 : const BlockGraph::Block* block) const override;
38 : virtual bool ReferenceIsSafeToRedirect(
39 : const BlockGraph::Block* referrer,
40 : const BlockGraph::Reference& reference) const override;
41 : // @}
42 :
43 : private:
44 : // TODO(chrisha): For now we are only a thin wrapper around a PE transform
45 : // policy. When the rest of the COFF machinery lands reimplement this to
46 : // respect the differences between COFF and PE code blocks.
47 : PETransformPolicy pe_policy_;
48 :
49 : DISALLOW_COPY_AND_ASSIGN(CoffTransformPolicy);
50 : };
51 :
52 : } // namespace pe
53 :
54 : #endif // SYZYGY_PE_COFF_TRANSFORM_POLICY_H_
|