1 : // Copyright 2014 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 a transform for converting non-relocation reference types in code
16 : // blocks to equivalent relocation references. Legacy transformations that have
17 : // not been updated to fully support COFF may insert these kinds of references
18 : // when generating or altering code.
19 : //
20 : // TODO(chrisha): Remove this eventually. It appears that *all* references use
21 : // the RELOC_REF_BIT when processing COFF files, and that reference types
22 : // are never mixed. Thus, the bit basically only indicates that we are
23 : // dealing with a COFF file, which is already known.
24 :
25 : #ifndef SYZYGY_PE_TRANSFORMS_COFF_CONVERT_LEGACY_CODE_REFERENCES_TRANSFORM_H_
26 : #define SYZYGY_PE_TRANSFORMS_COFF_CONVERT_LEGACY_CODE_REFERENCES_TRANSFORM_H_
27 :
28 : #include "syzygy/block_graph/transforms/named_transform.h"
29 :
30 : namespace pe {
31 : namespace transforms {
32 :
33 : // A transform for converting non-relocation reference types in code blocks
34 : // to equivalent relocation references.
35 : class CoffConvertLegacyCodeReferencesTransform
36 : : public block_graph::transforms::NamedBlockGraphTransformImpl<
37 : CoffConvertLegacyCodeReferencesTransform> {
38 : public:
39 : typedef block_graph::BlockGraph BlockGraph;
40 : typedef block_graph::TransformPolicyInterface TransformPolicyInterface;
41 :
42 : // Construct a CoffConvertLegacyCodeReferencesTransform.
43 E : CoffConvertLegacyCodeReferencesTransform() {}
44 :
45 : // Perform the transform. Convert legacy references in all code blocks.
46 : // @param policy the policy object restricting how the transform is applied.
47 : // @param block_graph the BlockGraph to transform.
48 : // @param headers_block the block containing the headers. This is currently
49 : // unused.
50 : // @returns true on success, false otherwise.
51 : virtual bool TransformBlockGraph(
52 : const TransformPolicyInterface* policy,
53 : BlockGraph* block_graph,
54 : BlockGraph::Block* /* headers_block */) OVERRIDE;
55 :
56 : // The name of this transform.
57 : static const char kTransformName[];
58 :
59 : private:
60 : DISALLOW_COPY_AND_ASSIGN(CoffConvertLegacyCodeReferencesTransform);
61 : };
62 :
63 : } // namespace transforms
64 : } // namespace pe
65 :
66 : #endif // SYZYGY_PE_TRANSFORMS_COFF_CONVERT_LEGACY_CODE_REFERENCES_TRANSFORM_H_
|