* addr2line.c (fill_lines): check shdr[i].sh_type because even if

.symtab section exists, the section's type can be SHT_NOBITS and
  actual data doesn't exist in the file. [Bug #9654]
  revert r45441.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2014-03-27 03:01:59 +00:00
parent 6c27d383dd
commit acc3cf5f30
2 changed files with 25 additions and 8 deletions

View File

@ -1,3 +1,10 @@
Thu Mar 27 11:58:55 2014 NARUSE, Yui <naruse@ruby-lang.org>
* addr2line.c (fill_lines): check shdr[i].sh_type because even if
.symtab section exists, the section's type can be SHT_NOBITS and
actual data doesn't exist in the file.
revert r45441.
Wed Mar 26 14:57:35 2014 NAKAMURA Usaku <usa@ruby-lang.org>
* parse.y: inline must be static (for mswin).

View File

@ -530,18 +530,28 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
#ifdef __powerpc64__
kprintf("%s:: %s: flag(%lx)\n",binary_filename,section_name,shdr[i].sh_flags);
#endif
if (!strcmp(section_name, ".debug_line")) {
debug_line_shdr = shdr + i;
} else if (!strcmp(section_name, ".gnu_debuglink")) {
gnu_debuglink_shdr = shdr + i;
} else if (!strcmp(section_name, ".symtab")) {
switch (shdr[i].sh_type) {
case SHT_STRTAB:
if (!strcmp(section_name, ".strtab")) {
strtab_shdr = shdr + i;
}
break;
case SHT_SYMTAB:
/* if (!strcmp(section_name, ".symtab")) */
symtab_shdr = shdr + i;
} else if (!strcmp(section_name, ".strtab")) {
strtab_shdr = shdr + i;
break;
case SHT_PROGBITS:
if (!strcmp(section_name, ".debug_line")) {
debug_line_shdr = shdr + i;
}
else if (!strcmp(section_name, ".gnu_debuglink")) {
gnu_debuglink_shdr = shdr + i;
}
break;
}
}
if (check_debuglink && symtab_shdr && strtab_shdr) {
if (symtab_shdr && strtab_shdr) {
char *strtab = file + strtab_shdr->sh_offset;
ElfW(Sym) *symtab = (ElfW(Sym) *)(file + symtab_shdr->sh_offset);
int symtab_count = (int)(symtab_shdr->sh_size / sizeof(ElfW(Sym)));