From 5995b57073ad5990e2f63c7f65c0a6c27cad55a9 Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Tue, 23 Dec 2008 02:02:20 +0000 Subject: * object.cc (Sized_relobj::layout_section): New function. (Sized_relobj::do_layout): Defer layout of input sections until after plugin has provided replacement files. (Sized_relobj::do_layout_deferred_sections): New function. * object.h (Relobj::set_section_offset): Remove virtual keyword. (Relobj::layout_deferred_sections): New function. (Relobj::do_layout_deferred_sections): New function. (Sized_relobj::do_layout_deferred_sections): New function. (Sized_relobj::layout_section): New function. (Sized_relobj::Deferred_layout): New structure. (Sized_relobj::deferred_layout_): New field. * plugin.cc (Plugin_manager::finish): Renamed, was cleanup. Change all callers. Layout deferred sections. (class Plugin_finish): Renamed, was Plugin_cleanup. Change all references. (Plugin_hook::run): Move code from do_plugin_hook inline. (Plugin_hook::do_plugin_hook): Remove. * plugin.h (Plugin_manager::Plugin_manager): Add missing initializers. (Plugin_manager::finish): Renamed, was cleanup. (Plugin_manager::should_defer_layout): New function. (Plugin_manager::add_deferred_layout_object): New function. (Plugin_manager::Deferred_layout_list): New type. (Plugin_manager::deferred_layout_objects_): New field. (Plugin_hook::do_plugin_hook): Remove. --- gold/object.h | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'gold/object.h') diff --git a/gold/object.h b/gold/object.h index fcb5d31..6c8c7a3 100644 --- a/gold/object.h +++ b/gold/object.h @@ -671,7 +671,7 @@ class Relobj : public Object { return this->do_output_section_offset(shndx); } // Set the offset of an input section within its output section. - virtual void + void set_section_offset(unsigned int shndx, uint64_t off) { this->do_set_section_offset(shndx, off); } @@ -712,6 +712,12 @@ class Relobj : public Object return (*this->map_to_relocatable_relocs_)[reloc_shndx]; } + // Layout sections whose layout was deferred while waiting for + // input files from a plugin. + void + layout_deferred_sections(Layout* layout) + { this->do_layout_deferred_sections(layout); } + protected: // The output section to be used for each input section, indexed by // the input section number. The output section is NULL if the @@ -764,6 +770,11 @@ class Relobj : public Object virtual void do_set_section_offset(unsigned int shndx, uint64_t off) = 0; + // Layout sections whose layout was deferred while waiting for + // input files from a plugin--implemented by child class. + virtual void + do_layout_deferred_sections(Layout*) = 0; + // Return the vector mapping input sections to output sections. Output_sections& output_sections() @@ -1368,6 +1379,11 @@ class Sized_relobj : public Relobj void do_layout(Symbol_table*, Layout*, Read_symbols_data*); + // Layout sections whose layout was deferred while waiting for + // input files from a plugin. + void + do_layout_deferred_sections(Layout*); + // Add the symbols to the symbol table. void do_add_symbols(Symbol_table*, Read_symbols_data*); @@ -1558,6 +1574,12 @@ class Sized_relobj : public Relobj include_linkonce_section(Layout*, unsigned int, const char*, const elfcpp::Shdr&); + // Layout an input section. + void + layout_section(Layout* layout, unsigned int shndx, const char* name, + typename This::Shdr& shdr, unsigned int reloc_shndx, + unsigned int reloc_type); + // Views and sizes when relocating. struct View_size { @@ -1681,6 +1703,25 @@ class Sized_relobj : public Relobj }; typedef Unordered_map Local_tls_got_offsets; + // Saved information for sections whose layout was deferred. + struct Deferred_layout + { + static const int shdr_size = elfcpp::Elf_sizes::shdr_size; + Deferred_layout(unsigned int shndx, const char* name, + const unsigned char* pshdr, + unsigned int reloc_shndx, unsigned int reloc_type) + : shndx_(shndx), name_(name), reloc_shndx_(reloc_shndx), + reloc_type_(reloc_type) + { + memcpy(this->shdr_data_, pshdr, shdr_size); + } + unsigned int shndx_; + std::string name_; + unsigned int reloc_shndx_; + unsigned int reloc_type_; + unsigned char shdr_data_[shdr_size]; + }; + // General access to the ELF file. elfcpp::Elf_file elf_file_; // Index of SHT_SYMTAB section. @@ -1715,6 +1756,8 @@ class Sized_relobj : public Relobj Comdat_group_table comdat_groups_; // Whether this object has a GNU style .eh_frame section. bool has_eh_frame_; + // The list of sections whose layout was deferred. + std::vector deferred_layout_; }; // A class to manage the list of all objects. -- cgit v1.1