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 : #include "syzygy/core/address.h"
15 :
16 : #include <iostream>
17 : #include "base/strings/stringprintf.h"
18 :
19 : namespace core {
20 :
21 : // Host function for compile asserts.
22 : void CompileAsserts() {
23 : COMPILE_ASSERT(sizeof(RelativeAddress) == sizeof(uint32),
24 : relative_address_must_be_4_byte);
25 : COMPILE_ASSERT(sizeof(AbsoluteAddress) == sizeof(uint32),
26 : absolute_address_must_be_4_byte);
27 : COMPILE_ASSERT(sizeof(FileOffsetAddress) == sizeof(uint32),
28 : file_offset_must_be_4_byte);
29 : }
30 :
31 E : const RelativeAddress RelativeAddress::kInvalidAddress(~0U);
32 E : const AbsoluteAddress AbsoluteAddress::kInvalidAddress(~0U);
33 E : const FileOffsetAddress FileOffsetAddress::kInvalidAddress(~0U);
34 :
35 E : std::ostream& operator<<(std::ostream& str, RelativeAddress addr) {
36 E : str << base::StringPrintf("Relative(0x%08X)", addr.value());
37 E : return str;
38 E : }
39 :
40 E : std::ostream& operator<<(std::ostream& str, AbsoluteAddress addr) {
41 E : str << base::StringPrintf("Absolute(0x%08X)", addr.value());
42 E : return str;
43 E : }
44 :
45 E : std::ostream& operator<<(std::ostream& str, FileOffsetAddress addr) {
46 E : str << base::StringPrintf("FileOffset(0x%08X)", addr.value());
47 E : return str;
48 E : }
49 :
50 : } // namespace core
|