summaryrefslogtreecommitdiff
path: root/rld-symbols.h
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2012-12-29 10:20:22 +1100
committerChris Johns <chrisj@rtems.org>2012-12-29 10:20:22 +1100
commitcc54579b0b54bd349f1d69f40aa89607e32bf614 (patch)
tree8d5fef66763090ebab459497d7302d0111b8e988 /rld-symbols.h
parent0123e92cdeb732ae20c3a69047c7d05877cb0318 (diff)
Fix managing weak symbols.
Weak symbols where not being managed correctly. The symbols table is now a class with externals and weaks as separate symtabs so the externals can be searched first then the weaks and if not found an unresolved error is raised. This was found creating a libbsdport RAP file where the drivers in the all driver table resolved to the weak symbols and so linking in nothing. Fixing the weak symbols as found in the libbsdport library triggered a new resolver bug. The object files now contain the resolver state and this is used to determine if an object file has been resolved or is currently being resolved avoiding rescursive loops with dependent object files. The resolver trace output is a little easier to read.
Diffstat (limited to 'rld-symbols.h')
-rw-r--r--rld-symbols.h81
1 files changed, 80 insertions, 1 deletions
diff --git a/rld-symbols.h b/rld-symbols.h
index e602e36..5405d2f 100644
--- a/rld-symbols.h
+++ b/rld-symbols.h
@@ -187,7 +187,76 @@ namespace rld
* A symbols table is a map container of symbols. Should always point to
* symbols held in a bucket.
*/
- typedef std::map < std::string, symbol* > table;
+ typedef std::map < std::string, symbol* > symtab;
+
+ /**
+ * A symbols contains a symbol table of externals and weak symbols.
+ */
+ class table
+ {
+ public:
+ /**
+ * Construct a table.
+ */
+ table ();
+
+ /**
+ * Destruct a table.
+ */
+ ~table ();
+
+ /**
+ * Add an external symbol.
+ */
+ void add_external (symbol& sym);
+
+ /**
+ * Add a weak symbol.
+ */
+ void add_weak (symbol& sym);
+
+ /**
+ * Find an external symbol.
+ */
+ symbol* find_external (const std::string& name);
+
+ /**
+ * Find an weak symbol.
+ */
+ symbol* find_weak (const std::string& name);
+
+ /**
+ * Return the size of the symbols loaded.
+ */
+ size_t size () const;
+
+ /**
+ * Return the externals symbol table.
+ */
+ const symtab& externals () const;
+
+ /**
+ * Return the weaks symbol table.
+ */
+ const symtab& weaks () const;
+
+ private:
+
+ /**
+ * Cannot copy a table.
+ */
+ table (const table& orig);
+
+ /**
+ * A table of external symbols.
+ */
+ symtab _externals;
+
+ /**
+ * A table of weak symbols.
+ */
+ symtab _weaks;
+ };
/**
* Load a table from a buckey.
@@ -195,6 +264,11 @@ namespace rld
void load (bucket& bucket_, table& table_);
/**
+ * Load a table from a buckey.
+ */
+ void load (bucket& bucket_, symtab& table_);
+
+ /**
* Given a container of symbols return how many are referenced.
*/
size_t referenced (pointers& symbols);
@@ -203,6 +277,11 @@ namespace rld
* Output the symbol table.
*/
void output (std::ostream& out, const table& symbols);
+
+ /**
+ * Output the symbol table.
+ */
+ void output (std::ostream& out, const symtab& symbols);
}
}