Skip to content

Commit f265ce7

Browse files
committed
* 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
1 parent e195203 commit f265ce7

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Tue Apr 1 07:37:00 2014 NARUSE, Yui <[email protected]>
2+
3+
* addr2line.c (fill_lines): use dynsym, which is used for dynamic
4+
linking and always exists, if there's no symtab.
5+
16
Tue Apr 1 07:27:15 2014 NARUSE, Yui <[email protected]>
27

38
* vm_dump.c (rb_print_backtrace): current implementation

addr2line.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
464464
int fd;
465465
off_t filesize;
466466
char *file;
467-
ElfW(Shdr) *symtab_shdr = NULL;
468-
ElfW(Shdr) *strtab_shdr = NULL;
467+
ElfW(Shdr) *symtab_shdr = NULL, *strtab_shdr = NULL;
468+
ElfW(Shdr) *dynsym_shdr = NULL, *dynstr_shdr = NULL;
469469

470470
fd = open(binary_filename, O_RDONLY);
471471
if (fd < 0) {
@@ -532,11 +532,18 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
532532
if (!strcmp(section_name, ".strtab")) {
533533
strtab_shdr = shdr + i;
534534
}
535+
else if (!strcmp(section_name, ".dynstr")) {
536+
dynstr_shdr = shdr + i;
537+
}
535538
break;
536539
case SHT_SYMTAB:
537540
/* if (!strcmp(section_name, ".symtab")) */
538541
symtab_shdr = shdr + i;
539542
break;
543+
case SHT_DYNSYM:
544+
/* if (!strcmp(section_name, ".dynsym")) */
545+
dynsym_shdr = shdr + i;
546+
break;
540547
case SHT_PROGBITS:
541548
if (!strcmp(section_name, ".debug_line")) {
542549
debug_line_shdr = shdr + i;
@@ -548,6 +555,11 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
548555
}
549556
}
550557

558+
if (!symtab_shdr) {
559+
symtab_shdr = dynsym_shdr;
560+
strtab_shdr = dynstr_shdr;
561+
}
562+
551563
if (symtab_shdr && strtab_shdr) {
552564
char *strtab = file + strtab_shdr->sh_offset;
553565
ElfW(Sym) *symtab = (ElfW(Sym) *)(file + symtab_shdr->sh_offset);

0 commit comments

Comments
 (0)