summaryrefslogtreecommitdiff
path: root/rld-symbols.h
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2012-11-17 17:34:33 +1100
committerChris Johns <chrisj@rtems.org>2012-11-17 17:34:33 +1100
commit7ee957ca2f579802b4823ad562f05bd27ad425e1 (patch)
tree5f085ca653f2d80496e984b978b556b561127064 /rld-symbols.h
parentd68833ada79a4255e95017b44f73dcb21c7a7701 (diff)
Refactor the ELF support to allow ELF write suppport.
The refactoring allows better reuse of the ELF support and cleans up some hacks from the generic file and archive handling improving the separation of the file handling from the file format, ie ELF. The handling of ELF object files and ELF object files inside archives is cleaner. The refactor cleaned up the symbol handling where the symbols now reside in the ELF file object and references are take in symbol pointer containers and symbol table containers. The main purpose of the refactor is to allow support for creating and writing ELF files. Also added an rtems-syms command where special symbol support can be added.
Diffstat (limited to 'rld-symbols.h')
-rw-r--r--rld-symbols.h77
1 files changed, 52 insertions, 25 deletions
diff --git a/rld-symbols.h b/rld-symbols.h
index ec6938d..f566efe 100644
--- a/rld-symbols.h
+++ b/rld-symbols.h
@@ -1,10 +1,10 @@
/*
- * Copyright (c) 2011, Chris Johns <chrisj@rtems.org>
+ * Copyright (c) 2011, Chris Johns <chrisj@rtems.org>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@@ -58,27 +58,27 @@ namespace rld
/**
* Construct an exported symbol with a object file.
*/
- symbol (const std::string& name,
- rld::files::object& object,
+ symbol (const std::string& name,
+ files::object& object,
const elf::elf_sym& esym);
/**
* Construct an unresolved symbol with no object file.
*/
symbol (const std::string& name, const elf::elf_sym& esym);
-
+
/**
* Construct a linker symbol that is internally created.
*/
symbol (const std::string& name,
const elf::elf_addr value);
-
+
/**
* Construct a linker symbol that is internally created.
*/
- symbol (const char* name,
- rld::elf::elf_addr value = 0);
-
+ symbol (const char* name,
+ elf::elf_addr value = 0);
+
/**
* The symbol's name.
*/
@@ -95,20 +95,35 @@ namespace rld
bool is_cplusplus () const;
/**
+ * The symbol's type.
+ */
+ int type () const;
+
+ /**
+ * The symbol's binding, ie local, weak, or global.
+ */
+ int binding () const;
+
+ /**
+ * The synbol's section index.
+ */
+ int index () const;
+
+ /**
* The symbol's object file name.
*/
- rld::files::object* object () const;
+ files::object* object () const;
/**
* Set the symbol's object file name. Used when resolving unresolved
* symbols.
*/
- void set_object (rld::files::object& obj);
+ void set_object (files::object& obj);
/**
* The ELF symbol.
*/
- const ::GElf_Sym& esym () const;
+ const elf::elf_sym& esym () const;
/**
* Return the number of references.
@@ -133,28 +148,39 @@ namespace rld
void output (std::ostream& out) const;
private:
- std::string name_; //< The name of the symbol.
- std::string demangled_; //< If a C++ symbol the demangled name.
- rld::files::object* object_; //< The object file containing the
- // symbol.
- ::GElf_Sym esym_; //< The ELF symbol.
- int references_; //< The number of times if it referenced.
+
+ std::string name_; //< The name of the symbol.
+ std::string demangled_; //< If a C++ symbol the demangled name.
+ files::object* object_; //< The object file containing the symbol.
+ elf::elf_sym esym_; //< The ELF symbol.
+ int references_; //< The number of times if it referenced.
};
/**
- * List of symbol references.
+ * Container of symbols. A bucket of symbols.
+ */
+ typedef std::list < symbol > bucket;
+
+ /**
+ * References to symbols. Should always point to symbols held in a bucket.
+ */
+ typedef std::list < symbol* > pointers;
+
+ /**
+ * A symbols table is a map container of symbols. Should always point to
+ * symbols held in a bucket.
*/
- typedef std::list < symbol* > list;
+ typedef std::map < std::string, symbol* > table;
/**
- * A symbols table is a map container of symbols.
+ * Load a table from a buckey.
*/
- typedef std::map < std::string, symbol > table;
+ void load (bucket& bucket_, table& table_);
/**
- * Given a list of symbols return how many are referenced.
+ * Given a container of symbols return how many are referenced.
*/
- size_t referenced (list& symbols);
+ size_t referenced (pointers& symbols);
/**
* Output the symbol table.
@@ -166,7 +192,8 @@ namespace rld
/**
* Output stream operator.
*/
-static inline std::ostream& operator<< (std::ostream& out, const rld::symbols::symbol& sym) {
+static inline std::ostream& operator<< (std::ostream& out,
+ const rld::symbols::symbol& sym) {
sym.output (out);
return out;
}