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.
25 template<int size
, bool big_endian
>
28 // The abstract class for target specific handling.
36 // Return the bit size that this target implements. This should
40 { return this->pti_
->size
; }
42 // Return whether this target is big-endian.
45 { return this->pti_
->is_big_endian
; }
47 // Machine code to store in e_machine field of ELF header.
50 { return this->pti_
->machine_code
; }
52 // Whether this target has a specific make_symbol function.
54 has_make_symbol() const
55 { return this->pti_
->has_make_symbol
; }
57 // Whether this target has a specific resolve function.
60 { return this->pti_
->has_resolve
; }
62 // Return the default address to use for the text segment.
64 text_segment_address() const
65 { return this->pti_
->text_segment_address
; }
67 // Return the ABI specified page size.
70 { return this->pti_
->abi_pagesize
; }
72 // Return the common page size used on actual systems.
74 common_pagesize() const
75 { return this->pti_
->common_pagesize
; }
78 // This struct holds the constant information for a child class. We
79 // use a struct to avoid the overhead of virtual function calls for
80 // simple information.
83 // Address size (32 or 64).
85 // Whether the target is big endian.
87 // The code to store in the e_machine field of the ELF header.
88 elfcpp::EM machine_code
;
89 // Whether this target has a specific make_symbol function.
91 // Whether this target has a specific resolve function.
93 // The default text segment address.
94 uint64_t text_segment_address
;
95 // The ABI specified page size.
96 uint64_t abi_pagesize
;
97 // The common page size used by actual implementations.
98 uint64_t common_pagesize
;
101 Target(const Target_info
* pti
)
106 Target(const Target
&);
107 Target
& operator=(const Target
&);
109 // The target information.
110 const Target_info
* pti_
;
113 // The abstract class for a specific size and endianness of target.
114 // Each actual target implementation class should derive from an
115 // instantiation of Sized_target.
117 template<int size
, bool big_endian
>
118 class Sized_target
: public Target
121 // Make a new symbol table entry for the target. This should be
122 // overridden by a target which needs additional information in the
123 // symbol table. This will only be called if has_make_symbol()
125 virtual Sized_symbol
<size
>*
129 // Resolve a symbol for the target. This should be overridden by a
130 // target which needs to take special action. TO is the
131 // pre-existing symbol. SYM is the new symbol, seen in OBJECT.
133 resolve(Symbol
*, const elfcpp::Sym
<size
, big_endian
>&, Object
*)
136 // Relocate section data. SYMTAB is the symbol table. OBJECT is
137 // the object in which the section appears. SH_TYPE is the type of
138 // the relocation section, SHT_REL or SHT_RELA. PRELOCS points to
139 // the relocation information. RELOC_COUNT is the number of relocs.
140 // LOCAL_COUNT is the number of local symbols. The VALUES and
141 // GLOBAL_SYMS have symbol table information. VIEW is a view into
142 // the output file holding the section contents, VIEW_ADDRESS is the
143 // virtual address of the view, and VIEW_SIZE is the size of the
146 relocate_section(const Symbol_table
*, // symtab
147 Sized_object
<size
, big_endian
>*, // object
148 unsigned int, // sh_type
149 const unsigned char*, // prelocs
150 size_t, // reloc_count
151 unsigned int, // local_count
152 const typename
elfcpp::Elf_types
<size
>::Elf_Addr
*, // values
153 Symbol
**, // global_syms
154 unsigned char*, // view
155 typename
elfcpp::Elf_types
<size
>::Elf_Addr
, // view_address
160 Sized_target(const Target::Target_info
* pti
)
163 assert(pti
->size
== size
);
164 assert(pti
->is_big_endian
? big_endian
: !big_endian
);
168 } // End namespace gold.
170 #endif // !defined(GOLD_TARGET_H)