aboutsummaryrefslogtreecommitdiff
path: root/gold/common.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2008-03-27 19:57:41 +0000
committerIan Lance Taylor <ian@airs.com>2008-03-27 19:57:41 +0000
commit49bdd526aba04608f9658d5c36923e10a2021df3 (patch)
treecba9fcbc29d0d3c0ad337a07dbc015ec094af8a0 /gold/common.cc
parentf66d8205394d34c6b03821f93d27b202d20438d4 (diff)
downloadbinutils-49bdd526aba04608f9658d5c36923e10a2021df3.zip
binutils-49bdd526aba04608f9658d5c36923e10a2021df3.tar.gz
binutils-49bdd526aba04608f9658d5c36923e10a2021df3.tar.bz2
* common.cc (Sort_commons::operator): Correct sorting algorithm.
* testsuite/common_test_1.c: New file. * testsuite/Makefile.am (check_PROGRAMS): Add common_test_1. (common_test_1_SOURCES): New variable. (common_test_1_DEPENDENCIES): New variable. (common_test_1_LDFLAGS): New variable.
Diffstat (limited to 'gold/common.cc')
-rw-r--r--gold/common.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/gold/common.cc b/gold/common.cc
index f92637e..54b686d 100644
--- a/gold/common.cc
+++ b/gold/common.cc
@@ -93,19 +93,21 @@ Sort_commons<size>::operator()(const Symbol* pa, const Symbol* pb) const
const Sized_symbol<size>* psa = symtab->get_sized_symbol<size>(pa);
const Sized_symbol<size>* psb = symtab->get_sized_symbol<size>(pb);
+ // Sort by largest size first.
typename Sized_symbol<size>::Size_type sa = psa->symsize();
typename Sized_symbol<size>::Size_type sb = psb->symsize();
if (sa < sb)
return false;
- else if (sb > sa)
+ else if (sb < sa)
return true;
- // When the symbols are the same size, we sort them by alignment.
+ // When the symbols are the same size, we sort them by alignment,
+ // largest alignment first.
typename Sized_symbol<size>::Value_type va = psa->value();
typename Sized_symbol<size>::Value_type vb = psb->value();
if (va < vb)
return false;
- else if (vb > va)
+ else if (vb < va)
return true;
// Otherwise we stabilize the sort by sorting by name.