1 : // Copyright 2015 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 : #ifndef SYZYGY_REFINERY_CORE_ADDRESS_H_
16 : #define SYZYGY_REFINERY_CORE_ADDRESS_H_
17 :
18 : #include <stdint.h>
19 :
20 : #include "syzygy/core/address_range.h"
21 :
22 m : namespace refinery {
23 :
24 : // TODO(manzagop): consider making Address a class for stricter control on
25 : // conversions. In particular, we've hit an issue where an int* being
26 : // reinterpret_cast'ed to an Address triggered sign extension in the pointer.
27 m : typedef uint64_t Address;
28 m : typedef uint64_t RelativeAddress;
29 m : typedef uint32_t Size;
30 :
31 : // AddressRange represents a range of memory with an address and a size.
32 : // TODO(manzagop): incorporate a notion of validity wrt the process (eg 32 vs
33 : // 64 bits).
34 m : class AddressRange : public core::AddressRange<Address, Size> {
35 m : public:
36 m : using Super = core::AddressRange<Address, Size>;
37 :
38 m : AddressRange(Address addr, Size size) : Super(addr, size) {}
39 m : AddressRange() {}
40 :
41 : // Determines the validity of the address range. All users of |AddressRange|
42 : // expect a valid range.
43 : // @returns true if the range is valid, false otherwise (empty range or
44 : // overflow).
45 m : bool IsValid() const;
46 m : };
47 :
48 m : } // namespace refinery
49 :
50 : #endif // SYZYGY_REFINERY_CORE_ADDRESS_H_
|