xref: /netbsd/external/gpl3/gdb.old/dist/gold/target.h (revision 56bb7041)
1*56bb7041Schristos // target.h -- target support for gold   -*- C++ -*-
2*56bb7041Schristos 
3*56bb7041Schristos // Copyright (C) 2006-2020 Free Software Foundation, Inc.
4*56bb7041Schristos // Written by Ian Lance Taylor <iant@google.com>.
5*56bb7041Schristos 
6*56bb7041Schristos // This file is part of gold.
7*56bb7041Schristos 
8*56bb7041Schristos // This program is free software; you can redistribute it and/or modify
9*56bb7041Schristos // it under the terms of the GNU General Public License as published by
10*56bb7041Schristos // the Free Software Foundation; either version 3 of the License, or
11*56bb7041Schristos // (at your option) any later version.
12*56bb7041Schristos 
13*56bb7041Schristos // This program is distributed in the hope that it will be useful,
14*56bb7041Schristos // but WITHOUT ANY WARRANTY; without even the implied warranty of
15*56bb7041Schristos // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*56bb7041Schristos // GNU General Public License for more details.
17*56bb7041Schristos 
18*56bb7041Schristos // You should have received a copy of the GNU General Public License
19*56bb7041Schristos // along with this program; if not, write to the Free Software
20*56bb7041Schristos // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21*56bb7041Schristos // MA 02110-1301, USA.
22*56bb7041Schristos 
23*56bb7041Schristos // The abstract class Target is the interface for target specific
24*56bb7041Schristos // support.  It defines abstract methods which each target must
25*56bb7041Schristos // implement.  Typically there will be one target per processor, but
26*56bb7041Schristos // in some cases it may be necessary to have subclasses.
27*56bb7041Schristos 
28*56bb7041Schristos // For speed and consistency we want to use inline functions to handle
29*56bb7041Schristos // relocation processing.  So besides implementations of the abstract
30*56bb7041Schristos // methods, each target is expected to define a template
31*56bb7041Schristos // specialization of the relocation functions.
32*56bb7041Schristos 
33*56bb7041Schristos #ifndef GOLD_TARGET_H
34*56bb7041Schristos #define GOLD_TARGET_H
35*56bb7041Schristos 
36*56bb7041Schristos #include "elfcpp.h"
37*56bb7041Schristos #include "options.h"
38*56bb7041Schristos #include "parameters.h"
39*56bb7041Schristos #include "stringpool.h"
40*56bb7041Schristos #include "debug.h"
41*56bb7041Schristos 
42*56bb7041Schristos namespace gold
43*56bb7041Schristos {
44*56bb7041Schristos 
45*56bb7041Schristos class Object;
46*56bb7041Schristos class Relobj;
47*56bb7041Schristos template<int size, bool big_endian>
48*56bb7041Schristos class Sized_relobj;
49*56bb7041Schristos template<int size, bool big_endian>
50*56bb7041Schristos class Sized_relobj_file;
51*56bb7041Schristos class Relocatable_relocs;
52*56bb7041Schristos template<int size, bool big_endian>
53*56bb7041Schristos struct Relocate_info;
54*56bb7041Schristos class Reloc_symbol_changes;
55*56bb7041Schristos class Symbol;
56*56bb7041Schristos template<int size>
57*56bb7041Schristos class Sized_symbol;
58*56bb7041Schristos class Symbol_table;
59*56bb7041Schristos class Output_data;
60*56bb7041Schristos class Output_data_got_base;
61*56bb7041Schristos class Output_section;
62*56bb7041Schristos class Input_objects;
63*56bb7041Schristos class Task;
64*56bb7041Schristos struct Symbol_location;
65*56bb7041Schristos class Versions;
66*56bb7041Schristos 
67*56bb7041Schristos // The abstract class for target specific handling.
68*56bb7041Schristos 
69*56bb7041Schristos class Target
70*56bb7041Schristos {
71*56bb7041Schristos  public:
~Target()72*56bb7041Schristos   virtual ~Target()
73*56bb7041Schristos   { }
74*56bb7041Schristos 
75*56bb7041Schristos   // Return the bit size that this target implements.  This should
76*56bb7041Schristos   // return 32 or 64.
77*56bb7041Schristos   int
get_size()78*56bb7041Schristos   get_size() const
79*56bb7041Schristos   { return this->pti_->size; }
80*56bb7041Schristos 
81*56bb7041Schristos   // Return whether this target is big-endian.
82*56bb7041Schristos   bool
is_big_endian()83*56bb7041Schristos   is_big_endian() const
84*56bb7041Schristos   { return this->pti_->is_big_endian; }
85*56bb7041Schristos 
86*56bb7041Schristos   // Machine code to store in e_machine field of ELF header.
87*56bb7041Schristos   elfcpp::EM
machine_code()88*56bb7041Schristos   machine_code() const
89*56bb7041Schristos   { return this->pti_->machine_code; }
90*56bb7041Schristos 
91*56bb7041Schristos   // Processor specific flags to store in e_flags field of ELF header.
92*56bb7041Schristos   elfcpp::Elf_Word
processor_specific_flags()93*56bb7041Schristos   processor_specific_flags() const
94*56bb7041Schristos   { return this->processor_specific_flags_; }
95*56bb7041Schristos 
96*56bb7041Schristos   // Whether processor specific flags are set at least once.
97*56bb7041Schristos   bool
are_processor_specific_flags_set()98*56bb7041Schristos   are_processor_specific_flags_set() const
99*56bb7041Schristos   { return this->are_processor_specific_flags_set_; }
100*56bb7041Schristos 
101*56bb7041Schristos   // Whether this target has a specific make_symbol function.
102*56bb7041Schristos   bool
has_make_symbol()103*56bb7041Schristos   has_make_symbol() const
104*56bb7041Schristos   { return this->pti_->has_make_symbol; }
105*56bb7041Schristos 
106*56bb7041Schristos   // Whether this target has a specific resolve function.
107*56bb7041Schristos   bool
has_resolve()108*56bb7041Schristos   has_resolve() const
109*56bb7041Schristos   { return this->pti_->has_resolve; }
110*56bb7041Schristos 
111*56bb7041Schristos   // Whether this target has a specific code fill function.
112*56bb7041Schristos   bool
has_code_fill()113*56bb7041Schristos   has_code_fill() const
114*56bb7041Schristos   { return this->pti_->has_code_fill; }
115*56bb7041Schristos 
116*56bb7041Schristos   // Return the default name of the dynamic linker.
117*56bb7041Schristos   const char*
dynamic_linker()118*56bb7041Schristos   dynamic_linker() const
119*56bb7041Schristos   { return this->pti_->dynamic_linker; }
120*56bb7041Schristos 
121*56bb7041Schristos   // Return the default address to use for the text segment.
122*56bb7041Schristos   // If a -z max-page-size argument has set the ABI page size
123*56bb7041Schristos   // to a value larger than the default starting address,
124*56bb7041Schristos   // bump the starting address up to the page size, to avoid
125*56bb7041Schristos   // misaligning the text segment in the file.
126*56bb7041Schristos   uint64_t
default_text_segment_address()127*56bb7041Schristos   default_text_segment_address() const
128*56bb7041Schristos   {
129*56bb7041Schristos     uint64_t addr = this->pti_->default_text_segment_address;
130*56bb7041Schristos     uint64_t pagesize = this->abi_pagesize();
131*56bb7041Schristos     if (addr < pagesize)
132*56bb7041Schristos       addr = pagesize;
133*56bb7041Schristos     return addr;
134*56bb7041Schristos   }
135*56bb7041Schristos 
136*56bb7041Schristos   // Return the ABI specified page size.
137*56bb7041Schristos   uint64_t
abi_pagesize()138*56bb7041Schristos   abi_pagesize() const
139*56bb7041Schristos   {
140*56bb7041Schristos     if (parameters->options().max_page_size() > 0)
141*56bb7041Schristos       return parameters->options().max_page_size();
142*56bb7041Schristos     else
143*56bb7041Schristos       return this->pti_->abi_pagesize;
144*56bb7041Schristos   }
145*56bb7041Schristos 
146*56bb7041Schristos   // Return the common page size used on actual systems.
147*56bb7041Schristos   uint64_t
common_pagesize()148*56bb7041Schristos   common_pagesize() const
149*56bb7041Schristos   {
150*56bb7041Schristos     if (parameters->options().common_page_size() > 0)
151*56bb7041Schristos       return std::min(parameters->options().common_page_size(),
152*56bb7041Schristos 		      this->abi_pagesize());
153*56bb7041Schristos     else
154*56bb7041Schristos       return std::min(this->pti_->common_pagesize,
155*56bb7041Schristos 		      this->abi_pagesize());
156*56bb7041Schristos   }
157*56bb7041Schristos 
158*56bb7041Schristos   // Return whether PF_X segments must contain nothing but the contents of
159*56bb7041Schristos   // SHF_EXECINSTR sections (no non-executable data, no headers).
160*56bb7041Schristos   bool
isolate_execinstr()161*56bb7041Schristos   isolate_execinstr() const
162*56bb7041Schristos   { return this->pti_->isolate_execinstr; }
163*56bb7041Schristos 
164*56bb7041Schristos   uint64_t
rosegment_gap()165*56bb7041Schristos   rosegment_gap() const
166*56bb7041Schristos   { return this->pti_->rosegment_gap; }
167*56bb7041Schristos 
168*56bb7041Schristos   // If we see some object files with .note.GNU-stack sections, and
169*56bb7041Schristos   // some objects files without them, this returns whether we should
170*56bb7041Schristos   // consider the object files without them to imply that the stack
171*56bb7041Schristos   // should be executable.
172*56bb7041Schristos   bool
is_default_stack_executable()173*56bb7041Schristos   is_default_stack_executable() const
174*56bb7041Schristos   { return this->pti_->is_default_stack_executable; }
175*56bb7041Schristos 
176*56bb7041Schristos   // Return a character which may appear as a prefix for a wrap
177*56bb7041Schristos   // symbol.  If this character appears, we strip it when checking for
178*56bb7041Schristos   // wrapping and add it back when forming the final symbol name.
179*56bb7041Schristos   // This should be '\0' if not special prefix is required, which is
180*56bb7041Schristos   // the normal case.
181*56bb7041Schristos   char
wrap_char()182*56bb7041Schristos   wrap_char() const
183*56bb7041Schristos   { return this->pti_->wrap_char; }
184*56bb7041Schristos 
185*56bb7041Schristos   // Return the special section index which indicates a small common
186*56bb7041Schristos   // symbol.  This will return SHN_UNDEF if there are no small common
187*56bb7041Schristos   // symbols.
188*56bb7041Schristos   elfcpp::Elf_Half
small_common_shndx()189*56bb7041Schristos   small_common_shndx() const
190*56bb7041Schristos   { return this->pti_->small_common_shndx; }
191*56bb7041Schristos 
192*56bb7041Schristos   // Return values to add to the section flags for the section holding
193*56bb7041Schristos   // small common symbols.
194*56bb7041Schristos   elfcpp::Elf_Xword
small_common_section_flags()195*56bb7041Schristos   small_common_section_flags() const
196*56bb7041Schristos   {
197*56bb7041Schristos     gold_assert(this->pti_->small_common_shndx != elfcpp::SHN_UNDEF);
198*56bb7041Schristos     return this->pti_->small_common_section_flags;
199*56bb7041Schristos   }
200*56bb7041Schristos 
201*56bb7041Schristos   // Return the special section index which indicates a large common
202*56bb7041Schristos   // symbol.  This will return SHN_UNDEF if there are no large common
203*56bb7041Schristos   // symbols.
204*56bb7041Schristos   elfcpp::Elf_Half
large_common_shndx()205*56bb7041Schristos   large_common_shndx() const
206*56bb7041Schristos   { return this->pti_->large_common_shndx; }
207*56bb7041Schristos 
208*56bb7041Schristos   // Return values to add to the section flags for the section holding
209*56bb7041Schristos   // large common symbols.
210*56bb7041Schristos   elfcpp::Elf_Xword
large_common_section_flags()211*56bb7041Schristos   large_common_section_flags() const
212*56bb7041Schristos   {
213*56bb7041Schristos     gold_assert(this->pti_->large_common_shndx != elfcpp::SHN_UNDEF);
214*56bb7041Schristos     return this->pti_->large_common_section_flags;
215*56bb7041Schristos   }
216*56bb7041Schristos 
217*56bb7041Schristos   // This hook is called when an output section is created.
218*56bb7041Schristos   void
new_output_section(Output_section * os)219*56bb7041Schristos   new_output_section(Output_section* os) const
220*56bb7041Schristos   { this->do_new_output_section(os); }
221*56bb7041Schristos 
222*56bb7041Schristos   // This is called to tell the target to complete any sections it is
223*56bb7041Schristos   // handling.  After this all sections must have their final size.
224*56bb7041Schristos   void
finalize_sections(Layout * layout,const Input_objects * input_objects,Symbol_table * symtab)225*56bb7041Schristos   finalize_sections(Layout* layout, const Input_objects* input_objects,
226*56bb7041Schristos 		    Symbol_table* symtab)
227*56bb7041Schristos   { return this->do_finalize_sections(layout, input_objects, symtab); }
228*56bb7041Schristos 
229*56bb7041Schristos   // Return the value to use for a global symbol which needs a special
230*56bb7041Schristos   // value in the dynamic symbol table.  This will only be called if
231*56bb7041Schristos   // the backend first calls symbol->set_needs_dynsym_value().
232*56bb7041Schristos   uint64_t
dynsym_value(const Symbol * sym)233*56bb7041Schristos   dynsym_value(const Symbol* sym) const
234*56bb7041Schristos   { return this->do_dynsym_value(sym); }
235*56bb7041Schristos 
236*56bb7041Schristos   // Return a string to use to fill out a code section.  This is
237*56bb7041Schristos   // basically one or more NOPS which must fill out the specified
238*56bb7041Schristos   // length in bytes.
239*56bb7041Schristos   std::string
code_fill(section_size_type length)240*56bb7041Schristos   code_fill(section_size_type length) const
241*56bb7041Schristos   { return this->do_code_fill(length); }
242*56bb7041Schristos 
243*56bb7041Schristos   // Return whether SYM is known to be defined by the ABI.  This is
244*56bb7041Schristos   // used to avoid inappropriate warnings about undefined symbols.
245*56bb7041Schristos   bool
is_defined_by_abi(const Symbol * sym)246*56bb7041Schristos   is_defined_by_abi(const Symbol* sym) const
247*56bb7041Schristos   { return this->do_is_defined_by_abi(sym); }
248*56bb7041Schristos 
249*56bb7041Schristos   // Adjust the output file header before it is written out.  VIEW
250*56bb7041Schristos   // points to the header in external form.  LEN is the length.
251*56bb7041Schristos   void
adjust_elf_header(unsigned char * view,int len)252*56bb7041Schristos   adjust_elf_header(unsigned char* view, int len)
253*56bb7041Schristos   { return this->do_adjust_elf_header(view, len); }
254*56bb7041Schristos 
255*56bb7041Schristos   // Return address and size to plug into eh_frame FDEs associated with a PLT.
256*56bb7041Schristos   void
plt_fde_location(const Output_data * plt,unsigned char * oview,uint64_t * address,off_t * len)257*56bb7041Schristos   plt_fde_location(const Output_data* plt, unsigned char* oview,
258*56bb7041Schristos 		   uint64_t* address, off_t* len) const
259*56bb7041Schristos   { return this->do_plt_fde_location(plt, oview, address, len); }
260*56bb7041Schristos 
261*56bb7041Schristos   // Return whether NAME is a local label name.  This is used to implement the
262*56bb7041Schristos   // --discard-locals options.
263*56bb7041Schristos   bool
is_local_label_name(const char * name)264*56bb7041Schristos   is_local_label_name(const char* name) const
265*56bb7041Schristos   { return this->do_is_local_label_name(name); }
266*56bb7041Schristos 
267*56bb7041Schristos   // Get the symbol index to use for a target specific reloc.
268*56bb7041Schristos   unsigned int
reloc_symbol_index(void * arg,unsigned int type)269*56bb7041Schristos   reloc_symbol_index(void* arg, unsigned int type) const
270*56bb7041Schristos   { return this->do_reloc_symbol_index(arg, type); }
271*56bb7041Schristos 
272*56bb7041Schristos   // Get the addend to use for a target specific reloc.
273*56bb7041Schristos   uint64_t
reloc_addend(void * arg,unsigned int type,uint64_t addend)274*56bb7041Schristos   reloc_addend(void* arg, unsigned int type, uint64_t addend) const
275*56bb7041Schristos   { return this->do_reloc_addend(arg, type, addend); }
276*56bb7041Schristos 
277*56bb7041Schristos   // Return the PLT address to use for a global symbol.
278*56bb7041Schristos   uint64_t
plt_address_for_global(const Symbol * sym)279*56bb7041Schristos   plt_address_for_global(const Symbol* sym) const
280*56bb7041Schristos   { return this->do_plt_address_for_global(sym); }
281*56bb7041Schristos 
282*56bb7041Schristos   // Return the PLT address to use for a local symbol.
283*56bb7041Schristos   uint64_t
plt_address_for_local(const Relobj * object,unsigned int symndx)284*56bb7041Schristos   plt_address_for_local(const Relobj* object, unsigned int symndx) const
285*56bb7041Schristos   { return this->do_plt_address_for_local(object, symndx); }
286*56bb7041Schristos 
287*56bb7041Schristos   // Return the offset to use for the GOT_INDX'th got entry which is
288*56bb7041Schristos   // for a local tls symbol specified by OBJECT, SYMNDX.
289*56bb7041Schristos   int64_t
tls_offset_for_local(const Relobj * object,unsigned int symndx,unsigned int got_indx)290*56bb7041Schristos   tls_offset_for_local(const Relobj* object,
291*56bb7041Schristos 		       unsigned int symndx,
292*56bb7041Schristos 		       unsigned int got_indx) const
293*56bb7041Schristos   { return do_tls_offset_for_local(object, symndx, got_indx); }
294*56bb7041Schristos 
295*56bb7041Schristos   // Return the offset to use for the GOT_INDX'th got entry which is
296*56bb7041Schristos   // for global tls symbol GSYM.
297*56bb7041Schristos   int64_t
tls_offset_for_global(Symbol * gsym,unsigned int got_indx)298*56bb7041Schristos   tls_offset_for_global(Symbol* gsym, unsigned int got_indx) const
299*56bb7041Schristos   { return do_tls_offset_for_global(gsym, got_indx); }
300*56bb7041Schristos 
301*56bb7041Schristos   // For targets that use function descriptors, if LOC is the location
302*56bb7041Schristos   // of a function, modify it to point at the function entry location.
303*56bb7041Schristos   void
function_location(Symbol_location * loc)304*56bb7041Schristos   function_location(Symbol_location* loc) const
305*56bb7041Schristos   { return do_function_location(loc); }
306*56bb7041Schristos 
307*56bb7041Schristos   // Return whether this target can use relocation types to determine
308*56bb7041Schristos   // if a function's address is taken.
309*56bb7041Schristos   bool
can_check_for_function_pointers()310*56bb7041Schristos   can_check_for_function_pointers() const
311*56bb7041Schristos   { return this->do_can_check_for_function_pointers(); }
312*56bb7041Schristos 
313*56bb7041Schristos   // Return whether a relocation to a merged section can be processed
314*56bb7041Schristos   // to retrieve the contents.
315*56bb7041Schristos   bool
can_icf_inline_merge_sections()316*56bb7041Schristos   can_icf_inline_merge_sections () const
317*56bb7041Schristos   { return this->pti_->can_icf_inline_merge_sections; }
318*56bb7041Schristos 
319*56bb7041Schristos   // Whether a section called SECTION_NAME may have function pointers to
320*56bb7041Schristos   // sections not eligible for safe ICF folding.
321*56bb7041Schristos   virtual bool
section_may_have_icf_unsafe_pointers(const char * section_name)322*56bb7041Schristos   section_may_have_icf_unsafe_pointers(const char* section_name) const
323*56bb7041Schristos   { return this->do_section_may_have_icf_unsafe_pointers(section_name); }
324*56bb7041Schristos 
325*56bb7041Schristos   // Return the base to use for the PC value in an FDE when it is
326*56bb7041Schristos   // encoded using DW_EH_PE_datarel.  This does not appear to be
327*56bb7041Schristos   // documented anywhere, but it is target specific.  Any use of
328*56bb7041Schristos   // DW_EH_PE_datarel in gcc requires defining a special macro
329*56bb7041Schristos   // (ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX) to output the value.
330*56bb7041Schristos   uint64_t
ehframe_datarel_base()331*56bb7041Schristos   ehframe_datarel_base() const
332*56bb7041Schristos   { return this->do_ehframe_datarel_base(); }
333*56bb7041Schristos 
334*56bb7041Schristos   // Return true if a reference to SYM from a reloc at *PRELOC
335*56bb7041Schristos   // means that the current function may call an object compiled
336*56bb7041Schristos   // without -fsplit-stack.  SYM is known to be defined in an object
337*56bb7041Schristos   // compiled without -fsplit-stack.
338*56bb7041Schristos   bool
is_call_to_non_split(const Symbol * sym,const unsigned char * preloc,const unsigned char * view,section_size_type view_size)339*56bb7041Schristos   is_call_to_non_split(const Symbol* sym, const unsigned char* preloc,
340*56bb7041Schristos 		       const unsigned char* view,
341*56bb7041Schristos 		       section_size_type view_size) const
342*56bb7041Schristos   { return this->do_is_call_to_non_split(sym, preloc, view, view_size); }
343*56bb7041Schristos 
344*56bb7041Schristos   // A function starts at OFFSET in section SHNDX in OBJECT.  That
345*56bb7041Schristos   // function was compiled with -fsplit-stack, but it refers to a
346*56bb7041Schristos   // function which was compiled without -fsplit-stack.  VIEW is a
347*56bb7041Schristos   // modifiable view of the section; VIEW_SIZE is the size of the
348*56bb7041Schristos   // view.  The target has to adjust the function so that it allocates
349*56bb7041Schristos   // enough stack.
350*56bb7041Schristos   void
calls_non_split(Relobj * object,unsigned int shndx,section_offset_type fnoffset,section_size_type fnsize,const unsigned char * prelocs,size_t reloc_count,unsigned char * view,section_size_type view_size,std::string * from,std::string * to)351*56bb7041Schristos   calls_non_split(Relobj* object, unsigned int shndx,
352*56bb7041Schristos 		  section_offset_type fnoffset, section_size_type fnsize,
353*56bb7041Schristos 		  const unsigned char* prelocs, size_t reloc_count,
354*56bb7041Schristos 		  unsigned char* view, section_size_type view_size,
355*56bb7041Schristos 		  std::string* from, std::string* to) const
356*56bb7041Schristos   {
357*56bb7041Schristos     this->do_calls_non_split(object, shndx, fnoffset, fnsize,
358*56bb7041Schristos 			     prelocs, reloc_count, view, view_size,
359*56bb7041Schristos 			     from, to);
360*56bb7041Schristos   }
361*56bb7041Schristos 
362*56bb7041Schristos   // Make an ELF object.
363*56bb7041Schristos   template<int size, bool big_endian>
364*56bb7041Schristos   Object*
make_elf_object(const std::string & name,Input_file * input_file,off_t offset,const elfcpp::Ehdr<size,big_endian> & ehdr)365*56bb7041Schristos   make_elf_object(const std::string& name, Input_file* input_file,
366*56bb7041Schristos 		  off_t offset, const elfcpp::Ehdr<size, big_endian>& ehdr)
367*56bb7041Schristos   { return this->do_make_elf_object(name, input_file, offset, ehdr); }
368*56bb7041Schristos 
369*56bb7041Schristos   // Make an output section.
370*56bb7041Schristos   Output_section*
make_output_section(const char * name,elfcpp::Elf_Word type,elfcpp::Elf_Xword flags)371*56bb7041Schristos   make_output_section(const char* name, elfcpp::Elf_Word type,
372*56bb7041Schristos 		      elfcpp::Elf_Xword flags)
373*56bb7041Schristos   { return this->do_make_output_section(name, type, flags); }
374*56bb7041Schristos 
375*56bb7041Schristos   // Return true if target wants to perform relaxation.
376*56bb7041Schristos   bool
may_relax()377*56bb7041Schristos   may_relax() const
378*56bb7041Schristos   {
379*56bb7041Schristos     // Run the dummy relaxation pass twice if relaxation debugging is enabled.
380*56bb7041Schristos     if (is_debugging_enabled(DEBUG_RELAXATION))
381*56bb7041Schristos       return true;
382*56bb7041Schristos 
383*56bb7041Schristos      return this->do_may_relax();
384*56bb7041Schristos   }
385*56bb7041Schristos 
386*56bb7041Schristos   // Perform a relaxation pass.  Return true if layout may be changed.
387*56bb7041Schristos   bool
relax(int pass,const Input_objects * input_objects,Symbol_table * symtab,Layout * layout,const Task * task)388*56bb7041Schristos   relax(int pass, const Input_objects* input_objects, Symbol_table* symtab,
389*56bb7041Schristos 	Layout* layout, const Task* task)
390*56bb7041Schristos   {
391*56bb7041Schristos     // Run the dummy relaxation pass twice if relaxation debugging is enabled.
392*56bb7041Schristos     if (is_debugging_enabled(DEBUG_RELAXATION))
393*56bb7041Schristos       return pass < 2;
394*56bb7041Schristos 
395*56bb7041Schristos     return this->do_relax(pass, input_objects, symtab, layout, task);
396*56bb7041Schristos   }
397*56bb7041Schristos 
398*56bb7041Schristos   // Return the target-specific name of attributes section.  This is
399*56bb7041Schristos   // NULL if a target does not use attributes section or if it uses
400*56bb7041Schristos   // the default section name ".gnu.attributes".
401*56bb7041Schristos   const char*
attributes_section()402*56bb7041Schristos   attributes_section() const
403*56bb7041Schristos   { return this->pti_->attributes_section; }
404*56bb7041Schristos 
405*56bb7041Schristos   // Return the vendor name of vendor attributes.
406*56bb7041Schristos   const char*
attributes_vendor()407*56bb7041Schristos   attributes_vendor() const
408*56bb7041Schristos   { return this->pti_->attributes_vendor; }
409*56bb7041Schristos 
410*56bb7041Schristos   // Whether a section called NAME is an attribute section.
411*56bb7041Schristos   bool
is_attributes_section(const char * name)412*56bb7041Schristos   is_attributes_section(const char* name) const
413*56bb7041Schristos   {
414*56bb7041Schristos     return ((this->pti_->attributes_section != NULL
415*56bb7041Schristos 	     && strcmp(name, this->pti_->attributes_section) == 0)
416*56bb7041Schristos 	    || strcmp(name, ".gnu.attributes") == 0);
417*56bb7041Schristos   }
418*56bb7041Schristos 
419*56bb7041Schristos   // Return a bit mask of argument types for attribute with TAG.
420*56bb7041Schristos   int
attribute_arg_type(int tag)421*56bb7041Schristos   attribute_arg_type(int tag) const
422*56bb7041Schristos   { return this->do_attribute_arg_type(tag); }
423*56bb7041Schristos 
424*56bb7041Schristos   // Return the attribute tag of the position NUM in the list of fixed
425*56bb7041Schristos   // attributes.  Normally there is no reordering and
426*56bb7041Schristos   // attributes_order(NUM) == NUM.
427*56bb7041Schristos   int
attributes_order(int num)428*56bb7041Schristos   attributes_order(int num) const
429*56bb7041Schristos   { return this->do_attributes_order(num); }
430*56bb7041Schristos 
431*56bb7041Schristos   // When a target is selected as the default target, we call this method,
432*56bb7041Schristos   // which may be used for expensive, target-specific initialization.
433*56bb7041Schristos   void
select_as_default_target()434*56bb7041Schristos   select_as_default_target()
435*56bb7041Schristos   { this->do_select_as_default_target(); }
436*56bb7041Schristos 
437*56bb7041Schristos   // Return the value to store in the EI_OSABI field in the ELF
438*56bb7041Schristos   // header.
439*56bb7041Schristos   elfcpp::ELFOSABI
osabi()440*56bb7041Schristos   osabi() const
441*56bb7041Schristos   { return this->osabi_; }
442*56bb7041Schristos 
443*56bb7041Schristos   // Set the value to store in the EI_OSABI field in the ELF header.
444*56bb7041Schristos   void
set_osabi(elfcpp::ELFOSABI osabi)445*56bb7041Schristos   set_osabi(elfcpp::ELFOSABI osabi)
446*56bb7041Schristos   { this->osabi_ = osabi; }
447*56bb7041Schristos 
448*56bb7041Schristos   // Define target-specific standard symbols.
449*56bb7041Schristos   void
define_standard_symbols(Symbol_table * symtab,Layout * layout)450*56bb7041Schristos   define_standard_symbols(Symbol_table* symtab, Layout* layout)
451*56bb7041Schristos   { this->do_define_standard_symbols(symtab, layout); }
452*56bb7041Schristos 
453*56bb7041Schristos   // Return the output section name to use given an input section
454*56bb7041Schristos   // name, or NULL if no target specific name mapping is required.
455*56bb7041Schristos   // Set *PLEN to the length of the name if returning non-NULL.
456*56bb7041Schristos   const char*
output_section_name(const Relobj * relobj,const char * name,size_t * plen)457*56bb7041Schristos   output_section_name(const Relobj* relobj,
458*56bb7041Schristos 		      const char* name,
459*56bb7041Schristos 		      size_t* plen) const
460*56bb7041Schristos   { return this->do_output_section_name(relobj, name, plen); }
461*56bb7041Schristos 
462*56bb7041Schristos   // Add any special sections for this symbol to the gc work list.
463*56bb7041Schristos   void
gc_mark_symbol(Symbol_table * symtab,Symbol * sym)464*56bb7041Schristos   gc_mark_symbol(Symbol_table* symtab, Symbol* sym) const
465*56bb7041Schristos   { this->do_gc_mark_symbol(symtab, sym); }
466*56bb7041Schristos 
467*56bb7041Schristos   // Return the name of the entry point symbol.
468*56bb7041Schristos   const char*
entry_symbol_name()469*56bb7041Schristos   entry_symbol_name() const
470*56bb7041Schristos   { return this->pti_->entry_symbol_name; }
471*56bb7041Schristos 
472*56bb7041Schristos   // Return the size in bits of SHT_HASH entry.
473*56bb7041Schristos   int
hash_entry_size()474*56bb7041Schristos   hash_entry_size() const
475*56bb7041Schristos   { return this->pti_->hash_entry_size; }
476*56bb7041Schristos 
477*56bb7041Schristos   // Return the section type to use for unwind sections.
478*56bb7041Schristos   unsigned int
unwind_section_type()479*56bb7041Schristos   unwind_section_type() const
480*56bb7041Schristos   { return this->pti_->unwind_section_type; }
481*56bb7041Schristos 
482*56bb7041Schristos   // Whether the target has a custom set_dynsym_indexes method.
483*56bb7041Schristos   bool
has_custom_set_dynsym_indexes()484*56bb7041Schristos   has_custom_set_dynsym_indexes() const
485*56bb7041Schristos   { return this->do_has_custom_set_dynsym_indexes(); }
486*56bb7041Schristos 
487*56bb7041Schristos   // Custom set_dynsym_indexes method for a target.
488*56bb7041Schristos   unsigned int
set_dynsym_indexes(std::vector<Symbol * > * dyn_symbols,unsigned int index,std::vector<Symbol * > * syms,Stringpool * dynpool,Versions * versions,Symbol_table * symtab)489*56bb7041Schristos   set_dynsym_indexes(std::vector<Symbol*>* dyn_symbols, unsigned int index,
490*56bb7041Schristos                      std::vector<Symbol*>* syms, Stringpool* dynpool,
491*56bb7041Schristos                      Versions* versions, Symbol_table* symtab) const
492*56bb7041Schristos   {
493*56bb7041Schristos     return this->do_set_dynsym_indexes(dyn_symbols, index, syms, dynpool,
494*56bb7041Schristos                                        versions, symtab);
495*56bb7041Schristos   }
496*56bb7041Schristos 
497*56bb7041Schristos   // Get the custom dynamic tag value.
498*56bb7041Schristos   unsigned int
dynamic_tag_custom_value(elfcpp::DT tag)499*56bb7041Schristos   dynamic_tag_custom_value(elfcpp::DT tag) const
500*56bb7041Schristos   { return this->do_dynamic_tag_custom_value(tag); }
501*56bb7041Schristos 
502*56bb7041Schristos   // Adjust the value written to the dynamic symbol table.
503*56bb7041Schristos   void
adjust_dyn_symbol(const Symbol * sym,unsigned char * view)504*56bb7041Schristos   adjust_dyn_symbol(const Symbol* sym, unsigned char* view) const
505*56bb7041Schristos   { this->do_adjust_dyn_symbol(sym, view); }
506*56bb7041Schristos 
507*56bb7041Schristos   // Return whether to include the section in the link.
508*56bb7041Schristos   bool
should_include_section(elfcpp::Elf_Word sh_type)509*56bb7041Schristos   should_include_section(elfcpp::Elf_Word sh_type) const
510*56bb7041Schristos   { return this->do_should_include_section(sh_type); }
511*56bb7041Schristos 
512*56bb7041Schristos   // Finalize the target-specific properties in the .note.gnu.property section.
513*56bb7041Schristos   void
finalize_gnu_properties(Layout * layout)514*56bb7041Schristos   finalize_gnu_properties(Layout* layout) const
515*56bb7041Schristos   { this->do_finalize_gnu_properties(layout); }
516*56bb7041Schristos 
517*56bb7041Schristos  protected:
518*56bb7041Schristos   // This struct holds the constant information for a child class.  We
519*56bb7041Schristos   // use a struct to avoid the overhead of virtual function calls for
520*56bb7041Schristos   // simple information.
521*56bb7041Schristos   struct Target_info
522*56bb7041Schristos   {
523*56bb7041Schristos     // Address size (32 or 64).
524*56bb7041Schristos     int size;
525*56bb7041Schristos     // Whether the target is big endian.
526*56bb7041Schristos     bool is_big_endian;
527*56bb7041Schristos     // The code to store in the e_machine field of the ELF header.
528*56bb7041Schristos     elfcpp::EM machine_code;
529*56bb7041Schristos     // Whether this target has a specific make_symbol function.
530*56bb7041Schristos     bool has_make_symbol;
531*56bb7041Schristos     // Whether this target has a specific resolve function.
532*56bb7041Schristos     bool has_resolve;
533*56bb7041Schristos     // Whether this target has a specific code fill function.
534*56bb7041Schristos     bool has_code_fill;
535*56bb7041Schristos     // Whether an object file with no .note.GNU-stack sections implies
536*56bb7041Schristos     // that the stack should be executable.
537*56bb7041Schristos     bool is_default_stack_executable;
538*56bb7041Schristos     // Whether a relocation to a merged section can be processed to
539*56bb7041Schristos     // retrieve the contents.
540*56bb7041Schristos     bool can_icf_inline_merge_sections;
541*56bb7041Schristos     // Prefix character to strip when checking for wrapping.
542*56bb7041Schristos     char wrap_char;
543*56bb7041Schristos     // The default dynamic linker name.
544*56bb7041Schristos     const char* dynamic_linker;
545*56bb7041Schristos     // The default text segment address.
546*56bb7041Schristos     uint64_t default_text_segment_address;
547*56bb7041Schristos     // The ABI specified page size.
548*56bb7041Schristos     uint64_t abi_pagesize;
549*56bb7041Schristos     // The common page size used by actual implementations.
550*56bb7041Schristos     uint64_t common_pagesize;
551*56bb7041Schristos     // Whether PF_X segments must contain nothing but the contents of
552*56bb7041Schristos     // SHF_EXECINSTR sections (no non-executable data, no headers).
553*56bb7041Schristos     bool isolate_execinstr;
554*56bb7041Schristos     // If nonzero, distance from the text segment to the read-only segment.
555*56bb7041Schristos     uint64_t rosegment_gap;
556*56bb7041Schristos     // The special section index for small common symbols; SHN_UNDEF
557*56bb7041Schristos     // if none.
558*56bb7041Schristos     elfcpp::Elf_Half small_common_shndx;
559*56bb7041Schristos     // The special section index for large common symbols; SHN_UNDEF
560*56bb7041Schristos     // if none.
561*56bb7041Schristos     elfcpp::Elf_Half large_common_shndx;
562*56bb7041Schristos     // Section flags for small common section.
563*56bb7041Schristos     elfcpp::Elf_Xword small_common_section_flags;
564*56bb7041Schristos     // Section flags for large common section.
565*56bb7041Schristos     elfcpp::Elf_Xword large_common_section_flags;
566*56bb7041Schristos     // Name of attributes section if it is not ".gnu.attributes".
567*56bb7041Schristos     const char* attributes_section;
568*56bb7041Schristos     // Vendor name of vendor attributes.
569*56bb7041Schristos     const char* attributes_vendor;
570*56bb7041Schristos     // Name of the main entry point to the program.
571*56bb7041Schristos     const char* entry_symbol_name;
572*56bb7041Schristos     // Size (in bits) of SHT_HASH entry. Always equal to 32, except for
573*56bb7041Schristos     // 64-bit S/390.
574*56bb7041Schristos     const int hash_entry_size;
575*56bb7041Schristos     // Processor-specific section type for ".eh_frame" (unwind) sections.
576*56bb7041Schristos     // SHT_PROGBITS if there is no special section type.
577*56bb7041Schristos     const unsigned int unwind_section_type;
578*56bb7041Schristos   };
579*56bb7041Schristos 
Target(const Target_info * pti)580*56bb7041Schristos   Target(const Target_info* pti)
581*56bb7041Schristos     : pti_(pti), processor_specific_flags_(0),
582*56bb7041Schristos       are_processor_specific_flags_set_(false), osabi_(elfcpp::ELFOSABI_NONE)
583*56bb7041Schristos   { }
584*56bb7041Schristos 
585*56bb7041Schristos   // Virtual function which may be implemented by the child class.
586*56bb7041Schristos   virtual void
do_new_output_section(Output_section *)587*56bb7041Schristos   do_new_output_section(Output_section*) const
588*56bb7041Schristos   { }
589*56bb7041Schristos 
590*56bb7041Schristos   // Virtual function which may be implemented by the child class.
591*56bb7041Schristos   virtual void
do_finalize_sections(Layout *,const Input_objects *,Symbol_table *)592*56bb7041Schristos   do_finalize_sections(Layout*, const Input_objects*, Symbol_table*)
593*56bb7041Schristos   { }
594*56bb7041Schristos 
595*56bb7041Schristos   // Virtual function which may be implemented by the child class.
596*56bb7041Schristos   virtual uint64_t
do_dynsym_value(const Symbol *)597*56bb7041Schristos   do_dynsym_value(const Symbol*) const
598*56bb7041Schristos   { gold_unreachable(); }
599*56bb7041Schristos 
600*56bb7041Schristos   // Virtual function which must be implemented by the child class if
601*56bb7041Schristos   // needed.
602*56bb7041Schristos   virtual std::string
do_code_fill(section_size_type)603*56bb7041Schristos   do_code_fill(section_size_type) const
604*56bb7041Schristos   { gold_unreachable(); }
605*56bb7041Schristos 
606*56bb7041Schristos   // Virtual function which may be implemented by the child class.
607*56bb7041Schristos   virtual bool
do_is_defined_by_abi(const Symbol *)608*56bb7041Schristos   do_is_defined_by_abi(const Symbol*) const
609*56bb7041Schristos   { return false; }
610*56bb7041Schristos 
611*56bb7041Schristos   // Adjust the output file header before it is written out.  VIEW
612*56bb7041Schristos   // points to the header in external form.  LEN is the length, and
613*56bb7041Schristos   // will be one of the values of elfcpp::Elf_sizes<size>::ehdr_size.
614*56bb7041Schristos   // By default, we set the EI_OSABI field if requested (in
615*56bb7041Schristos   // Sized_target).
616*56bb7041Schristos   virtual void
617*56bb7041Schristos   do_adjust_elf_header(unsigned char*, int) = 0;
618*56bb7041Schristos 
619*56bb7041Schristos   // Return address and size to plug into eh_frame FDEs associated with a PLT.
620*56bb7041Schristos   virtual void
621*56bb7041Schristos   do_plt_fde_location(const Output_data* plt, unsigned char* oview,
622*56bb7041Schristos 		      uint64_t* address, off_t* len) const;
623*56bb7041Schristos 
624*56bb7041Schristos   // Virtual function which may be overridden by the child class.
625*56bb7041Schristos   virtual bool
626*56bb7041Schristos   do_is_local_label_name(const char*) const;
627*56bb7041Schristos 
628*56bb7041Schristos   // Virtual function that must be overridden by a target which uses
629*56bb7041Schristos   // target specific relocations.
630*56bb7041Schristos   virtual unsigned int
do_reloc_symbol_index(void *,unsigned int)631*56bb7041Schristos   do_reloc_symbol_index(void*, unsigned int) const
632*56bb7041Schristos   { gold_unreachable(); }
633*56bb7041Schristos 
634*56bb7041Schristos   // Virtual function that must be overridden by a target which uses
635*56bb7041Schristos   // target specific relocations.
636*56bb7041Schristos   virtual uint64_t
do_reloc_addend(void *,unsigned int,uint64_t)637*56bb7041Schristos   do_reloc_addend(void*, unsigned int, uint64_t) const
638*56bb7041Schristos   { gold_unreachable(); }
639*56bb7041Schristos 
640*56bb7041Schristos   // Virtual functions that must be overridden by a target that uses
641*56bb7041Schristos   // STT_GNU_IFUNC symbols.
642*56bb7041Schristos   virtual uint64_t
do_plt_address_for_global(const Symbol *)643*56bb7041Schristos   do_plt_address_for_global(const Symbol*) const
644*56bb7041Schristos   { gold_unreachable(); }
645*56bb7041Schristos 
646*56bb7041Schristos   virtual uint64_t
do_plt_address_for_local(const Relobj *,unsigned int)647*56bb7041Schristos   do_plt_address_for_local(const Relobj*, unsigned int) const
648*56bb7041Schristos   { gold_unreachable(); }
649*56bb7041Schristos 
650*56bb7041Schristos   virtual int64_t
do_tls_offset_for_local(const Relobj *,unsigned int,unsigned int)651*56bb7041Schristos   do_tls_offset_for_local(const Relobj*, unsigned int, unsigned int) const
652*56bb7041Schristos   { gold_unreachable(); }
653*56bb7041Schristos 
654*56bb7041Schristos   virtual int64_t
do_tls_offset_for_global(Symbol *,unsigned int)655*56bb7041Schristos   do_tls_offset_for_global(Symbol*, unsigned int) const
656*56bb7041Schristos   { gold_unreachable(); }
657*56bb7041Schristos 
658*56bb7041Schristos   virtual void
659*56bb7041Schristos   do_function_location(Symbol_location*) const = 0;
660*56bb7041Schristos 
661*56bb7041Schristos   // Virtual function which may be overriden by the child class.
662*56bb7041Schristos   virtual bool
do_can_check_for_function_pointers()663*56bb7041Schristos   do_can_check_for_function_pointers() const
664*56bb7041Schristos   { return false; }
665*56bb7041Schristos 
666*56bb7041Schristos   // Virtual function which may be overridden by the child class.  We
667*56bb7041Schristos   // recognize some default sections for which we don't care whether
668*56bb7041Schristos   // they have function pointers.
669*56bb7041Schristos   virtual bool
do_section_may_have_icf_unsafe_pointers(const char * section_name)670*56bb7041Schristos   do_section_may_have_icf_unsafe_pointers(const char* section_name) const
671*56bb7041Schristos   {
672*56bb7041Schristos     // We recognize sections for normal vtables, construction vtables and
673*56bb7041Schristos     // EH frames.
674*56bb7041Schristos     return (!is_prefix_of(".rodata._ZTV", section_name)
675*56bb7041Schristos 	    && !is_prefix_of(".data.rel.ro._ZTV", section_name)
676*56bb7041Schristos 	    && !is_prefix_of(".rodata._ZTC", section_name)
677*56bb7041Schristos 	    && !is_prefix_of(".data.rel.ro._ZTC", section_name)
678*56bb7041Schristos 	    && !is_prefix_of(".eh_frame", section_name));
679*56bb7041Schristos   }
680*56bb7041Schristos 
681*56bb7041Schristos   virtual uint64_t
do_ehframe_datarel_base()682*56bb7041Schristos   do_ehframe_datarel_base() const
683*56bb7041Schristos   { gold_unreachable(); }
684*56bb7041Schristos 
685*56bb7041Schristos   // Virtual function which may be overridden by the child class.  The
686*56bb7041Schristos   // default implementation is that any function not defined by the
687*56bb7041Schristos   // ABI is a call to a non-split function.
688*56bb7041Schristos   virtual bool
689*56bb7041Schristos   do_is_call_to_non_split(const Symbol* sym, const unsigned char*,
690*56bb7041Schristos 			  const unsigned char*, section_size_type) const;
691*56bb7041Schristos 
692*56bb7041Schristos   // Virtual function which may be overridden by the child class.
693*56bb7041Schristos   virtual void
694*56bb7041Schristos   do_calls_non_split(Relobj* object, unsigned int, section_offset_type,
695*56bb7041Schristos 		     section_size_type, const unsigned char*, size_t,
696*56bb7041Schristos 		     unsigned char*, section_size_type,
697*56bb7041Schristos 		     std::string*, std::string*) const;
698*56bb7041Schristos 
699*56bb7041Schristos   // make_elf_object hooks.  There are four versions of these for
700*56bb7041Schristos   // different address sizes and endianness.
701*56bb7041Schristos 
702*56bb7041Schristos   // Set processor specific flags.
703*56bb7041Schristos   void
set_processor_specific_flags(elfcpp::Elf_Word flags)704*56bb7041Schristos   set_processor_specific_flags(elfcpp::Elf_Word flags)
705*56bb7041Schristos   {
706*56bb7041Schristos     this->processor_specific_flags_ = flags;
707*56bb7041Schristos     this->are_processor_specific_flags_set_ = true;
708*56bb7041Schristos   }
709*56bb7041Schristos 
710*56bb7041Schristos #ifdef HAVE_TARGET_32_LITTLE
711*56bb7041Schristos   // Virtual functions which may be overridden by the child class.
712*56bb7041Schristos   virtual Object*
713*56bb7041Schristos   do_make_elf_object(const std::string&, Input_file*, off_t,
714*56bb7041Schristos 		     const elfcpp::Ehdr<32, false>&);
715*56bb7041Schristos #endif
716*56bb7041Schristos 
717*56bb7041Schristos #ifdef HAVE_TARGET_32_BIG
718*56bb7041Schristos   // Virtual functions which may be overridden by the child class.
719*56bb7041Schristos   virtual Object*
720*56bb7041Schristos   do_make_elf_object(const std::string&, Input_file*, off_t,
721*56bb7041Schristos 		     const elfcpp::Ehdr<32, true>&);
722*56bb7041Schristos #endif
723*56bb7041Schristos 
724*56bb7041Schristos #ifdef HAVE_TARGET_64_LITTLE
725*56bb7041Schristos   // Virtual functions which may be overridden by the child class.
726*56bb7041Schristos   virtual Object*
727*56bb7041Schristos   do_make_elf_object(const std::string&, Input_file*, off_t,
728*56bb7041Schristos 		     const elfcpp::Ehdr<64, false>& ehdr);
729*56bb7041Schristos #endif
730*56bb7041Schristos 
731*56bb7041Schristos #ifdef HAVE_TARGET_64_BIG
732*56bb7041Schristos   // Virtual functions which may be overridden by the child class.
733*56bb7041Schristos   virtual Object*
734*56bb7041Schristos   do_make_elf_object(const std::string& name, Input_file* input_file,
735*56bb7041Schristos 		     off_t offset, const elfcpp::Ehdr<64, true>& ehdr);
736*56bb7041Schristos #endif
737*56bb7041Schristos 
738*56bb7041Schristos   // Virtual functions which may be overridden by the child class.
739*56bb7041Schristos   virtual Output_section*
740*56bb7041Schristos   do_make_output_section(const char* name, elfcpp::Elf_Word type,
741*56bb7041Schristos 			 elfcpp::Elf_Xword flags);
742*56bb7041Schristos 
743*56bb7041Schristos   // Virtual function which may be overridden by the child class.
744*56bb7041Schristos   virtual bool
do_may_relax()745*56bb7041Schristos   do_may_relax() const
746*56bb7041Schristos   { return parameters->options().relax(); }
747*56bb7041Schristos 
748*56bb7041Schristos   // Virtual function which may be overridden by the child class.
749*56bb7041Schristos   virtual bool
do_relax(int,const Input_objects *,Symbol_table *,Layout *,const Task *)750*56bb7041Schristos   do_relax(int, const Input_objects*, Symbol_table*, Layout*, const Task*)
751*56bb7041Schristos   { return false; }
752*56bb7041Schristos 
753*56bb7041Schristos   // A function for targets to call.  Return whether BYTES/LEN matches
754*56bb7041Schristos   // VIEW/VIEW_SIZE at OFFSET.
755*56bb7041Schristos   bool
756*56bb7041Schristos   match_view(const unsigned char* view, section_size_type view_size,
757*56bb7041Schristos 	     section_offset_type offset, const char* bytes, size_t len) const;
758*56bb7041Schristos 
759*56bb7041Schristos   // Set the contents of a VIEW/VIEW_SIZE to nops starting at OFFSET
760*56bb7041Schristos   // for LEN bytes.
761*56bb7041Schristos   void
762*56bb7041Schristos   set_view_to_nop(unsigned char* view, section_size_type view_size,
763*56bb7041Schristos 		  section_offset_type offset, size_t len) const;
764*56bb7041Schristos 
765*56bb7041Schristos   // This must be overridden by the child class if it has target-specific
766*56bb7041Schristos   // attributes subsection in the attribute section.
767*56bb7041Schristos   virtual int
do_attribute_arg_type(int)768*56bb7041Schristos   do_attribute_arg_type(int) const
769*56bb7041Schristos   { gold_unreachable(); }
770*56bb7041Schristos 
771*56bb7041Schristos   // This may be overridden by the child class.
772*56bb7041Schristos   virtual int
do_attributes_order(int num)773*56bb7041Schristos   do_attributes_order(int num) const
774*56bb7041Schristos   { return num; }
775*56bb7041Schristos 
776*56bb7041Schristos   // This may be overridden by the child class.
777*56bb7041Schristos   virtual void
do_select_as_default_target()778*56bb7041Schristos   do_select_as_default_target()
779*56bb7041Schristos   { }
780*56bb7041Schristos 
781*56bb7041Schristos   // This may be overridden by the child class.
782*56bb7041Schristos   virtual void
do_define_standard_symbols(Symbol_table *,Layout *)783*56bb7041Schristos   do_define_standard_symbols(Symbol_table*, Layout*)
784*56bb7041Schristos   { }
785*56bb7041Schristos 
786*56bb7041Schristos   // This may be overridden by the child class.
787*56bb7041Schristos   virtual const char*
do_output_section_name(const Relobj *,const char *,size_t *)788*56bb7041Schristos   do_output_section_name(const Relobj*, const char*, size_t*) const
789*56bb7041Schristos   { return NULL; }
790*56bb7041Schristos 
791*56bb7041Schristos   // This may be overridden by the child class.
792*56bb7041Schristos   virtual void
do_gc_mark_symbol(Symbol_table *,Symbol *)793*56bb7041Schristos   do_gc_mark_symbol(Symbol_table*, Symbol*) const
794*56bb7041Schristos   { }
795*56bb7041Schristos 
796*56bb7041Schristos   // This may be overridden by the child class.
797*56bb7041Schristos   virtual bool
do_has_custom_set_dynsym_indexes()798*56bb7041Schristos   do_has_custom_set_dynsym_indexes() const
799*56bb7041Schristos   { return false; }
800*56bb7041Schristos 
801*56bb7041Schristos   // This may be overridden by the child class.
802*56bb7041Schristos   virtual unsigned int
do_set_dynsym_indexes(std::vector<Symbol * > *,unsigned int,std::vector<Symbol * > *,Stringpool *,Versions *,Symbol_table *)803*56bb7041Schristos   do_set_dynsym_indexes(std::vector<Symbol*>*, unsigned int,
804*56bb7041Schristos                         std::vector<Symbol*>*, Stringpool*, Versions*,
805*56bb7041Schristos                         Symbol_table*) const
806*56bb7041Schristos   { gold_unreachable(); }
807*56bb7041Schristos 
808*56bb7041Schristos   // This may be overridden by the child class.
809*56bb7041Schristos   virtual unsigned int
do_dynamic_tag_custom_value(elfcpp::DT)810*56bb7041Schristos   do_dynamic_tag_custom_value(elfcpp::DT) const
811*56bb7041Schristos   { gold_unreachable(); }
812*56bb7041Schristos 
813*56bb7041Schristos   // This may be overridden by the child class.
814*56bb7041Schristos   virtual void
do_adjust_dyn_symbol(const Symbol *,unsigned char *)815*56bb7041Schristos   do_adjust_dyn_symbol(const Symbol*, unsigned char*) const
816*56bb7041Schristos   { }
817*56bb7041Schristos 
818*56bb7041Schristos   // This may be overridden by the child class.
819*56bb7041Schristos   virtual bool
do_should_include_section(elfcpp::Elf_Word)820*56bb7041Schristos   do_should_include_section(elfcpp::Elf_Word) const
821*56bb7041Schristos   { return true; }
822*56bb7041Schristos 
823*56bb7041Schristos   // Finalize the target-specific properties in the .note.gnu.property section.
824*56bb7041Schristos   virtual void
do_finalize_gnu_properties(Layout *)825*56bb7041Schristos   do_finalize_gnu_properties(Layout*) const
826*56bb7041Schristos   { }
827*56bb7041Schristos 
828*56bb7041Schristos  private:
829*56bb7041Schristos   // The implementations of the four do_make_elf_object virtual functions are
830*56bb7041Schristos   // almost identical except for their sizes and endianness.  We use a template.
831*56bb7041Schristos   // for their implementations.
832*56bb7041Schristos   template<int size, bool big_endian>
833*56bb7041Schristos   inline Object*
834*56bb7041Schristos   do_make_elf_object_implementation(const std::string&, Input_file*, off_t,
835*56bb7041Schristos 				    const elfcpp::Ehdr<size, big_endian>&);
836*56bb7041Schristos 
837*56bb7041Schristos   Target(const Target&);
838*56bb7041Schristos   Target& operator=(const Target&);
839*56bb7041Schristos 
840*56bb7041Schristos   // The target information.
841*56bb7041Schristos   const Target_info* pti_;
842*56bb7041Schristos   // Processor-specific flags.
843*56bb7041Schristos   elfcpp::Elf_Word processor_specific_flags_;
844*56bb7041Schristos   // Whether the processor-specific flags are set at least once.
845*56bb7041Schristos   bool are_processor_specific_flags_set_;
846*56bb7041Schristos   // If not ELFOSABI_NONE, the value to put in the EI_OSABI field of
847*56bb7041Schristos   // the ELF header.  This is handled at this level because it is
848*56bb7041Schristos   // OS-specific rather than processor-specific.
849*56bb7041Schristos   elfcpp::ELFOSABI osabi_;
850*56bb7041Schristos };
851*56bb7041Schristos 
852*56bb7041Schristos // The abstract class for a specific size and endianness of target.
853*56bb7041Schristos // Each actual target implementation class should derive from an
854*56bb7041Schristos // instantiation of Sized_target.
855*56bb7041Schristos 
856*56bb7041Schristos template<int size, bool big_endian>
857*56bb7041Schristos class Sized_target : public Target
858*56bb7041Schristos {
859*56bb7041Schristos  public:
860*56bb7041Schristos   // Make a new symbol table entry for the target.  This should be
861*56bb7041Schristos   // overridden by a target which needs additional information in the
862*56bb7041Schristos   // symbol table.  This will only be called if has_make_symbol()
863*56bb7041Schristos   // returns true.
864*56bb7041Schristos   virtual Sized_symbol<size>*
make_symbol(const char *,elfcpp::STT,Object *,unsigned int,uint64_t)865*56bb7041Schristos   make_symbol(const char*, elfcpp::STT, Object*, unsigned int, uint64_t)
866*56bb7041Schristos   { gold_unreachable(); }
867*56bb7041Schristos 
868*56bb7041Schristos   // Resolve a symbol for the target.  This should be overridden by a
869*56bb7041Schristos   // target which needs to take special action.  TO is the
870*56bb7041Schristos   // pre-existing symbol.  SYM is the new symbol, seen in OBJECT.
871*56bb7041Schristos   // VERSION is the version of SYM.  This will only be called if
872*56bb7041Schristos   // has_resolve() returns true.
873*56bb7041Schristos   virtual bool
resolve(Symbol *,const elfcpp::Sym<size,big_endian> &,Object *,const char *)874*56bb7041Schristos   resolve(Symbol*, const elfcpp::Sym<size, big_endian>&, Object*,
875*56bb7041Schristos 	  const char*)
876*56bb7041Schristos   { gold_unreachable(); }
877*56bb7041Schristos 
878*56bb7041Schristos   // Process the relocs for a section, and record information of the
879*56bb7041Schristos   // mapping from source to destination sections. This mapping is later
880*56bb7041Schristos   // used to determine unreferenced garbage sections. This procedure is
881*56bb7041Schristos   // only called during garbage collection.
882*56bb7041Schristos   virtual void
883*56bb7041Schristos   gc_process_relocs(Symbol_table* symtab,
884*56bb7041Schristos 		    Layout* layout,
885*56bb7041Schristos 		    Sized_relobj_file<size, big_endian>* object,
886*56bb7041Schristos 		    unsigned int data_shndx,
887*56bb7041Schristos 		    unsigned int sh_type,
888*56bb7041Schristos 		    const unsigned char* prelocs,
889*56bb7041Schristos 		    size_t reloc_count,
890*56bb7041Schristos 		    Output_section* output_section,
891*56bb7041Schristos 		    bool needs_special_offset_handling,
892*56bb7041Schristos 		    size_t local_symbol_count,
893*56bb7041Schristos 		    const unsigned char* plocal_symbols) = 0;
894*56bb7041Schristos 
895*56bb7041Schristos   // Scan the relocs for a section, and record any information
896*56bb7041Schristos   // required for the symbol.  SYMTAB is the symbol table.  OBJECT is
897*56bb7041Schristos   // the object in which the section appears.  DATA_SHNDX is the
898*56bb7041Schristos   // section index that these relocs apply to.  SH_TYPE is the type of
899*56bb7041Schristos   // the relocation section, SHT_REL or SHT_RELA.  PRELOCS points to
900*56bb7041Schristos   // the relocation data.  RELOC_COUNT is the number of relocs.
901*56bb7041Schristos   // LOCAL_SYMBOL_COUNT is the number of local symbols.
902*56bb7041Schristos   // OUTPUT_SECTION is the output section.
903*56bb7041Schristos   // NEEDS_SPECIAL_OFFSET_HANDLING is true if offsets to the output
904*56bb7041Schristos   // sections are not mapped as usual.  PLOCAL_SYMBOLS points to the
905*56bb7041Schristos   // local symbol data from OBJECT.  GLOBAL_SYMBOLS is the array of
906*56bb7041Schristos   // pointers to the global symbol table from OBJECT.
907*56bb7041Schristos   virtual void
908*56bb7041Schristos   scan_relocs(Symbol_table* symtab,
909*56bb7041Schristos 	      Layout* layout,
910*56bb7041Schristos 	      Sized_relobj_file<size, big_endian>* object,
911*56bb7041Schristos 	      unsigned int data_shndx,
912*56bb7041Schristos 	      unsigned int sh_type,
913*56bb7041Schristos 	      const unsigned char* prelocs,
914*56bb7041Schristos 	      size_t reloc_count,
915*56bb7041Schristos 	      Output_section* output_section,
916*56bb7041Schristos 	      bool needs_special_offset_handling,
917*56bb7041Schristos 	      size_t local_symbol_count,
918*56bb7041Schristos 	      const unsigned char* plocal_symbols) = 0;
919*56bb7041Schristos 
920*56bb7041Schristos   // Relocate section data.  SH_TYPE is the type of the relocation
921*56bb7041Schristos   // section, SHT_REL or SHT_RELA.  PRELOCS points to the relocation
922*56bb7041Schristos   // information.  RELOC_COUNT is the number of relocs.
923*56bb7041Schristos   // OUTPUT_SECTION is the output section.
924*56bb7041Schristos   // NEEDS_SPECIAL_OFFSET_HANDLING is true if offsets must be mapped
925*56bb7041Schristos   // to correspond to the output section.  VIEW is a view into the
926*56bb7041Schristos   // output file holding the section contents, VIEW_ADDRESS is the
927*56bb7041Schristos   // virtual address of the view, and VIEW_SIZE is the size of the
928*56bb7041Schristos   // view.  If NEEDS_SPECIAL_OFFSET_HANDLING is true, the VIEW_xx
929*56bb7041Schristos   // parameters refer to the complete output section data, not just
930*56bb7041Schristos   // the input section data.
931*56bb7041Schristos   virtual void
932*56bb7041Schristos   relocate_section(const Relocate_info<size, big_endian>*,
933*56bb7041Schristos 		   unsigned int sh_type,
934*56bb7041Schristos 		   const unsigned char* prelocs,
935*56bb7041Schristos 		   size_t reloc_count,
936*56bb7041Schristos 		   Output_section* output_section,
937*56bb7041Schristos 		   bool needs_special_offset_handling,
938*56bb7041Schristos 		   unsigned char* view,
939*56bb7041Schristos 		   typename elfcpp::Elf_types<size>::Elf_Addr view_address,
940*56bb7041Schristos 		   section_size_type view_size,
941*56bb7041Schristos 		   const Reloc_symbol_changes*) = 0;
942*56bb7041Schristos 
943*56bb7041Schristos   // Scan the relocs during a relocatable link.  The parameters are
944*56bb7041Schristos   // like scan_relocs, with an additional Relocatable_relocs
945*56bb7041Schristos   // parameter, used to record the disposition of the relocs.
946*56bb7041Schristos   virtual void
947*56bb7041Schristos   scan_relocatable_relocs(Symbol_table* symtab,
948*56bb7041Schristos 			  Layout* layout,
949*56bb7041Schristos 			  Sized_relobj_file<size, big_endian>* object,
950*56bb7041Schristos 			  unsigned int data_shndx,
951*56bb7041Schristos 			  unsigned int sh_type,
952*56bb7041Schristos 			  const unsigned char* prelocs,
953*56bb7041Schristos 			  size_t reloc_count,
954*56bb7041Schristos 			  Output_section* output_section,
955*56bb7041Schristos 			  bool needs_special_offset_handling,
956*56bb7041Schristos 			  size_t local_symbol_count,
957*56bb7041Schristos 			  const unsigned char* plocal_symbols,
958*56bb7041Schristos 			  Relocatable_relocs*) = 0;
959*56bb7041Schristos 
960*56bb7041Schristos   // Scan the relocs for --emit-relocs.  The parameters are
961*56bb7041Schristos   // like scan_relocatable_relocs.
962*56bb7041Schristos   virtual void
963*56bb7041Schristos   emit_relocs_scan(Symbol_table* symtab,
964*56bb7041Schristos 		   Layout* layout,
965*56bb7041Schristos 		   Sized_relobj_file<size, big_endian>* object,
966*56bb7041Schristos 		   unsigned int data_shndx,
967*56bb7041Schristos 		   unsigned int sh_type,
968*56bb7041Schristos 		   const unsigned char* prelocs,
969*56bb7041Schristos 		   size_t reloc_count,
970*56bb7041Schristos 		   Output_section* output_section,
971*56bb7041Schristos 		   bool needs_special_offset_handling,
972*56bb7041Schristos 		   size_t local_symbol_count,
973*56bb7041Schristos 		   const unsigned char* plocal_syms,
974*56bb7041Schristos 		   Relocatable_relocs* rr) = 0;
975*56bb7041Schristos 
976*56bb7041Schristos   // Emit relocations for a section during a relocatable link, and for
977*56bb7041Schristos   // --emit-relocs.  The parameters are like relocate_section, with
978*56bb7041Schristos   // additional parameters for the view of the output reloc section.
979*56bb7041Schristos   virtual void
980*56bb7041Schristos   relocate_relocs(const Relocate_info<size, big_endian>*,
981*56bb7041Schristos 		  unsigned int sh_type,
982*56bb7041Schristos 		  const unsigned char* prelocs,
983*56bb7041Schristos 		  size_t reloc_count,
984*56bb7041Schristos 		  Output_section* output_section,
985*56bb7041Schristos 		  typename elfcpp::Elf_types<size>::Elf_Off
986*56bb7041Schristos                     offset_in_output_section,
987*56bb7041Schristos 		  unsigned char* view,
988*56bb7041Schristos 		  typename elfcpp::Elf_types<size>::Elf_Addr view_address,
989*56bb7041Schristos 		  section_size_type view_size,
990*56bb7041Schristos 		  unsigned char* reloc_view,
991*56bb7041Schristos 		  section_size_type reloc_view_size) = 0;
992*56bb7041Schristos 
993*56bb7041Schristos   // Perform target-specific processing in a relocatable link.  This is
994*56bb7041Schristos   // only used if we use the relocation strategy RELOC_SPECIAL.
995*56bb7041Schristos   // RELINFO points to a Relocation_info structure. SH_TYPE is the relocation
996*56bb7041Schristos   // section type. PRELOC_IN points to the original relocation.  RELNUM is
997*56bb7041Schristos   // the index number of the relocation in the relocation section.
998*56bb7041Schristos   // OUTPUT_SECTION is the output section to which the relocation is applied.
999*56bb7041Schristos   // OFFSET_IN_OUTPUT_SECTION is the offset of the relocation input section
1000*56bb7041Schristos   // within the output section.  VIEW points to the output view of the
1001*56bb7041Schristos   // output section.  VIEW_ADDRESS is output address of the view.  VIEW_SIZE
1002*56bb7041Schristos   // is the size of the output view and PRELOC_OUT points to the new
1003*56bb7041Schristos   // relocation in the output object.
1004*56bb7041Schristos   //
1005*56bb7041Schristos   // A target only needs to override this if the generic code in
1006*56bb7041Schristos   // target-reloc.h cannot handle some relocation types.
1007*56bb7041Schristos 
1008*56bb7041Schristos   virtual void
relocate_special_relocatable(const Relocate_info<size,big_endian> *,unsigned int,const unsigned char *,size_t,Output_section *,typename elfcpp::Elf_types<size>::Elf_Off,unsigned char *,typename elfcpp::Elf_types<size>::Elf_Addr,section_size_type,unsigned char *)1009*56bb7041Schristos   relocate_special_relocatable(const Relocate_info<size, big_endian>*
1010*56bb7041Schristos 				/*relinfo */,
1011*56bb7041Schristos 			       unsigned int /* sh_type */,
1012*56bb7041Schristos 			       const unsigned char* /* preloc_in */,
1013*56bb7041Schristos 			       size_t /* relnum */,
1014*56bb7041Schristos 			       Output_section* /* output_section */,
1015*56bb7041Schristos 			       typename elfcpp::Elf_types<size>::Elf_Off
1016*56bb7041Schristos                                  /* offset_in_output_section */,
1017*56bb7041Schristos 			       unsigned char* /* view */,
1018*56bb7041Schristos 			       typename elfcpp::Elf_types<size>::Elf_Addr
1019*56bb7041Schristos 				 /* view_address */,
1020*56bb7041Schristos 			       section_size_type /* view_size */,
1021*56bb7041Schristos 			       unsigned char* /* preloc_out*/)
1022*56bb7041Schristos   { gold_unreachable(); }
1023*56bb7041Schristos 
1024*56bb7041Schristos   // Return the number of entries in the GOT.  This is only used for
1025*56bb7041Schristos   // laying out the incremental link info sections.  A target needs
1026*56bb7041Schristos   // to implement this to support incremental linking.
1027*56bb7041Schristos 
1028*56bb7041Schristos   virtual unsigned int
got_entry_count()1029*56bb7041Schristos   got_entry_count() const
1030*56bb7041Schristos   { gold_unreachable(); }
1031*56bb7041Schristos 
1032*56bb7041Schristos   // Return the number of entries in the PLT.  This is only used for
1033*56bb7041Schristos   // laying out the incremental link info sections.  A target needs
1034*56bb7041Schristos   // to implement this to support incremental linking.
1035*56bb7041Schristos 
1036*56bb7041Schristos   virtual unsigned int
plt_entry_count()1037*56bb7041Schristos   plt_entry_count() const
1038*56bb7041Schristos   { gold_unreachable(); }
1039*56bb7041Schristos 
1040*56bb7041Schristos   // Return the offset of the first non-reserved PLT entry.  This is
1041*56bb7041Schristos   // only used for laying out the incremental link info sections.
1042*56bb7041Schristos   // A target needs to implement this to support incremental linking.
1043*56bb7041Schristos 
1044*56bb7041Schristos   virtual unsigned int
first_plt_entry_offset()1045*56bb7041Schristos   first_plt_entry_offset() const
1046*56bb7041Schristos   { gold_unreachable(); }
1047*56bb7041Schristos 
1048*56bb7041Schristos   // Return the size of each PLT entry.  This is only used for
1049*56bb7041Schristos   // laying out the incremental link info sections.  A target needs
1050*56bb7041Schristos   // to implement this to support incremental linking.
1051*56bb7041Schristos 
1052*56bb7041Schristos   virtual unsigned int
plt_entry_size()1053*56bb7041Schristos   plt_entry_size() const
1054*56bb7041Schristos   { gold_unreachable(); }
1055*56bb7041Schristos 
1056*56bb7041Schristos   // Return the size of each GOT entry.  This is only used for
1057*56bb7041Schristos   // laying out the incremental link info sections.  A target needs
1058*56bb7041Schristos   // to implement this if its GOT size is different.
1059*56bb7041Schristos 
1060*56bb7041Schristos   virtual unsigned int
got_entry_size()1061*56bb7041Schristos   got_entry_size() const
1062*56bb7041Schristos   { return size / 8; }
1063*56bb7041Schristos 
1064*56bb7041Schristos   // Create the GOT and PLT sections for an incremental update.
1065*56bb7041Schristos   // A target needs to implement this to support incremental linking.
1066*56bb7041Schristos 
1067*56bb7041Schristos   virtual Output_data_got_base*
init_got_plt_for_update(Symbol_table *,Layout *,unsigned int,unsigned int)1068*56bb7041Schristos   init_got_plt_for_update(Symbol_table*,
1069*56bb7041Schristos 			  Layout*,
1070*56bb7041Schristos 			  unsigned int /* got_count */,
1071*56bb7041Schristos 			  unsigned int /* plt_count */)
1072*56bb7041Schristos   { gold_unreachable(); }
1073*56bb7041Schristos 
1074*56bb7041Schristos   // Reserve a GOT entry for a local symbol, and regenerate any
1075*56bb7041Schristos   // necessary dynamic relocations.
1076*56bb7041Schristos   virtual void
reserve_local_got_entry(unsigned int,Sized_relobj<size,big_endian> *,unsigned int,unsigned int)1077*56bb7041Schristos   reserve_local_got_entry(unsigned int /* got_index */,
1078*56bb7041Schristos 			  Sized_relobj<size, big_endian>* /* obj */,
1079*56bb7041Schristos 			  unsigned int /* r_sym */,
1080*56bb7041Schristos 			  unsigned int /* got_type */)
1081*56bb7041Schristos   { gold_unreachable(); }
1082*56bb7041Schristos 
1083*56bb7041Schristos   // Reserve a GOT entry for a global symbol, and regenerate any
1084*56bb7041Schristos   // necessary dynamic relocations.
1085*56bb7041Schristos   virtual void
reserve_global_got_entry(unsigned int,Symbol *,unsigned int)1086*56bb7041Schristos   reserve_global_got_entry(unsigned int /* got_index */, Symbol* /* gsym */,
1087*56bb7041Schristos 			   unsigned int /* got_type */)
1088*56bb7041Schristos   { gold_unreachable(); }
1089*56bb7041Schristos 
1090*56bb7041Schristos   // Register an existing PLT entry for a global symbol.
1091*56bb7041Schristos   // A target needs to implement this to support incremental linking.
1092*56bb7041Schristos 
1093*56bb7041Schristos   virtual void
register_global_plt_entry(Symbol_table *,Layout *,unsigned int,Symbol *)1094*56bb7041Schristos   register_global_plt_entry(Symbol_table*, Layout*,
1095*56bb7041Schristos 			    unsigned int /* plt_index */,
1096*56bb7041Schristos 			    Symbol*)
1097*56bb7041Schristos   { gold_unreachable(); }
1098*56bb7041Schristos 
1099*56bb7041Schristos   // Force a COPY relocation for a given symbol.
1100*56bb7041Schristos   // A target needs to implement this to support incremental linking.
1101*56bb7041Schristos 
1102*56bb7041Schristos   virtual void
emit_copy_reloc(Symbol_table *,Symbol *,Output_section *,off_t)1103*56bb7041Schristos   emit_copy_reloc(Symbol_table*, Symbol*, Output_section*, off_t)
1104*56bb7041Schristos   { gold_unreachable(); }
1105*56bb7041Schristos 
1106*56bb7041Schristos   // Apply an incremental relocation.
1107*56bb7041Schristos 
1108*56bb7041Schristos   virtual void
apply_relocation(const Relocate_info<size,big_endian> *,typename elfcpp::Elf_types<size>::Elf_Addr,unsigned int,typename elfcpp::Elf_types<size>::Elf_Swxword,const Symbol *,unsigned char *,typename elfcpp::Elf_types<size>::Elf_Addr,section_size_type)1109*56bb7041Schristos   apply_relocation(const Relocate_info<size, big_endian>* /* relinfo */,
1110*56bb7041Schristos 		   typename elfcpp::Elf_types<size>::Elf_Addr /* r_offset */,
1111*56bb7041Schristos 		   unsigned int /* r_type */,
1112*56bb7041Schristos 		   typename elfcpp::Elf_types<size>::Elf_Swxword /* r_addend */,
1113*56bb7041Schristos 		   const Symbol* /* gsym */,
1114*56bb7041Schristos 		   unsigned char* /* view */,
1115*56bb7041Schristos 		   typename elfcpp::Elf_types<size>::Elf_Addr /* address */,
1116*56bb7041Schristos 		   section_size_type /* view_size */)
1117*56bb7041Schristos   { gold_unreachable(); }
1118*56bb7041Schristos 
1119*56bb7041Schristos   // Handle target specific gc actions when adding a gc reference from
1120*56bb7041Schristos   // SRC_OBJ, SRC_SHNDX to a location specified by DST_OBJ, DST_SHNDX
1121*56bb7041Schristos   // and DST_OFF.
1122*56bb7041Schristos   void
gc_add_reference(Symbol_table * symtab,Relobj * src_obj,unsigned int src_shndx,Relobj * dst_obj,unsigned int dst_shndx,typename elfcpp::Elf_types<size>::Elf_Addr dst_off)1123*56bb7041Schristos   gc_add_reference(Symbol_table* symtab,
1124*56bb7041Schristos 		   Relobj* src_obj,
1125*56bb7041Schristos 		   unsigned int src_shndx,
1126*56bb7041Schristos 		   Relobj* dst_obj,
1127*56bb7041Schristos 		   unsigned int dst_shndx,
1128*56bb7041Schristos 		   typename elfcpp::Elf_types<size>::Elf_Addr dst_off) const
1129*56bb7041Schristos   {
1130*56bb7041Schristos     this->do_gc_add_reference(symtab, src_obj, src_shndx,
1131*56bb7041Schristos 			      dst_obj, dst_shndx, dst_off);
1132*56bb7041Schristos   }
1133*56bb7041Schristos 
1134*56bb7041Schristos   // Return the r_sym field from a relocation.
1135*56bb7041Schristos   // Most targets can use the default version of this routine,
1136*56bb7041Schristos   // but some targets have a non-standard r_info field, and will
1137*56bb7041Schristos   // need to provide a target-specific version.
1138*56bb7041Schristos   virtual unsigned int
get_r_sym(const unsigned char * preloc)1139*56bb7041Schristos   get_r_sym(const unsigned char* preloc) const
1140*56bb7041Schristos   {
1141*56bb7041Schristos     // Since REL and RELA relocs share the same structure through
1142*56bb7041Schristos     // the r_info field, we can just use REL here.
1143*56bb7041Schristos     elfcpp::Rel<size, big_endian> rel(preloc);
1144*56bb7041Schristos     return elfcpp::elf_r_sym<size>(rel.get_r_info());
1145*56bb7041Schristos   }
1146*56bb7041Schristos 
1147*56bb7041Schristos   // Record a target-specific program property in the .note.gnu.property
1148*56bb7041Schristos   // section.
1149*56bb7041Schristos   virtual void
record_gnu_property(unsigned int,unsigned int,size_t,const unsigned char *,const Object *)1150*56bb7041Schristos   record_gnu_property(unsigned int, unsigned int, size_t,
1151*56bb7041Schristos 		      const unsigned char*, const Object*)
1152*56bb7041Schristos   { }
1153*56bb7041Schristos 
1154*56bb7041Schristos   // Merge the target-specific program properties from the current object.
1155*56bb7041Schristos   virtual void
merge_gnu_properties(const Object *)1156*56bb7041Schristos   merge_gnu_properties(const Object*)
1157*56bb7041Schristos   { }
1158*56bb7041Schristos 
1159*56bb7041Schristos  protected:
Sized_target(const Target::Target_info * pti)1160*56bb7041Schristos   Sized_target(const Target::Target_info* pti)
1161*56bb7041Schristos     : Target(pti)
1162*56bb7041Schristos   {
1163*56bb7041Schristos     gold_assert(pti->size == size);
1164*56bb7041Schristos     gold_assert(pti->is_big_endian ? big_endian : !big_endian);
1165*56bb7041Schristos   }
1166*56bb7041Schristos 
1167*56bb7041Schristos   // Set the EI_OSABI field if requested.
1168*56bb7041Schristos   virtual void
1169*56bb7041Schristos   do_adjust_elf_header(unsigned char*, int);
1170*56bb7041Schristos 
1171*56bb7041Schristos   // Handle target specific gc actions when adding a gc reference.
1172*56bb7041Schristos   virtual void
do_gc_add_reference(Symbol_table *,Relobj *,unsigned int,Relobj *,unsigned int,typename elfcpp::Elf_types<size>::Elf_Addr)1173*56bb7041Schristos   do_gc_add_reference(Symbol_table*, Relobj*, unsigned int,
1174*56bb7041Schristos 		      Relobj*, unsigned int,
1175*56bb7041Schristos 		      typename elfcpp::Elf_types<size>::Elf_Addr) const
1176*56bb7041Schristos   { }
1177*56bb7041Schristos 
1178*56bb7041Schristos   virtual void
do_function_location(Symbol_location *)1179*56bb7041Schristos   do_function_location(Symbol_location*) const
1180*56bb7041Schristos   { }
1181*56bb7041Schristos };
1182*56bb7041Schristos 
1183*56bb7041Schristos } // End namespace gold.
1184*56bb7041Schristos 
1185*56bb7041Schristos #endif // !defined(GOLD_TARGET_H)
1186