X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gold%2Ftarget.h;h=087a3235816ab834671bc4bbe7d690ca27a57d06;hb=5862844d0f443b9f65e8dd0d85c43f8818d3f355;hp=e3805910301f392275bab8b0872a4ceb8e0c74bc;hpb=99fd8cfff7a9da67efc2e6c627176f5c767c6e7d;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/target.h b/gold/target.h index e380591030..087a323581 100644 --- a/gold/target.h +++ b/gold/target.h @@ -1,6 +1,6 @@ // target.h -- target support for gold -*- C++ -*- -// Copyright (C) 2006-2014 Free Software Foundation, Inc. +// Copyright (C) 2006-2019 Free Software Foundation, Inc. // Written by Ian Lance Taylor . // This file is part of gold. @@ -119,9 +119,19 @@ class Target { return this->pti_->dynamic_linker; } // Return the default address to use for the text segment. + // If a -z max-page-size argument has set the ABI page size + // to a value larger than the default starting address, + // bump the starting address up to the page size, to avoid + // misaligning the text segment in the file. uint64_t default_text_segment_address() const - { return this->pti_->default_text_segment_address; } + { + uint64_t addr = this->pti_->default_text_segment_address; + uint64_t pagesize = this->abi_pagesize(); + if (addr < pagesize) + addr = pagesize; + return addr; + } // Return the ABI specified page size. uint64_t @@ -321,13 +331,15 @@ 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 unsigned char* view, + section_size_type view_size) const + { return this->do_is_call_to_non_split(sym, preloc, view, view_size); } // A function starts at OFFSET in section SHNDX in OBJECT. That // function was compiled with -fsplit-stack, but it refers to a @@ -338,10 +350,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); } @@ -455,6 +469,16 @@ class Target 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; } + + // Return the section type to use for unwind sections. + unsigned int + unwind_section_type() const + { return this->pti_->unwind_section_type; } + // Whether the target has a custom set_dynsym_indexes method. bool has_custom_set_dynsym_indexes() const @@ -485,6 +509,11 @@ class Target should_include_section(elfcpp::Elf_Word sh_type) const { return this->do_should_include_section(sh_type); } + // Finalize the target-specific properties in the .note.gnu.property section. + void + finalize_gnu_properties(Layout* layout) const + { this->do_finalize_gnu_properties(layout); } + protected: // This struct holds the constant information for a child class. We // use a struct to avoid the overhead of virtual function calls for @@ -540,6 +569,12 @@ class Target 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; + // Processor-specific section type for ".eh_frame" (unwind) sections. + // SHT_PROGBITS if there is no special section type. + const unsigned int unwind_section_type; }; Target(const Target_info* pti) @@ -651,12 +686,14 @@ 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 unsigned char*, section_size_type) 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 @@ -783,6 +820,11 @@ class Target do_should_include_section(elfcpp::Elf_Word) const { return true; } + // Finalize the target-specific properties in the .note.gnu.property section. + virtual void + do_finalize_gnu_properties(Layout*) const + { } + 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. @@ -820,7 +862,7 @@ class Sized_target : public Target // symbol table. This will only be called if has_make_symbol() // returns true. virtual Sized_symbol* - make_symbol() const + make_symbol(const char*, elfcpp::STT, Object*, unsigned int, uint64_t) { gold_unreachable(); } // Resolve a symbol for the target. This should be overridden by a @@ -828,7 +870,7 @@ class Sized_target : public Target // pre-existing symbol. SYM is the new symbol, seen in OBJECT. // VERSION is the version of SYM. This will only be called if // has_resolve() returns true. - virtual void + virtual bool resolve(Symbol*, const elfcpp::Sym&, Object*, const char*) { gold_unreachable(); } @@ -915,6 +957,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. @@ -926,7 +984,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, @@ -996,6 +1053,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. @@ -1056,9 +1121,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 { @@ -1066,6 +1131,31 @@ 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()); + } + + // Record a target-specific program property in the .note.gnu.property + // section. + virtual void + record_gnu_property(unsigned int, unsigned int, size_t, + const unsigned char*, const Object*) + { } + + // Merge the target-specific program properties from the current object. + virtual void + merge_gnu_properties(const Object*) + { } + protected: Sized_target(const Target::Target_info* pti) : Target(pti) @@ -1080,8 +1170,8 @@ class Sized_target : public Target // 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 { }