1 // dynobj.h -- dynamic object support for gold -*- C++ -*-
13 // A dynamic object (ET_DYN). This is an abstract base class itself.
14 // The implementations is the template class Sized_dynobj.
16 class Dynobj : public Object
19 Dynobj(const std::string& name, Input_file* input_file, off_t offset = 0)
20 : Object(name, input_file, true, offset)
24 // A dynamic object, size and endian specific version.
26 template<int size, bool big_endian>
27 class Sized_dynobj : public Dynobj
30 Sized_dynobj(const std::string& name, Input_file* input_file, off_t offset,
31 const typename elfcpp::Ehdr<size, big_endian>&);
33 // Set up the object file based on the ELF header.
35 setup(const typename elfcpp::Ehdr<size, big_endian>&);
39 do_read_symbols(Read_symbols_data*);
41 // Lay out the input sections.
43 do_layout(const General_options&, Symbol_table*, Layout*,
46 // Add the symbols to the symbol table.
48 do_add_symbols(Symbol_table*, Read_symbols_data*);
50 // Get the name of a section.
52 do_section_name(unsigned int shndx)
53 { return this->elf_file_.section_name(shndx); }
55 // Return a view of the contents of a section. Set *PLEN to the
58 do_section_contents(unsigned int shndx)
59 { return this->elf_file_.section_contents(shndx); }
63 typedef Sized_dynobj<size, big_endian> This;
64 static const int shdr_size = elfcpp::Elf_sizes<size>::shdr_size;
65 static const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
66 static const int dyn_size = elfcpp::Elf_sizes<size>::dyn_size;
67 typedef elfcpp::Shdr<size, big_endian> Shdr;
68 typedef elfcpp::Dyn<size, big_endian> Dyn;
70 // Find the dynamic symbol table and the version sections, given the
73 find_dynsym_sections(const unsigned char* pshdrs,
74 unsigned int* pdynshm_shndx,
75 unsigned int* pversym_shndx,
76 unsigned int* pverdef_shndx,
77 unsigned int* pverneed_shndx,
78 unsigned int* pdynamic_shndx);
80 // Read the dynamic symbol section SHNDX.
82 read_dynsym_section(const unsigned char* pshdrs, unsigned int shndx,
83 elfcpp::SHT type, unsigned int link,
84 File_view** view, off_t* view_size,
85 unsigned int* view_info);
87 // Set the SONAME from the SHT_DYNAMIC section at DYNAMIC_SHNDX.
88 // The STRTAB parameters may have the relevant string table.
90 set_soname(const unsigned char* pshdrs, unsigned int dynamic_shndx,
91 unsigned int strtab_shndx, const unsigned char* strtabu,
94 // Mapping from version number to version name.
95 typedef std::vector<const char*> Version_map;
97 // Create the version map.
99 make_version_map(Read_symbols_data* sd, Version_map*) const;
101 // Add an entry to the version map.
103 set_version_map(Version_map*, unsigned int ndx, const char* name) const;
105 // General access to the ELF file.
106 elfcpp::Elf_file<size, big_endian, Object> elf_file_;
107 // The DT_SONAME name, if any.
111 } // End namespace gold.
113 #endif // !defined(GOLD_DYNOBJ_H)