rmodtool: Increase limit on number of symbols

An internal index `i` was previously allocated as
Elf64_Half which is uint16_t.  Bumping to uint64_t
increases the number of allowed symbols and prevents
a segfault in processing a larger ramstage.debug file.
Also introduce a separate counter for the number of sections.

Change-Id: I9ad2f64c452cef2e7bf957f766600891cb5ae798
Signed-off-by: Damien Zammit <damien@zamaudio.com>
Reviewed-on: https://review.coreboot.org/21360
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
This commit is contained in:
Damien Zammit 2017-09-03 21:04:41 +10:00 committed by Martin Roth
parent 7bc0e42749
commit 0025247171
1 changed files with 6 additions and 5 deletions

View File

@ -435,7 +435,8 @@ symtab_read(const struct buffer *in, struct parsed_elf *pelf,
{
Elf64_Ehdr *ehdr;
Elf64_Shdr *shdr;
Elf64_Half i;
Elf64_Half shnum;
Elf64_Xword i;
Elf64_Xword nsyms;
Elf64_Sym *sym;
struct buffer b;
@ -443,17 +444,17 @@ symtab_read(const struct buffer *in, struct parsed_elf *pelf,
ehdr = &pelf->ehdr;
shdr = NULL;
for (i = 0; i < ehdr->e_shnum; i++) {
if (pelf->shdr[i].sh_type != SHT_SYMTAB)
for (shnum = 0; shnum < ehdr->e_shnum; shnum++) {
if (pelf->shdr[shnum].sh_type != SHT_SYMTAB)
continue;
if (shdr != NULL) {
ERROR("Multiple symbol sections found. %u and %u\n",
(unsigned int)(shdr - pelf->shdr), i);
(unsigned int)(shdr - pelf->shdr), shnum);
return -1;
}
shdr = &pelf->shdr[i];
shdr = &pelf->shdr[shnum];
}
if (shdr == NULL) {