aboutsummaryrefslogtreecommitdiff
path: root/gold/object.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2008-07-22 22:08:43 +0000
committerIan Lance Taylor <ian@airs.com>2008-07-22 22:08:43 +0000
commit92de84a60cbdb80b808c8571e709c1384c6ee6fc (patch)
tree850dc6691e2bef093d847da5d35241b98b04e2ea /gold/object.h
parent3f7c5e1d995c658ef8709e5fae244f25434db931 (diff)
downloadgdb-92de84a60cbdb80b808c8571e709c1384c6ee6fc.zip
gdb-92de84a60cbdb80b808c8571e709c1384c6ee6fc.tar.gz
gdb-92de84a60cbdb80b808c8571e709c1384c6ee6fc.tar.bz2
* cref.cc: New file.
* cref.h: New file. * options.h (class General_options): Add --print-symbol-counts. * main.cc (main): Issue defined symbol report if requested. * archive.cc (Archive::interpret_header): Make into a const member function. (Archive::add_symbols): Call Input_objects::archive_start and archive_stop. (Archive::const_iterator): Define new class. (Archive::begin, Archive::end): New functions. (Archive::include_all_members): Rewrite to use iterator. (Archive::count_members): New function. * archive.h (class Archive): Update declarations. (Archive::filename): New function. * object.cc: Include "cref.h". (Sized_relobj::Sized_relobj): Initialize defined_count_. (Sized_relobj::do_get_global_symbol_counts): New function. (Input_objects::add_object): Add object to cross-referencer. (Input_objects::archive_start): New function. (Input_objects::archive_stop): New function. (Input_objects::print_symbol_counts): New function. * object.h: Declare Cref and Archive. (Object::get_global_symbol_counts): New function. (Object::do_get_global_symbol_counts): New pure virtual function. (class Sized_relobj): Add defined_count_ field. Update declarations. (class Input_objects): Add cref_ field. Update constructor. Update declarations. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and defined_count_. (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing symbol counts. (Sized_dynobj::do_get_global_symbol_counts): New function. * dynobj.h (class Sized_dynobj): Add fields symbols_ and defined_count_. Update declarations. Define Symbols typedef. * symtab.cc (Symbol_table::add_from_relobj): Add defined parameter. Change all callers. (Symbol_table::add_from_dynobj): Add sympointers and defined parameters. Change all callers. * symtab.h (class Symbol_table): Update declarations. * Makefile.am (CCFILES): Add cref.cc. (HFILES): Add cref.h. * Makefile.in: Rebuild.
Diffstat (limited to 'gold/object.h')
-rw-r--r--gold/object.h37
1 files changed, 36 insertions, 1 deletions
diff --git a/gold/object.h b/gold/object.h
index df509b2..7334492 100644
--- a/gold/object.h
+++ b/gold/object.h
@@ -36,6 +36,8 @@ namespace gold
class General_options;
class Task;
+class Cref;
+class Archive;
class Layout;
class Output_section;
class Output_file;
@@ -421,6 +423,14 @@ class Object
clear_view_cache_marks()
{ this->input_file()->file().clear_view_cache_marks(); }
+ // Get the number of global symbols defined by this object, and the
+ // number of the symbols whose final definition came from this
+ // object.
+ void
+ get_global_symbol_counts(const Symbol_table* symtab, size_t* defined,
+ size_t* used) const
+ { this->do_get_global_symbol_counts(symtab, defined, used); }
+
protected:
// Read the symbols--implemented by child class.
virtual void
@@ -476,6 +486,10 @@ class Object
virtual Xindex*
do_initialize_xindex() = 0;
+ // Implement get_global_symbol_counts--implemented by child class.
+ virtual void
+ do_get_global_symbol_counts(const Symbol_table*, size_t*, size_t*) const = 0;
+
// Get the file. We pass on const-ness.
Input_file*
input_file()
@@ -1395,6 +1409,10 @@ class Sized_relobj : public Relobj
Xindex*
do_initialize_xindex();
+ // Get symbol counts.
+ void
+ do_get_global_symbol_counts(const Symbol_table*, size_t*, size_t*) const;
+
// Get the offset of a section.
uint64_t
do_output_section_offset(unsigned int shndx) const
@@ -1628,6 +1646,8 @@ class Sized_relobj : public Relobj
unsigned int output_local_dynsym_count_;
// The entries in the symbol table for the external symbols.
Symbols symbols_;
+ // Number of symbols defined in object file itself.
+ size_t defined_count_;
// File offset for local symbols.
off_t local_symbol_offset_;
// File offset for local dynamic symbols.
@@ -1655,7 +1675,8 @@ class Input_objects
{
public:
Input_objects()
- : relobj_list_(), dynobj_list_(), sonames_(), system_library_directory_()
+ : relobj_list_(), dynobj_list_(), sonames_(), system_library_directory_(),
+ cref_(NULL)
{ }
// The type of the list of input relocateable objects.
@@ -1671,6 +1692,14 @@ class Input_objects
bool
add_object(Object*);
+ // Start processing an archive.
+ void
+ archive_start(Archive*);
+
+ // Stop processing an archive.
+ void
+ archive_stop(Archive*);
+
// For each dynamic object, check whether we've seen all of its
// explicit dependencies.
void
@@ -1681,6 +1710,10 @@ class Input_objects
bool
found_in_system_library_directory(const Object*) const;
+ // Print symbol counts.
+ void
+ print_symbol_counts(const Symbol_table*) const;
+
// Iterate over all regular objects.
Relobj_iterator
@@ -1723,6 +1756,8 @@ class Input_objects
Unordered_set<std::string> sonames_;
// The directory in which we find the libc.so.
std::string system_library_directory_;
+ // Manage cross-references if requested.
+ Cref* cref_;
};
// Some of the information we pass to the relocation routines. We