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.
24 // The abstract class for target specific handling.
32 // Return the bit size that this target implements. This should
36 { return this->size_; }
38 // Return whether this target is big-endian.
41 { return this->is_big_endian_; }
43 // Whether this target has a specific make_symbol function.
45 has_make_symbol() const
46 { return this->has_make_symbol_; }
48 // Whether this target has a specific resolve function.
51 { return this->has_resolve_; }
53 // Resolve a symbol. This is called when we see a symbol with a
54 // target specific binding (STB_LOOS through STB_HIOS or STB_LOPROC
55 // through STB_HIPROC). TO is a pre-existing symbol. SYM is the
56 // new symbol, seen in OBJECT. This returns true on success, false
57 // if the symbol can not be resolved.
58 template<int size, bool big_endian>
60 resolve(Sized_symbol<size>* to, const elfcpp::Sym<size, big_endian>& sym,
64 Target(int size, bool is_big_endian, bool has_make_symbol, bool has_resolve)
66 is_big_endian_(is_big_endian),
67 has_make_symbol_(has_make_symbol),
68 has_resolve_(has_resolve)
72 Target(const Target&);
73 Target& operator=(const Target&);
77 // Whether this target is big endian.
79 // Whether this target has a special make_symbol function.
80 bool has_make_symbol_;
81 // Whether this target has a special resolve function.
85 // The abstract class for a specific size and endianness of target.
86 // Each actual target implementation class should derive from an
87 // instantiation of Sized_target.
89 template<int size, bool big_endian>
90 class Sized_target : public Target
93 // Make a new symbol table entry for the target. This should be
94 // overridden by a target which needs additional information in the
95 // symbol table. This will only be called if has_make_symbol()
97 virtual Sized_symbol<size>*
101 // Resolve a symbol for the target. This should be overridden by a
102 // target which needs to take special action. TO is the
103 // pre-existing symbol. SYM is the new symbol, seen in OBJECT.
105 resolve(Symbol*, const elfcpp::Sym<size, big_endian>&, Object*)
109 Sized_target(bool has_make_symbol, bool has_resolve)
110 : Target(size, big_endian, has_make_symbol, has_resolve)
114 } // End namespace gold.
116 #endif // !defined(GOLD_TARGET_H)