1 // target.h -- target support for gold -*- C++ -*-
3 // The abstract class Target is the interface for target specific
4 // support. It defines abstract methods which each target must
5 // implement. Typically there will be one target per processor, but
6 // in some cases it may be necessary to have subclasses.
8 // For speed and consistency we want to use inline functions to handle
9 // relocation processing. So besides implementations of the abstract
10 // methods, each target is expected to define a template
11 // specialization of the relocation functions.
26 // The abstract class for target specific handling.
34 // Return the bit size that this target implements. This should
38 { return this->pti_
->size
; }
40 // Return whether this target is big-endian.
43 { return this->pti_
->is_big_endian
; }
45 // Whether this target has a specific make_symbol function.
47 has_make_symbol() const
48 { return this->pti_
->has_make_symbol
; }
50 // Whether this target has a specific resolve function.
53 { return this->pti_
->has_resolve
; }
55 // Return the default address to use for the text segment.
57 text_segment_address() const
58 { return this->pti_
->text_segment_address
; }
60 // Return the ABI specified page size.
63 { return this->pti_
->abi_pagesize
; }
65 // Return the common page size used on actual systems.
67 common_pagesize() const
68 { return this->pti_
->common_pagesize
; }
71 // This struct holds the constant information for a child class. We
72 // use a struct to avoid the overhead of virtual function calls for
73 // simple information.
76 // Address size (32 or 64).
78 // Whether the target is big endian.
80 // Whether this target has a specific make_symbol function.
82 // Whether this target has a specific resolve function.
84 // The default text segment address.
85 uint64_t text_segment_address
;
86 // The ABI specified page size.
87 uint64_t abi_pagesize
;
88 // The common page size used by actual implementations.
89 uint64_t common_pagesize
;
92 Target(const Target_info
* pti
)
97 Target(const Target
&);
98 Target
& operator=(const Target
&);
100 // The target information.
101 const Target_info
* pti_
;
104 // The abstract class for a specific size and endianness of target.
105 // Each actual target implementation class should derive from an
106 // instantiation of Sized_target.
108 template<int size
, bool big_endian
>
109 class Sized_target
: public Target
112 // Make a new symbol table entry for the target. This should be
113 // overridden by a target which needs additional information in the
114 // symbol table. This will only be called if has_make_symbol()
116 virtual Sized_symbol
<size
>*
120 // Resolve a symbol for the target. This should be overridden by a
121 // target which needs to take special action. TO is the
122 // pre-existing symbol. SYM is the new symbol, seen in OBJECT.
124 resolve(Symbol
*, const elfcpp::Sym
<size
, big_endian
>&, Object
*)
128 Sized_target(const Target::Target_info
* pti
)
131 assert(pti
->size
== size
);
132 assert(pti
->is_big_endian
? big_endian
: !big_endian
);
136 } // End namespace gold.
138 #endif // !defined(GOLD_TARGET_H)