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 : // Declares an ordering that duplicates the original ordering implied by the
16 : // underlying block graph's source ranges. If the block graph has not been
17 : // transformed the ordering will be identical to the ordering of the original
18 : // image. If it has been changed, it will be substantially similar. The blocks
19 : // in each section are ordered as follows:
20 : //
21 : // 1. Blocks with initialized data before blocks without.
22 : // 2. Presence of source range data as primary key.
23 : // 3. Source address of first data byte with source data as secondary key.
24 : // 4. Finally, break ties with the always unique block ID.
25 : //
26 : // Sections are ordered by section ID, as the Decomposer currently guarantees
27 : // that this will be the same order in which they were laid out in the original
28 : // image.
29 :
30 : #ifndef SYZYGY_BLOCK_GRAPH_ORDERERS_ORIGINAL_ORDERER_H_
31 : #define SYZYGY_BLOCK_GRAPH_ORDERERS_ORIGINAL_ORDERER_H_
32 :
33 : #include "syzygy/block_graph/orderers/named_orderer.h"
34 :
35 : namespace block_graph {
36 : namespace orderers {
37 :
38 : class OriginalOrderer
39 : : public block_graph::orderers::NamedOrdererImpl<OriginalOrderer> {
40 : public:
41 E : OriginalOrderer() { }
42 :
43 : // Applies this orderer to the provided block graph.
44 : //
45 : // @param ordered_block_graph the block graph to order.
46 : // @param header_block The header block of the block graph to transform.
47 : // @returns true on success, false otherwise.
48 : virtual bool OrderBlockGraph(OrderedBlockGraph* ordered_block_graph,
49 : BlockGraph::Block* header_block) OVERRIDE;
50 :
51 : static const char kOrdererName[];
52 :
53 : private:
54 : DISALLOW_COPY_AND_ASSIGN(OriginalOrderer);
55 : };
56 :
57 : } // namespace orderers
58 : } // namespace block_graph
59 :
60 : #endif // SYZYGY_BLOCK_GRAPH_ORDERERS_ORIGINAL_ORDERER_H_
|