summaryrefslogtreecommitdiff
path: root/src/elflint.c
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2015-03-09 16:41:48 +0100
committerMark Wielaard <mjw@redhat.com>2015-03-13 09:41:25 +0100
commitae9aa3e4b2853d58598a6928eb1dbaacf6488496 (patch)
treea42fcfbe44bda3650e5f49f0a8aa22b5114e02ff /src/elflint.c
parent0ff3e49f3381ca9613fe83456d3a20a94977c5c6 (diff)
downloadelfutils-ae9aa3e4b2853d58598a6928eb1dbaacf6488496.tar.gz
elflint: Correct gnu_symbias usage in compare_hash_gnu_hash.
commit 0a545e "elflint: Add various low-level checks." introduced a bug in the handling of the gnu_symbias. The symbol in the bucket should first be compared to STN_UNDEF before applying the bias. And the used symbol index should have the bias added when compared against plain hash symbol. Found on Debian wheezy with run-elflint-self.sh. Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'src/elflint.c')
-rw-r--r--src/elflint.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/elflint.c b/src/elflint.c
index 143424c6..a6f9b688 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -2397,20 +2397,22 @@ hash section [%2zu] '%s' uses too much data\n"),
for (Elf32_Word cnt = 0; cnt < gnu_nbucket; ++cnt)
{
- Elf32_Word symidx = gnu_bucket[cnt] - gnu_symbias;;
- if (symidx != STN_UNDEF)
- do
- {
- if (symidx >= max_nsyms || symidx >= nentries)
- {
- ERROR (gettext ("\
-hash section [%2zu] '%s' invalid symbol index\n"),
- gnu_hash_idx, gnu_hash_name);
- return;
- }
- used[symidx] |= 1;
- }
- while ((gnu_chain[symidx++] & 1u) == 0);
+ if (gnu_bucket[cnt] != STN_UNDEF)
+ {
+ Elf32_Word symidx = gnu_bucket[cnt] - gnu_symbias;
+ do
+ {
+ if (symidx >= max_nsyms || symidx + gnu_symbias >= nentries)
+ {
+ ERROR (gettext ("\
+hash section [%2zu] '%s' invalid symbol index %" PRIu32 " (max_nsyms: %" PRIu32 ", nentries: %" PRIu32 "\n"),
+ gnu_hash_idx, gnu_hash_name, symidx, max_nsyms, nentries);
+ return;
+ }
+ used[symidx + gnu_symbias] |= 1;
+ }
+ while ((gnu_chain[symidx++] & 1u) == 0);
+ }
}
/* Now go over the old hash table and check that we cover the same