a031c403302197dd8e7f340767ab6026557491c3
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.
21 class General_options
;
23 template<int size
, bool big_endian
>
25 template<int size
, bool big_endian
>
32 // The abstract class for target specific handling.
40 // Return the bit size that this target implements. This should
44 { return this->pti_
->size
; }
46 // Return whether this target is big-endian.
49 { return this->pti_
->is_big_endian
; }
51 // Machine code to store in e_machine field of ELF header.
54 { return this->pti_
->machine_code
; }
56 // Whether this target has a specific make_symbol function.
58 has_make_symbol() const
59 { return this->pti_
->has_make_symbol
; }
61 // Whether this target has a specific resolve function.
64 { return this->pti_
->has_resolve
; }
66 // Return the default name of the dynamic linker.
68 dynamic_linker() const
69 { return this->pti_
->dynamic_linker
; }
71 // Return the default address to use for the text segment.
73 text_segment_address() const
74 { return this->pti_
->text_segment_address
; }
76 // Return the ABI specified page size.
79 { return this->pti_
->abi_pagesize
; }
81 // Return the common page size used on actual systems.
83 common_pagesize() const
84 { return this->pti_
->common_pagesize
; }
86 // This is called to tell the target to complete any sections it is
87 // handling. After this all sections must have their final size.
89 finalize_sections(Layout
* layout
)
90 { return this->do_finalize_sections(layout
); }
93 // This struct holds the constant information for a child class. We
94 // use a struct to avoid the overhead of virtual function calls for
95 // simple information.
98 // Address size (32 or 64).
100 // Whether the target is big endian.
102 // The code to store in the e_machine field of the ELF header.
103 elfcpp::EM machine_code
;
104 // Whether this target has a specific make_symbol function.
105 bool has_make_symbol
;
106 // Whether this target has a specific resolve function.
108 // The default dynamic linker name.
109 const char* dynamic_linker
;
110 // The default text segment address.
111 uint64_t text_segment_address
;
112 // The ABI specified page size.
113 uint64_t abi_pagesize
;
114 // The common page size used by actual implementations.
115 uint64_t common_pagesize
;
118 Target(const Target_info
* pti
)
122 // Virtual function which may be implemented by the child class.
124 do_finalize_sections(Layout
*)
128 Target(const Target
&);
129 Target
& operator=(const Target
&);
131 // The target information.
132 const Target_info
* pti_
;
135 // The abstract class for a specific size and endianness of target.
136 // Each actual target implementation class should derive from an
137 // instantiation of Sized_target.
139 template<int size
, bool big_endian
>
140 class Sized_target
: public Target
143 // Make a new symbol table entry for the target. This should be
144 // overridden by a target which needs additional information in the
145 // symbol table. This will only be called if has_make_symbol()
147 virtual Sized_symbol
<size
>*
149 { gold_unreachable(); }
151 // Resolve a symbol for the target. This should be overridden by a
152 // target which needs to take special action. TO is the
153 // pre-existing symbol. SYM is the new symbol, seen in OBJECT.
154 // This will only be called if has_resolve() returns true.
156 resolve(Symbol
*, const elfcpp::Sym
<size
, big_endian
>&, Object
*)
157 { gold_unreachable(); }
159 // Scan the relocs for a section, and record any information
160 // required for the symbol. OPTIONS is the command line options.
161 // SYMTAB is the symbol table. OBJECT is the object in which the
162 // section appears. DATA_SHNDX is the section index that these
163 // relocs apply to. SH_TYPE is the type of the relocation section,
164 // SHT_REL or SHT_RELA. PRELOCS points to the relocation data.
165 // RELOC_COUNT is the number of relocs. LOCAL_SYMBOL_COUNT is the
166 // number of local symbols. PLOCAL_SYMBOLS points to the local
167 // symbol data from OBJECT. GLOBAL_SYMBOLS is the array of pointers
168 // to the global symbol table from OBJECT.
170 scan_relocs(const General_options
& options
,
171 Symbol_table
* symtab
,
173 Sized_relobj
<size
, big_endian
>* object
,
174 unsigned int data_shndx
,
175 unsigned int sh_type
,
176 const unsigned char* prelocs
,
178 size_t local_symbol_count
,
179 const unsigned char* plocal_symbols
,
180 Symbol
** global_symbols
) = 0;
182 // Relocate section data. SH_TYPE is the type of the relocation
183 // section, SHT_REL or SHT_RELA. PRELOCS points to the relocation
184 // information. RELOC_COUNT is the number of relocs. VIEW is a
185 // view into the output file holding the section contents,
186 // VIEW_ADDRESS is the virtual address of the view, and VIEW_SIZE is
187 // the size of the view.
189 relocate_section(const Relocate_info
<size
, big_endian
>*,
190 unsigned int sh_type
,
191 const unsigned char* prelocs
,
194 typename
elfcpp::Elf_types
<size
>::Elf_Addr view_address
,
195 off_t view_size
) = 0;
198 Sized_target(const Target::Target_info
* pti
)
201 gold_assert(pti
->size
== size
);
202 gold_assert(pti
->is_big_endian
? big_endian
: !big_endian
);
206 } // End namespace gold.
208 #endif // !defined(GOLD_TARGET_H)
This page took 0.046759 seconds and 4 git commands to generate.