aboutsummaryrefslogtreecommitdiff
path: root/gold/dynobj.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2006-11-14 19:21:05 +0000
committerIan Lance Taylor <iant@google.com>2006-11-14 19:21:05 +0000
commitdbe717effbdf31236088837f4686fd5ad5e71893 (patch)
treefd5ed267334d62fadcaf7ff7132c0a7287553ed8 /gold/dynobj.h
parent6c73cbb1d9a26d1c4d9bd5464832846b7c049b9d (diff)
downloadgdb-dbe717effbdf31236088837f4686fd5ad5e71893.zip
gdb-dbe717effbdf31236088837f4686fd5ad5e71893.tar.gz
gdb-dbe717effbdf31236088837f4686fd5ad5e71893.tar.bz2
More dynamic object support, initial scripting support.
Diffstat (limited to 'gold/dynobj.h')
-rw-r--r--gold/dynobj.h67
1 files changed, 62 insertions, 5 deletions
diff --git a/gold/dynobj.h b/gold/dynobj.h
index 99e7883..04a2c63 100644
--- a/gold/dynobj.h
+++ b/gold/dynobj.h
@@ -3,6 +3,8 @@
#ifndef GOLD_DYNOBJ_H
#define GOLD_DYNOBJ_H
+#include <vector>
+
#include "object.h"
namespace gold
@@ -28,6 +30,10 @@ class Sized_dynobj : public Dynobj
Sized_dynobj(const std::string& name, Input_file* input_file, off_t offset,
const typename elfcpp::Ehdr<size, big_endian>&);
+ // Set up the object file based on the ELF header.
+ void
+ setup(const typename elfcpp::Ehdr<size, big_endian>&);
+
// Read the symbols.
void
do_read_symbols(Read_symbols_data*);
@@ -41,14 +47,65 @@ class Sized_dynobj : public Dynobj
void
do_add_symbols(Symbol_table*, Read_symbols_data*);
+ // Get the name of a section.
+ std::string
+ do_section_name(unsigned int shndx)
+ { return this->elf_file_.section_name(shndx); }
+
// Return a view of the contents of a section. Set *PLEN to the
// size.
- const unsigned char*
- do_section_contents(unsigned int shnum, off_t* plen) = 0;
+ Object::Location
+ do_section_contents(unsigned int shndx)
+ { return this->elf_file_.section_contents(shndx); }
- // Get the name of a section.
- std::string
- do_section_name(unsigned int shnum);
+ private:
+ // For convenience.
+ typedef Sized_dynobj<size, big_endian> This;
+ static const int shdr_size = elfcpp::Elf_sizes<size>::shdr_size;
+ static const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
+ static const int dyn_size = elfcpp::Elf_sizes<size>::dyn_size;
+ typedef elfcpp::Shdr<size, big_endian> Shdr;
+ typedef elfcpp::Dyn<size, big_endian> Dyn;
+
+ // Find the dynamic symbol table and the version sections, given the
+ // section headers.
+ void
+ find_dynsym_sections(const unsigned char* pshdrs,
+ unsigned int* pdynshm_shndx,
+ unsigned int* pversym_shndx,
+ unsigned int* pverdef_shndx,
+ unsigned int* pverneed_shndx,
+ unsigned int* pdynamic_shndx);
+
+ // Read the dynamic symbol section SHNDX.
+ void
+ read_dynsym_section(const unsigned char* pshdrs, unsigned int shndx,
+ elfcpp::SHT type, unsigned int link,
+ File_view** view, off_t* view_size,
+ unsigned int* view_info);
+
+ // Set the SONAME from the SHT_DYNAMIC section at DYNAMIC_SHNDX.
+ // The STRTAB parameters may have the relevant string table.
+ void
+ set_soname(const unsigned char* pshdrs, unsigned int dynamic_shndx,
+ unsigned int strtab_shndx, const unsigned char* strtabu,
+ off_t strtab_size);
+
+ // Mapping from version number to version name.
+ typedef std::vector<const char*> Version_map;
+
+ // Create the version map.
+ void
+ make_version_map(Read_symbols_data* sd, Version_map*) const;
+
+ // Add an entry to the version map.
+ void
+ set_version_map(Version_map*, unsigned int ndx, const char* name) const;
+
+ // General access to the ELF file.
+ elfcpp::Elf_file<size, big_endian, Object> elf_file_;
+ // The DT_SONAME name, if any.
+ std::string soname_;
};
} // End namespace gold.