g++ 3.2.2 portability fixes.
[deliverable/binutils-gdb.git] / gold / target.h
1 // target.h -- target support for gold -*- C++ -*-
2
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.
7
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.
12
13 #ifndef GOLD_TARGET_H
14 #define GOLD_TARGET_H
15
16 #include "symtab.h"
17 #include "elfcpp.h"
18
19 namespace gold
20 {
21
22 class Object;
23
24 // The abstract class for target specific handling.
25
26 class Target
27 {
28 public:
29 virtual ~Target()
30 { }
31
32 // Return the bit size that this target implements. This should
33 // return 32 or 64.
34 int
35 get_size() const
36 { return this->size_; }
37
38 // Return whether this target is big-endian.
39 bool
40 is_big_endian() const
41 { return this->is_big_endian_; }
42
43 // Whether this target has a specific make_symbol function.
44 bool
45 has_make_symbol() const
46 { return this->has_make_symbol_; }
47
48 // Whether this target has a specific resolve function.
49 bool
50 has_resolve() const
51 { return this->has_resolve_; }
52
53 protected:
54 Target(int size, bool is_big_endian, bool has_make_symbol, bool has_resolve)
55 : size_(size),
56 is_big_endian_(is_big_endian),
57 has_make_symbol_(has_make_symbol),
58 has_resolve_(has_resolve)
59 { }
60
61 private:
62 Target(const Target&);
63 Target& operator=(const Target&);
64
65 // The target size.
66 int size_;
67 // Whether this target is big endian.
68 bool is_big_endian_;
69 // Whether this target has a special make_symbol function.
70 bool has_make_symbol_;
71 // Whether this target has a special resolve function.
72 bool has_resolve_;
73 };
74
75 // The abstract class for a specific size and endianness of target.
76 // Each actual target implementation class should derive from an
77 // instantiation of Sized_target.
78
79 template<int size, bool big_endian>
80 class Sized_target : public Target
81 {
82 public:
83 // Make a new symbol table entry for the target. This should be
84 // overridden by a target which needs additional information in the
85 // symbol table. This will only be called if has_make_symbol()
86 // returns true.
87 virtual Sized_symbol<size>*
88 make_symbol()
89 { abort(); }
90
91 // Resolve a symbol for the target. This should be overridden by a
92 // target which needs to take special action. TO is the
93 // pre-existing symbol. SYM is the new symbol, seen in OBJECT.
94 virtual void
95 resolve(Symbol*, const elfcpp::Sym<size, big_endian>&, Object*)
96 { abort(); }
97
98 protected:
99 Sized_target(bool has_make_symbol, bool has_resolve)
100 : Target(size, big_endian, has_make_symbol, has_resolve)
101 { }
102 };
103
104 } // End namespace gold.
105
106 #endif // !defined(GOLD_TARGET_H)
This page took 0.057184 seconds and 5 git commands to generate.