aboutsummaryrefslogtreecommitdiff
path: root/gold/symtab.cc
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/symtab.cc
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/symtab.cc')
-rw-r--r--gold/symtab.cc53
1 files changed, 43 insertions, 10 deletions
diff --git a/gold/symtab.cc b/gold/symtab.cc
index f9bbcc0..03e592e 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -835,8 +835,11 @@ Symbol_table::add_from_relobj(
size_t symndx_offset,
const char* sym_names,
size_t sym_name_size,
- typename Sized_relobj<size, big_endian>::Symbols* sympointers)
+ typename Sized_relobj<size, big_endian>::Symbols* sympointers,
+ size_t *defined)
{
+ *defined = 0;
+
gold_assert(size == relobj->target()->get_size());
gold_assert(size == parameters->target().get_size());
@@ -847,6 +850,8 @@ Symbol_table::add_from_relobj(
const unsigned char* p = syms;
for (size_t i = 0; i < count; ++i, p += sym_size)
{
+ (*sympointers)[i] = NULL;
+
elfcpp::Sym<size, big_endian> sym(p);
unsigned int st_name = sym.get_st_name();
@@ -867,6 +872,9 @@ Symbol_table::add_from_relobj(
if (!is_ordinary)
orig_st_shndx = elfcpp::SHN_UNDEF;
+ if (st_shndx != elfcpp::SHN_UNDEF)
+ ++*defined;
+
// A symbol defined in a section which we are not including must
// be treated as an undefined symbol.
if (st_shndx != elfcpp::SHN_UNDEF
@@ -977,8 +985,12 @@ Symbol_table::add_from_dynobj(
size_t sym_name_size,
const unsigned char* versym,
size_t versym_size,
- const std::vector<const char*>* version_map)
+ const std::vector<const char*>* version_map,
+ typename Sized_relobj<size, big_endian>::Symbols* sympointers,
+ size_t* defined)
{
+ *defined = 0;
+
gold_assert(size == dynobj->target()->get_size());
gold_assert(size == parameters->target().get_size());
@@ -1012,6 +1024,9 @@ Symbol_table::add_from_dynobj(
{
elfcpp::Sym<size, big_endian> sym(p);
+ if (sympointers != NULL)
+ (*sympointers)[i] = NULL;
+
// Ignore symbols with local binding or that have
// internal or hidden visibility.
if (sym.get_st_bind() == elfcpp::STB_LOCAL
@@ -1047,6 +1062,9 @@ Symbol_table::add_from_dynobj(
unsigned int st_shndx = dynobj->adjust_sym_shndx(i, psym->get_st_shndx(),
&is_ordinary);
+ if (st_shndx != elfcpp::SHN_UNDEF)
+ ++*defined;
+
Sized_symbol<size>* res;
if (versym == NULL)
@@ -1142,6 +1160,9 @@ Symbol_table::add_from_dynobj(
&& res->source() == Symbol::FROM_OBJECT
&& res->object() == dynobj)
object_symbols.push_back(res);
+
+ if (sympointers != NULL)
+ (*sympointers)[i] = res;
}
this->record_weak_aliases(&object_symbols);
@@ -2628,7 +2649,8 @@ Symbol_table::add_from_relobj<32, false>(
size_t symndx_offset,
const char* sym_names,
size_t sym_name_size,
- Sized_relobj<32, true>::Symbols* sympointers);
+ Sized_relobj<32, true>::Symbols* sympointers,
+ size_t* defined);
#endif
#ifdef HAVE_TARGET_32_BIG
@@ -2641,7 +2663,8 @@ Symbol_table::add_from_relobj<32, true>(
size_t symndx_offset,
const char* sym_names,
size_t sym_name_size,
- Sized_relobj<32, false>::Symbols* sympointers);
+ Sized_relobj<32, false>::Symbols* sympointers,
+ size_t* defined);
#endif
#ifdef HAVE_TARGET_64_LITTLE
@@ -2654,7 +2677,8 @@ Symbol_table::add_from_relobj<64, false>(
size_t symndx_offset,
const char* sym_names,
size_t sym_name_size,
- Sized_relobj<64, true>::Symbols* sympointers);
+ Sized_relobj<64, true>::Symbols* sympointers,
+ size_t* defined);
#endif
#ifdef HAVE_TARGET_64_BIG
@@ -2667,7 +2691,8 @@ Symbol_table::add_from_relobj<64, true>(
size_t symndx_offset,
const char* sym_names,
size_t sym_name_size,
- Sized_relobj<64, false>::Symbols* sympointers);
+ Sized_relobj<64, false>::Symbols* sympointers,
+ size_t* defined);
#endif
#ifdef HAVE_TARGET_32_LITTLE
@@ -2681,7 +2706,9 @@ Symbol_table::add_from_dynobj<32, false>(
size_t sym_name_size,
const unsigned char* versym,
size_t versym_size,
- const std::vector<const char*>* version_map);
+ const std::vector<const char*>* version_map,
+ Sized_relobj<32, false>::Symbols* sympointers,
+ size_t* defined);
#endif
#ifdef HAVE_TARGET_32_BIG
@@ -2695,7 +2722,9 @@ Symbol_table::add_from_dynobj<32, true>(
size_t sym_name_size,
const unsigned char* versym,
size_t versym_size,
- const std::vector<const char*>* version_map);
+ const std::vector<const char*>* version_map,
+ Sized_relobj<32, true>::Symbols* sympointers,
+ size_t* defined);
#endif
#ifdef HAVE_TARGET_64_LITTLE
@@ -2709,7 +2738,9 @@ Symbol_table::add_from_dynobj<64, false>(
size_t sym_name_size,
const unsigned char* versym,
size_t versym_size,
- const std::vector<const char*>* version_map);
+ const std::vector<const char*>* version_map,
+ Sized_relobj<64, false>::Symbols* sympointers,
+ size_t* defined);
#endif
#ifdef HAVE_TARGET_64_BIG
@@ -2723,7 +2754,9 @@ Symbol_table::add_from_dynobj<64, true>(
size_t sym_name_size,
const unsigned char* versym,
size_t versym_size,
- const std::vector<const char*>* version_map);
+ const std::vector<const char*>* version_map,
+ Sized_relobj<64, true>::Symbols* sympointers,
+ size_t* defined);
#endif
#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)