Comparing aliases of the same symbol must be done by pointer

Different aliases of the same symbol are considered equal.  This is at
least how the elf_symbol::operator== is intended to work.

What makes the different aliases be different is their pointer value.
This patch fixes several spots where these assumptions are not
respected.

	* src/abg-ir.cc (elf_symbol::operator==): Fix thinko and
	indentation.  What was I thinking ...
	(elf_symbol::add_alias)
	(compute_aliases_for_elf_symbol): Do not compare aliases using the
	equality operator, because it considers all aliases of a given
	symbol as equal.  Rather, use elf_symbol::is_main_symbol() to test
	if an alias is the main symbol alias.
	* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
	Likewise.
	* src/abg-corpus.cc
	(corpus::priv::build_unreferenced_symbols_tables): Likewise.
	* src/abg-writer.cc (write_elf_symbol_aliases): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2016-01-25 15:19:59 +01:00
parent 066ebbdf0e
commit 8c1acaeb08
4 changed files with 13 additions and 14 deletions

View File

@ -226,7 +226,7 @@ function_name_changed_but_not_symbol(const function_decl_sptr f,
if (fs == ss)
return true;
for (elf_symbol_sptr s = fs->get_next_alias();
s && s != fs->get_main_symbol();
s && !s->is_main_symbol();
s = s->get_next_alias())
if (*s == *ss)
return true;

View File

@ -1015,7 +1015,7 @@ corpus::priv::build_unreferenced_symbols_tables()
{
refed_funs[sym->get_id_string()] = true;
for (elf_symbol_sptr a = sym->get_next_alias();
a && (a != sym->get_main_symbol());
a && !a->is_main_symbol();
a = a->get_next_alias())
refed_funs[a->get_id_string()] = true;
}
@ -1027,7 +1027,7 @@ corpus::priv::build_unreferenced_symbols_tables()
{
refed_vars[sym->get_id_string()] = true;
for (elf_symbol_sptr a = sym->get_next_alias();
a && a != sym->get_main_symbol();
a && !a->is_main_symbol();
a = a->get_next_alias())
refed_vars[a->get_id_string()] = true;
}

View File

@ -1158,10 +1158,10 @@ elf_symbol::add_alias(const elf_symbol_sptr& alias)
{
elf_symbol_sptr last_alias;
for (elf_symbol_sptr a = get_next_alias();
a && (a.get() != get_main_symbol().get());
a && !a->is_main_symbol();
a = a->get_next_alias())
{
if (a->get_next_alias().get() == get_main_symbol().get())
if (a->get_next_alias()->is_main_symbol())
{
assert(last_alias == 0);
last_alias = a;
@ -1457,10 +1457,9 @@ bool
elf_symbol::operator==(const elf_symbol& other) const
{
bool are_equal = textually_equals(*this, other);
return are_equal;
if (!are_equal)
are_equal = get_alias_which_equals(other);
return are_equal;
return are_equal;
}
/// Test if the current symbol aliases another one.
@ -1478,7 +1477,7 @@ elf_symbol::does_alias(const elf_symbol& o) const
return true;
for (elf_symbol_sptr a = get_next_alias();
a && a!= get_main_symbol();
a && !a->is_main_symbol();
a = a->get_next_alias())
{
if (o == *a)
@ -1517,7 +1516,7 @@ compute_aliases_for_elf_symbol(const elf_symbol& sym,
{
if (elf_symbol_sptr a = sym.get_next_alias())
for (; a != sym.get_main_symbol(); a = a->get_next_alias())
for (; a && !a->is_main_symbol(); a = a->get_next_alias())
aliases.push_back(a);
else
for (string_elf_symbols_map_type::const_iterator i = symtab.begin();
@ -1529,12 +1528,12 @@ compute_aliases_for_elf_symbol(const elf_symbol& sym,
{
if (**j == sym)
for (elf_symbol_sptr s = (*j)->get_next_alias();
s && s != (*j)->get_main_symbol();
s && !s->is_main_symbol();
s = s->get_next_alias())
aliases.push_back(s);
else
for (elf_symbol_sptr s = (*j)->get_next_alias();
s && s != (*j)->get_main_symbol();
s && !s->is_main_symbol();
s = s->get_next_alias())
if (*s == sym)
aliases.push_back(*j);

View File

@ -930,10 +930,10 @@ write_elf_symbol_aliases(const elf_symbol& sym, ostream& o)
!s->is_main_symbol();
s = s->get_next_alias())
{
if (s->get_next_alias() == s->get_main_symbol())
o << s->get_id_string() << "'";
if (s->get_next_alias()->is_main_symbol())
o << s->get_id_string() << "'";
else
o << s->get_id_string() << ",";
o << s->get_id_string() << ",";
emitted = true;
}