From: William C. <wc...@us...> - 2004-09-22 13:40:09
|
Update of /cvsroot/oprofile/oprofile/libutil++ In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4126/libutil++ Modified Files: op_bfd.h op_bfd.cpp Log Message: Add logic to use the preferred symbol name. Index: op_bfd.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/libutil++/op_bfd.h,v retrieving revision 1.32 retrieving revision 1.33 diff -u -p -d -r1.32 -r1.33 --- op_bfd.h 11 Sep 2004 17:46:16 -0000 1.32 +++ op_bfd.h 22 Sep 2004 13:39:58 -0000 1.33 @@ -50,6 +50,8 @@ public: asymbol const * symbol() const { return bfd_symbol; } size_t size() const { return symb_size; } void size(size_t s) { symb_size = s; } + bool hidden() const { return symb_hidden; } + bool weak() const { return symb_weak; } /// compare two symbols by their filepos() bool operator<(op_bfd_symbol const & lhs) const; @@ -69,6 +71,10 @@ private: size_t symb_size; /// the name of the symbol std::string symb_name; + /// normally not externally visible symbol + bool symb_hidden; + /// whether other symbols can override it + bool symb_weak; }; /** Index: op_bfd.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/libutil++/op_bfd.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -u -p -d -r1.54 -r1.55 --- op_bfd.cpp 12 Aug 2004 19:35:56 -0000 1.54 +++ op_bfd.cpp 22 Sep 2004 13:39:58 -0000 1.55 @@ -259,6 +259,9 @@ op_bfd_symbol::op_bfd_symbol(asymbol con // we name the symbol after the section. if (a->name && a->name[0] != '\0') { symb_name = a->name; + symb_weak = a->flags & BSF_WEAK; + symb_hidden = (a->flags & BSF_LOCAL) + && !(a->flags & BSF_GLOBAL); } else { symb_name = string("??") + a->section->name; } @@ -434,19 +437,27 @@ bool interesting_symbol(asymbol * sym) } /** - * return true if the symbol is boring, boring symbol are eliminated - * when multiple symbol exist at the same vma + * return true if the first symbol is less interesting than the second symbol + * boring symbol are eliminated when multiple symbol exist at the same vma */ -bool boring_symbol(string const & name) +bool boring_symbol(op_bfd_symbol const & first, op_bfd_symbol const & second) { // FIXME: check if we can't do a better job, this heuristic fix all // case I'm aware - if (name == "Letext") + if (first.name() == "Letext") return true; - if (name.substr(0, 2) == "??") + if (first.name().substr(0, 2) == "??") return true; + // checking to see if first symbol for the vma + // is less interesting than second symbol + if ((first.hidden() && !second.hidden()) + || (first.name()[0] == '_' && second.name()[0] != '_') + || (first.name()[0] != '_' && second.name()[0] != '_' + && (first.weak() && !second.weak()))) + return true; + return false; } @@ -527,7 +538,7 @@ void op_bfd::get_symbols(op_bfd::symbols symbols_found_t::iterator temp = it; ++temp; if (temp != symbols.end() && (it->vma() == temp->vma())) { - if (boring_symbol(it->name())) { + if (boring_symbol(*it, *temp)) { it = symbols.erase(it); } else { symbols.erase(temp); |