X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gold%2Fobject.h;h=b7bd38faaf8c1e73ef01f425bdd3256b2507c24d;hb=54ac3df1adbf7b4b3470a8df08caa0aea4c89616;hp=f408408d28a793ce3d736a35552ade9c5f4add30;hpb=91a65d2fe88fabe2d553a0362b2f76034f820175;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/object.h b/gold/object.h index f408408d28..b7bd38faaf 100644 --- a/gold/object.h +++ b/gold/object.h @@ -1,6 +1,6 @@ // object.h -- support for an object file for linking in gold -*- C++ -*- -// Copyright (C) 2006-2015 Free Software Foundation, Inc. +// Copyright (C) 2006-2020 Free Software Foundation, Inc. // Written by Ian Lance Taylor . // This file is part of gold. @@ -39,6 +39,7 @@ class General_options; class Task; class Cref; class Layout; +class Kept_section; class Output_data; class Output_section; class Output_section_data; @@ -372,6 +373,7 @@ struct Compressed_section_info { section_size_type size; elfcpp::Elf_Xword flag; + uint64_t addralign; const unsigned char* contents; }; typedef std::map Compressed_section_map; @@ -807,7 +809,8 @@ class Object bool section_is_compressed(unsigned int shndx, - section_size_type* uncompressed_size) const + section_size_type* uncompressed_size, + elfcpp::Elf_Xword* palign = NULL) const { if (this->compressed_sections_ == NULL) return false; @@ -817,6 +820,8 @@ class Object { if (uncompressed_size != NULL) *uncompressed_size = p->second.size; + if (palign != NULL) + *palign = p->second.addralign; return true; } return false; @@ -827,7 +832,7 @@ class Object // by the caller. const unsigned char* decompressed_section_contents(unsigned int shndx, section_size_type* plen, - bool* is_cached); + bool* is_cached, uint64_t* palign = NULL); // Discard any buffers of decompressed sections. This is done // at the end of the Add_symbols task. @@ -844,6 +849,11 @@ class Object get_incremental_reloc_count(unsigned int symndx) const { return this->do_get_incremental_reloc_count(symndx); } + // Return the output view for section SHNDX. + unsigned char* + get_output_view(unsigned int shndx, section_size_type* plen) const + { return this->do_get_output_view(shndx, plen); } + protected: // Returns NULL for Objects that are not dynamic objects. This method // is overridden in the Dynobj class. @@ -1029,6 +1039,11 @@ class Object do_get_incremental_reloc_count(unsigned int) const { gold_unreachable(); } + // Return the output view for a section. + virtual unsigned char* + do_get_output_view(unsigned int, section_size_type*) const + { gold_unreachable(); } + void set_compressed_sections(Compressed_section_map* compressed_sections) { this->compressed_sections_ = compressed_sections; } @@ -2294,7 +2309,17 @@ class Sized_relobj_file : public Sized_relobj // and return its output address. This is used only for relocations in // debugging sections. Address - map_to_kept_section(unsigned int shndx, bool* found) const; + map_to_kept_section(unsigned int shndx, std::string& section_name, + bool* found) const; + + // Look for a kept section corresponding to the given discarded section, + // and return its object file. + Relobj* + find_kept_section_object(unsigned int shndx, unsigned int* symndx_p) const; + + // Return the name of symbol SYMNDX. + const char* + get_symbol_name(unsigned int symndx); // Compute final local symbol value. R_SYM is the local symbol index. // LV_IN points to a local symbol value containing the input value. @@ -2552,6 +2577,13 @@ class Sized_relobj_file : public Sized_relobj const unsigned char* pshdrs, Output_file* of, Views* pviews); + // Relocate section data for a range of sections. + void + relocate_section_range(const Symbol_table* symtab, const Layout* layout, + const unsigned char* pshdrs, Output_file* of, + Views* pviews, unsigned int start_shndx, + unsigned int end_shndx); + // Adjust this local symbol value. Return false if the symbol // should be discarded from the output file. virtual bool @@ -2563,6 +2595,10 @@ class Sized_relobj_file : public Sized_relobj set_output_local_symbol_count(unsigned int value) { this->output_local_symbol_count_ = value; } + // Return the output view for a section. + unsigned char* + do_get_output_view(unsigned int, section_size_type*) const; + private: // For convenience. typedef Sized_relobj_file This; @@ -2570,17 +2606,22 @@ class Sized_relobj_file : public Sized_relobj static const int shdr_size = elfcpp::Elf_sizes::shdr_size; static const int sym_size = elfcpp::Elf_sizes::sym_size; typedef elfcpp::Shdr Shdr; + typedef elfcpp::Shdr_write Shdr_write; // To keep track of discarded comdat sections, we need to map a member // section index to the object and section index of the corresponding // kept section. struct Kept_comdat_section { - Kept_comdat_section(Relobj* a_object, unsigned int a_shndx) - : object(a_object), shndx(a_shndx) + Kept_comdat_section(uint64_t a_sh_size, Kept_section* a_kept_section, + unsigned int a_symndx, bool a_is_comdat) + : sh_size(a_sh_size), kept_section(a_kept_section), + symndx (a_symndx), is_comdat(a_is_comdat) { } - Relobj* object; - unsigned int shndx; + uint64_t sh_size; // Section size + Kept_section* kept_section; // Kept section info + unsigned int symndx; // Index of key symbol + bool is_comdat; // True if comdat group, false if linkonce }; typedef std::map Kept_comdat_section_table; @@ -2614,8 +2655,8 @@ class Sized_relobj_file : public Sized_relobj // Layout an input section. void layout_section(Layout* layout, unsigned int shndx, const char* name, - const typename This::Shdr& shdr, unsigned int reloc_shndx, - unsigned int reloc_type); + const typename This::Shdr& shdr, unsigned int sh_type, + unsigned int reloc_shndx, unsigned int reloc_type); // Layout an input .eh_frame section. void @@ -2626,6 +2667,10 @@ class Sized_relobj_file : public Sized_relobj unsigned int shndx, const typename This::Shdr&, unsigned int reloc_shndx, unsigned int reloc_type); + // Layout an input .note.gnu.property section. + void + layout_gnu_property_section(Layout* layout, unsigned int shndx); + // Write section data to the output file. Record the views and // sizes in VIEWS for use when relocating. void @@ -2696,7 +2741,8 @@ class Sized_relobj_file : public Sized_relobj unsigned int sh_type, unsigned int shndx, const unsigned char* prelocs, size_t reloc_count, unsigned char* view, section_size_type view_size, - Reloc_symbol_changes** reloc_map); + Reloc_symbol_changes** reloc_map, + const Sized_target* target); template void @@ -2704,7 +2750,8 @@ class Sized_relobj_file : public Sized_relobj unsigned int shndx, const unsigned char* prelocs, size_t reloc_count, unsigned char* view, section_size_type view_size, - Reloc_symbol_changes** reloc_map); + Reloc_symbol_changes** reloc_map, + const Sized_target* target); // Find all functions in a section. void @@ -2723,25 +2770,29 @@ class Sized_relobj_file : public Sized_relobj // Record a mapping from discarded section SHNDX to the corresponding // kept section. void - set_kept_comdat_section(unsigned int shndx, Relobj* kept_object, - unsigned int kept_shndx) + set_kept_comdat_section(unsigned int shndx, bool is_comdat, + unsigned int symndx, uint64_t sh_size, + Kept_section* kept_section) { - Kept_comdat_section kept(kept_object, kept_shndx); + Kept_comdat_section kept(sh_size, kept_section, symndx, is_comdat); this->kept_comdat_sections_.insert(std::make_pair(shndx, kept)); } // Find the kept section corresponding to the discarded section // SHNDX. Return true if found. bool - get_kept_comdat_section(unsigned int shndx, Relobj** kept_object, - unsigned int* kept_shndx) const + get_kept_comdat_section(unsigned int shndx, bool* is_comdat, + unsigned int *symndx, uint64_t* sh_size, + Kept_section** kept_section) const { typename Kept_comdat_section_table::const_iterator p = this->kept_comdat_sections_.find(shndx); if (p == this->kept_comdat_sections_.end()) return false; - *kept_object = p->second.object; - *kept_shndx = p->second.shndx; + *is_comdat = p->second.is_comdat; + *symndx = p->second.symndx; + *sh_size = p->second.sh_size; + *kept_section = p->second.kept_section; return true; } @@ -2775,15 +2826,18 @@ class Sized_relobj_file : public Sized_relobj { static const int shdr_size = elfcpp::Elf_sizes::shdr_size; Deferred_layout(unsigned int shndx, const char* name, + unsigned int sh_type, const unsigned char* pshdr, unsigned int reloc_shndx, unsigned int reloc_type) - : shndx_(shndx), name_(name), reloc_shndx_(reloc_shndx), + : name_(name), shndx_(shndx), reloc_shndx_(reloc_shndx), reloc_type_(reloc_type) { + typename This::Shdr_write shdr(this->shdr_data_); memcpy(this->shdr_data_, pshdr, shdr_size); + shdr.put_sh_type(sh_type); } - unsigned int shndx_; std::string name_; + unsigned int shndx_; unsigned int reloc_shndx_; unsigned int reloc_type_; unsigned char shdr_data_[shdr_size]; @@ -2819,9 +2873,6 @@ class Sized_relobj_file : public Sized_relobj Kept_comdat_section_table kept_comdat_sections_; // Whether this object has a GNU style .eh_frame section. bool has_eh_frame_; - // 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_; @@ -2829,6 +2880,8 @@ class Sized_relobj_file : public Sized_relobj std::vector deferred_layout_; // The list of relocation sections whose layout was deferred. std::vector deferred_layout_relocs_; + // Pointer to the list of output views; valid only during do_relocate(). + const Views* output_views_; }; // A class to manage the list of all objects.