summaryrefslogtreecommitdiff
path: root/util/cbfstool/elfheaders.c
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2017-09-03 21:04:41 +1000
committerMartin Roth <martinroth@google.com>2017-09-13 19:25:14 +0000
commit0025247171cff79fc955f70ed127a3de49c68d28 (patch)
tree58d70d555d5c11a798a79b0a32b241bf235dff1a /util/cbfstool/elfheaders.c
parent7bc0e4274928243df61e96a099d141d7251a3956 (diff)
downloadcoreboot-0025247171cff79fc955f70ed127a3de49c68d28.tar.xz
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>
Diffstat (limited to 'util/cbfstool/elfheaders.c')
-rw-r--r--util/cbfstool/elfheaders.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/util/cbfstool/elfheaders.c b/util/cbfstool/elfheaders.c
index 67f01d4df1..acb25a7475 100644
--- a/util/cbfstool/elfheaders.c
+++ b/util/cbfstool/elfheaders.c
@@ -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) {