* addr2line.c (fill_lines): use dynsym, which is used for dynamic

linking and always exists, if there's no symtab.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2014-03-31 22:39:07 +00:00
Родитель e1952036a4
Коммит f265ce708d
2 изменённых файлов: 19 добавлений и 2 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Tue Apr 1 07:37:00 2014 NARUSE, Yui <naruse@ruby-lang.org>
* addr2line.c (fill_lines): use dynsym, which is used for dynamic
linking and always exists, if there's no symtab.
Tue Apr 1 07:27:15 2014 NARUSE, Yui <naruse@ruby-lang.org>
* vm_dump.c (rb_print_backtrace): current implementation

Просмотреть файл

@ -464,8 +464,8 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
int fd;
off_t filesize;
char *file;
ElfW(Shdr) *symtab_shdr = NULL;
ElfW(Shdr) *strtab_shdr = NULL;
ElfW(Shdr) *symtab_shdr = NULL, *strtab_shdr = NULL;
ElfW(Shdr) *dynsym_shdr = NULL, *dynstr_shdr = NULL;
fd = open(binary_filename, O_RDONLY);
if (fd < 0) {
@ -532,11 +532,18 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
if (!strcmp(section_name, ".strtab")) {
strtab_shdr = shdr + i;
}
else if (!strcmp(section_name, ".dynstr")) {
dynstr_shdr = shdr + i;
}
break;
case SHT_SYMTAB:
/* if (!strcmp(section_name, ".symtab")) */
symtab_shdr = shdr + i;
break;
case SHT_DYNSYM:
/* if (!strcmp(section_name, ".dynsym")) */
dynsym_shdr = shdr + i;
break;
case SHT_PROGBITS:
if (!strcmp(section_name, ".debug_line")) {
debug_line_shdr = shdr + i;
@ -548,6 +555,11 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
}
}
if (!symtab_shdr) {
symtab_shdr = dynsym_shdr;
strtab_shdr = dynstr_shdr;
}
if (symtab_shdr && strtab_shdr) {
char *strtab = file + strtab_shdr->sh_offset;
ElfW(Sym) *symtab = (ElfW(Sym) *)(file + symtab_shdr->sh_offset);