X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gold%2Ftarget.h;h=c0f24eea795e8a658d2074fc8129d82bca9bea05;hb=4d625b70fc3fb7facc7159feb8d49b78ac6641f9;hp=d4b9d0f35d885d5d10dc463b5a2a1fdcc6157386;hpb=62fe925ad4724f379e9bec4f19408dc71d416042;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/target.h b/gold/target.h index d4b9d0f35d..c0f24eea79 100644 --- a/gold/target.h +++ b/gold/target.h @@ -1,7 +1,6 @@ // target.h -- target support for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2016 Free Software Foundation, Inc. // Written by Ian Lance Taylor . // This file is part of gold. @@ -37,6 +36,7 @@ #include "elfcpp.h" #include "options.h" #include "parameters.h" +#include "stringpool.h" #include "debug.h" namespace gold @@ -61,6 +61,8 @@ class Output_data_got_base; class Output_section; class Input_objects; class Task; +struct Symbol_location; +class Versions; // The abstract class for target specific handling. @@ -237,9 +239,15 @@ class Target // Adjust the output file header before it is written out. VIEW // points to the header in external form. LEN is the length. void - adjust_elf_header(unsigned char* view, int len) const + adjust_elf_header(unsigned char* view, int len) { return this->do_adjust_elf_header(view, len); } + // Return address and size to plug into eh_frame FDEs associated with a PLT. + void + plt_fde_location(const Output_data* plt, unsigned char* oview, + uint64_t* address, off_t* len) const + { return this->do_plt_fde_location(plt, oview, address, len); } + // Return whether NAME is a local label name. This is used to implement the // --discard-locals options. bool @@ -280,6 +288,12 @@ class Target tls_offset_for_global(Symbol* gsym, unsigned int got_indx) const { return do_tls_offset_for_global(gsym, got_indx); } + // For targets that use function descriptors, if LOC is the location + // of a function, modify it to point at the function entry location. + void + function_location(Symbol_location* loc) const + { return do_function_location(loc); } + // Return whether this target can use relocation types to determine // if a function's address is taken. bool @@ -307,13 +321,13 @@ class Target ehframe_datarel_base() const { return this->do_ehframe_datarel_base(); } - // Return true if a reference to SYM from a reloc of type R_TYPE + // Return true if a reference to SYM from a reloc at *PRELOC // means that the current function may call an object compiled // without -fsplit-stack. SYM is known to be defined in an object // compiled without -fsplit-stack. bool - is_call_to_non_split(const Symbol* sym, unsigned int r_type) const - { return this->do_is_call_to_non_split(sym, r_type); } + is_call_to_non_split(const Symbol* sym, const unsigned char* preloc) const + { return this->do_is_call_to_non_split(sym, preloc); } // A function starts at OFFSET in section SHNDX in OBJECT. That // function was compiled with -fsplit-stack, but it refers to a @@ -324,10 +338,12 @@ class Target 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) const { - this->do_calls_non_split(object, shndx, fnoffset, fnsize, view, view_size, + this->do_calls_non_split(object, shndx, fnoffset, fnsize, + prelocs, reloc_count, view, view_size, from, to); } @@ -436,6 +452,46 @@ class Target gc_mark_symbol(Symbol_table* symtab, Symbol* sym) const { this->do_gc_mark_symbol(symtab, sym); } + // Return the name of the entry point symbol. + const char* + entry_symbol_name() const + { return this->pti_->entry_symbol_name; } + + // Return the size in bits of SHT_HASH entry. + int + hash_entry_size() const + { return this->pti_->hash_entry_size; } + + // Whether the target has a custom set_dynsym_indexes method. + bool + has_custom_set_dynsym_indexes() const + { return this->do_has_custom_set_dynsym_indexes(); } + + // Custom set_dynsym_indexes method for a target. + unsigned int + set_dynsym_indexes(std::vector* dyn_symbols, unsigned int index, + std::vector* syms, Stringpool* dynpool, + Versions* versions, Symbol_table* symtab) const + { + return this->do_set_dynsym_indexes(dyn_symbols, index, syms, dynpool, + versions, symtab); + } + + // Get the custom dynamic tag value. + unsigned int + dynamic_tag_custom_value(elfcpp::DT tag) const + { return this->do_dynamic_tag_custom_value(tag); } + + // Adjust the value written to the dynamic symbol table. + void + adjust_dyn_symbol(const Symbol* sym, unsigned char* view) const + { this->do_adjust_dyn_symbol(sym, view); } + + // Return whether to include the section in the link. + bool + should_include_section(elfcpp::Elf_Word sh_type) const + { return this->do_should_include_section(sh_type); } + protected: // This struct holds the constant information for a child class. We // use a struct to avoid the overhead of virtual function calls for @@ -489,6 +545,11 @@ class Target const char* attributes_section; // Vendor name of vendor attributes. const char* attributes_vendor; + // Name of the main entry point to the program. + const char* entry_symbol_name; + // Size (in bits) of SHT_HASH entry. Always equal to 32, except for + // 64-bit S/390. + const int hash_entry_size; }; Target(const Target_info* pti) @@ -528,7 +589,12 @@ class Target // By default, we set the EI_OSABI field if requested (in // Sized_target). virtual void - do_adjust_elf_header(unsigned char*, int) const = 0; + do_adjust_elf_header(unsigned char*, int) = 0; + + // Return address and size to plug into eh_frame FDEs associated with a PLT. + virtual void + do_plt_fde_location(const Output_data* plt, unsigned char* oview, + uint64_t* address, off_t* len) const; // Virtual function which may be overridden by the child class. virtual bool @@ -564,6 +630,9 @@ class Target do_tls_offset_for_global(Symbol*, unsigned int) const { gold_unreachable(); } + virtual void + do_function_location(Symbol_location*) const = 0; + // Virtual function which may be overriden by the child class. virtual bool do_can_check_for_function_pointers() const @@ -592,12 +661,13 @@ class Target // default implementation is that any function not defined by the // ABI is a call to a non-split function. virtual bool - do_is_call_to_non_split(const Symbol* sym, unsigned int) const; + do_is_call_to_non_split(const Symbol* sym, const unsigned char*) const; // Virtual function which may be overridden by the child class. virtual void do_calls_non_split(Relobj* object, unsigned int, section_offset_type, - section_size_type, unsigned char*, section_size_type, + section_size_type, const unsigned char*, size_t, + unsigned char*, section_size_type, std::string*, std::string*) const; // make_elf_object hooks. There are four versions of these for @@ -697,6 +767,33 @@ class Target do_gc_mark_symbol(Symbol_table*, Symbol*) const { } + // This may be overridden by the child class. + virtual bool + do_has_custom_set_dynsym_indexes() const + { return false; } + + // This may be overridden by the child class. + virtual unsigned int + do_set_dynsym_indexes(std::vector*, unsigned int, + std::vector*, Stringpool*, Versions*, + Symbol_table*) const + { gold_unreachable(); } + + // This may be overridden by the child class. + virtual unsigned int + do_dynamic_tag_custom_value(elfcpp::DT) const + { gold_unreachable(); } + + // This may be overridden by the child class. + virtual void + do_adjust_dyn_symbol(const Symbol*, unsigned char*) const + { } + + // This may be overridden by the child class. + virtual bool + do_should_include_section(elfcpp::Elf_Word) const + { return true; } + private: // The implementations of the four do_make_elf_object virtual functions are // almost identical except for their sizes and endianness. We use a template. @@ -829,6 +926,22 @@ class Sized_target : public Target const unsigned char* plocal_symbols, Relocatable_relocs*) = 0; + // Scan the relocs for --emit-relocs. The parameters are + // like scan_relocatable_relocs. + virtual void + emit_relocs_scan(Symbol_table* symtab, + Layout* layout, + Sized_relobj_file* object, + unsigned int data_shndx, + unsigned int sh_type, + const unsigned char* prelocs, + size_t reloc_count, + Output_section* output_section, + bool needs_special_offset_handling, + size_t local_symbol_count, + const unsigned char* plocal_syms, + Relocatable_relocs* rr) = 0; + // Emit relocations for a section during a relocatable link, and for // --emit-relocs. The parameters are like relocate_section, with // additional parameters for the view of the output reloc section. @@ -840,7 +953,6 @@ class Sized_target : public Target Output_section* output_section, typename elfcpp::Elf_types::Elf_Off offset_in_output_section, - const Relocatable_relocs*, unsigned char* view, typename elfcpp::Elf_types::Elf_Addr view_address, section_size_type view_size, @@ -910,6 +1022,14 @@ class Sized_target : public Target plt_entry_size() const { gold_unreachable(); } + // Return the size of each GOT entry. This is only used for + // laying out the incremental link info sections. A target needs + // to implement this if its GOT size is different. + + virtual unsigned int + got_entry_size() const + { return size / 8; } + // Create the GOT and PLT sections for an incremental update. // A target needs to implement this to support incremental linking. @@ -970,9 +1090,9 @@ class Sized_target : public Target // and DST_OFF. void gc_add_reference(Symbol_table* symtab, - Object* src_obj, + Relobj* src_obj, unsigned int src_shndx, - Object* dst_obj, + Relobj* dst_obj, unsigned int dst_shndx, typename elfcpp::Elf_types::Elf_Addr dst_off) const { @@ -980,6 +1100,19 @@ class Sized_target : public Target dst_obj, dst_shndx, dst_off); } + // Return the r_sym field from a relocation. + // Most targets can use the default version of this routine, + // but some targets have a non-standard r_info field, and will + // need to provide a target-specific version. + virtual unsigned int + get_r_sym(const unsigned char* preloc) const + { + // Since REL and RELA relocs share the same structure through + // the r_info field, we can just use REL here. + elfcpp::Rel rel(preloc); + return elfcpp::elf_r_sym(rel.get_r_info()); + } + protected: Sized_target(const Target::Target_info* pti) : Target(pti) @@ -990,14 +1123,18 @@ class Sized_target : public Target // Set the EI_OSABI field if requested. virtual void - do_adjust_elf_header(unsigned char*, int) const; + do_adjust_elf_header(unsigned char*, int); // Handle target specific gc actions when adding a gc reference. virtual void - do_gc_add_reference(Symbol_table*, Object*, unsigned int, - Object*, unsigned int, + do_gc_add_reference(Symbol_table*, Relobj*, unsigned int, + Relobj*, unsigned int, typename elfcpp::Elf_types::Elf_Addr) const { } + + virtual void + do_function_location(Symbol_location*) const + { } }; } // End namespace gold.