// object.h -- support for an object file for linking in gold -*- C++ -*-
-// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012
-// Free Software Foundation, Inc.
+// Copyright (C) 2006-2015 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
{
std::string source_file;
std::string enclosing_symbol_name;
- int line_number;
+ elfcpp::STT enclosing_symbol_type;
};
// Data about a single relocation section. This is read in
// Return the name of a section given a section index.
std::string
- section_name(unsigned int shndx)
+ section_name(unsigned int shndx) const
{ return this->do_section_name(shndx); }
// Return the section flags given a section index.
output_section(unsigned int shndx) const
{ return this->do_output_section(shndx); }
+ // Given a section index, return its address.
+ // The return value will be -1U if the section is specially mapped,
+ // such as a merge section.
+ uint64_t
+ output_section_address(unsigned int shndx)
+ { return this->do_output_section_address(shndx); }
+
// Given a section index, return the offset in the Output_section.
// The return value will be -1U if the section is specially mapped,
// such as a merge section.
// Get the name of a section--implemented by child class.
virtual std::string
- do_section_name(unsigned int shndx) = 0;
+ do_section_name(unsigned int shndx) const = 0;
// Get section flags--implemented by child class.
virtual uint64_t
do_output_section(unsigned int) const
{ gold_unreachable(); }
+ // Get the address of a section--implemented by child class.
+ virtual uint64_t
+ do_output_section_address(unsigned int)
+ { gold_unreachable(); }
+
// Get the offset of a section--implemented by child class.
virtual uint64_t
do_output_section_offset(unsigned int) const
read_section_data(elfcpp::Elf_file<size, big_endian, Object>*,
Read_symbols_data*);
+ // Find the section header with the given NAME. If HDR is non-NULL
+ // then it is a section header returned from a previous call to this
+ // function and the next section header with the same name will be
+ // returned.
+ template<int size, bool big_endian>
+ const unsigned char*
+ find_shdr(const unsigned char* pshdrs, const char* name,
+ const char* names, section_size_type names_size,
+ const unsigned char* hdr) const;
+
// Let the child class initialize the xindex object directly.
void
set_xindex(Xindex* xindex)
unsigned int got_offset)
{ this->do_set_local_got_offset(symndx, got_type, got_offset); }
+ // Return whether the local symbol SYMNDX is a TLS symbol.
+ bool
+ local_is_tls(unsigned int symndx) const
+ { return this->do_local_is_tls(symndx); }
+
// The number of local symbols in the input symbol table.
virtual unsigned int
local_symbol_count() const
return this->output_sections_[shndx] != NULL;
}
- // The the output section of the input section with index SHNDX.
+ // The output section of the input section with index SHNDX.
// This is only used currently to remove a section from the link in
// relaxation.
void
do_get_incremental_reloc_count(unsigned int symndx) const
{ return this->reloc_counts_[symndx]; }
+ // Return the word size of the object file.
+ int
+ elfsize() const
+ { return this->do_elfsize(); }
+
+ // Return TRUE if this is a big-endian object file.
+ bool
+ is_big_endian() const
+ { return this->do_is_big_endian(); }
+
protected:
// The output section to be used for each input section, indexed by
// the input section number. The output section is NULL if the
do_set_local_got_offset(unsigned int symndx, unsigned int got_type,
unsigned int got_offset) = 0;
+ // Return whether local symbol SYMNDX is a TLS symbol.
+ virtual bool
+ do_local_is_tls(unsigned int symndx) const = 0;
+
// Return the number of local symbols--implemented by child class.
virtual unsigned int
do_local_symbol_count() const = 0;
return this->reloc_bases_[symndx] + counter;
}
+ // Return the word size of the object file--
+ // implemented by child class.
+ virtual int
+ do_elfsize() const = 0;
+
+ // Return TRUE if this is a big-endian object file--
+ // implemented by child class.
+ virtual bool
+ do_is_big_endian() const = 0;
+
private:
// Mapping from input sections to output section.
Output_sections output_sections_;
section_offsets()
{ return this->section_offsets_; }
+ // Get the address of an output section.
+ uint64_t
+ do_output_section_address(unsigned int shndx);
+
// Get the offset of a section.
uint64_t
do_output_section_offset(unsigned int shndx) const
}
}
+ // Return the word size of the object file.
+ virtual int
+ do_elfsize() const
+ { return size; }
+
+ // Return TRUE if this is a big-endian object file.
+ virtual bool
+ do_is_big_endian() const
+ { return big_endian; }
+
private:
// The GOT offsets of local symbols. This map also stores GOT offsets
// for tp-relative offsets for TLS symbols.
void
set_local_plt_offset(unsigned int symndx, unsigned int plt_offset);
+ // Adjust this local symbol value. Return false if the symbol
+ // should be discarded from the output file.
+ bool
+ adjust_local_symbol(Symbol_value<size>* lv) const
+ { return this->do_adjust_local_symbol(lv); }
+
// Return the name of the symbol that spans the given offset in the
// specified section in this object. This is used only for error
// messages and is not particularly efficient.
Address
map_to_kept_section(unsigned int shndx, bool* found) const;
- // Find the section header with the given NAME. If HDR is non-NULL
- // then it is a section header returned from a previous call to this
- // function and the next section header with the same name will be
- // returned.
- const unsigned char*
- find_shdr(const unsigned char* pshdrs, const char* name,
- const char* names, section_size_type names_size,
- const unsigned char* hdr) const;
-
// Compute final local symbol value. R_SYM is the local symbol index.
// LV_IN points to a local symbol value containing the input value.
// LV_OUT points to a local symbol value storing the final output value,
Symbol_value<size>* lv_out,
const Symbol_table* symtab);
+ // Return true if the layout for this object was deferred.
+ bool is_deferred_layout() const
+ { return this->is_deferred_layout_; }
+
protected:
typedef typename Sized_relobj<size, big_endian>::Output_sections
Output_sections;
void
do_read_symbols(Read_symbols_data*);
+ // Read the symbols. This is common code for all target-specific
+ // overrides of do_read_symbols.
+ void
+ base_read_symbols(Read_symbols_data*);
+
// Return the value of a local symbol.
uint64_t
do_local_symbol_value(unsigned int symndx, uint64_t addend) const
unsigned int
do_local_plt_offset(unsigned int symndx) const;
+ // Return whether local symbol SYMNDX is a TLS symbol.
+ bool
+ do_local_is_tls(unsigned int symndx) const
+ { return this->local_symbol(symndx)->is_tls_symbol(); }
+
// Return the number of local symbols.
unsigned int
do_local_symbol_count() const
// Get the name of a section.
std::string
- do_section_name(unsigned int shndx)
+ do_section_name(unsigned int shndx) const
{ return this->elf_file_.section_name(shndx); }
// Return the location of the contents of a section.
const unsigned char* pshdrs, Output_file* of,
Views* pviews);
+ // Adjust this local symbol value. Return false if the symbol
+ // should be discarded from the output file.
+ virtual bool
+ do_adjust_local_symbol(Symbol_value<size>*) const
+ { return true; }
+
// Allow a child to set output local symbol count.
void
set_output_local_symbol_count(unsigned int value)
const Read_relocs_data::Relocs_list::iterator&,
Relocatable_relocs*);
- // Emit the relocs for --emit-relocs.
- void
- emit_relocs(const Relocate_info<size, big_endian>*, unsigned int,
- unsigned int sh_type, const unsigned char* prelocs,
- size_t reloc_count, Output_section*, Address output_offset,
- unsigned char* view, Address address,
- section_size_type view_size,
- unsigned char* reloc_view, section_size_type reloc_view_size);
-
- // Emit the relocs for --emit-relocs, templatized on the type of the
- // relocation section.
- template<int sh_type>
- void
- emit_relocs_reltype(const Relocate_info<size, big_endian>*, unsigned int,
- const unsigned char* prelocs, size_t reloc_count,
- Output_section*, Address output_offset,
- unsigned char* view, Address address,
- section_size_type view_size,
- unsigned char* reloc_view,
- section_size_type reloc_view_size);
-
// Scan the input relocations for --incremental.
void
incremental_relocs_scan(const Read_relocs_data::Relocs_list::iterator&);
// If this object has a GNU style .eh_frame section that is discarded in
// output, record the index here. Otherwise it is -1U.
unsigned int discarded_eh_frame_shndx_;
+ // True if the layout of this object was deferred, waiting for plugin
+ // replacement files.
+ bool is_deferred_layout_;
// The list of sections whose layout was deferred.
std::vector<Deferred_layout> deferred_layout_;
// The list of relocation sections whose layout was deferred.