1 : // Copyright 2011 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 : #include "syzygy/pdb/pdb_data.h"
16 :
17 : #include "base/logging.h"
18 :
19 : namespace pdb {
20 :
21 : // Here is a translation from our types to
22 E : bool PdbFixup::ValidHeader() const {
23 E : switch (type) {
24 : case TYPE_ABSOLUTE:
25 : case TYPE_RELATIVE:
26 : case TYPE_PC_RELATIVE: {
27 : // Ensure that no unknown flags are set.
28 E : return (flags & FLAG_UNKNOWN) == 0;
29 : }
30 :
31 : case TYPE_OFFSET_32BIT:
32 : case TYPE_OFFSET_8BIT: {
33 : // We've only ever seen offset fixups without flags.
34 E : return flags == 0;
35 : }
36 :
37 : default: {
38 i : return false;
39 : }
40 : }
41 E : }
42 :
43 E : size_t PdbFixup::size() const {
44 E : switch (type) {
45 E : case TYPE_ABSOLUTE: return 4;
46 E : case TYPE_RELATIVE: return 4;
47 i : case TYPE_OFFSET_32BIT: return 4;
48 i : case TYPE_OFFSET_8BIT: return 1;
49 E : case TYPE_PC_RELATIVE: return 4;
50 :
51 : default: {
52 i : NOTREACHED() << "Invalid PdbFixup::Type: " << type << ".";
53 : }
54 : }
55 :
56 i : return 0;
57 E : }
58 :
59 E : bool PdbFixup::is_offset() const {
60 : return type == TYPE_OFFSET_32BIT ||
61 E : type == TYPE_OFFSET_8BIT;
62 E : }
63 :
64 : } // namespace pdb
|