1 : // Copyright 2011 Google Inc.
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/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 : std::ostream& operator<<(std::ostream& str, RelativeAddress addr) {
32 E : str << StringPrintf("Relative(0x%08X)", addr.value());
33 E : return str;
34 E : }
35 :
36 E : std::ostream& operator<<(std::ostream& str, AbsoluteAddress addr) {
37 E : str << StringPrintf("Absolute(0x%08X)", addr.value());
38 E : return str;
39 E : }
40 :
41 i : std::ostream& operator<<(std::ostream& str, FileOffsetAddress addr) {
42 i : str << StringPrintf("FileOffset(0x%08X)", addr.value());
43 i : return str;
44 i : }
45 :
46 : } // namespace core
|