[前][次][番号順一覧][スレッド一覧]

ruby-changes:33412

From: naruse <ko1@a...>
Date: Tue, 1 Apr 2014 07:39:13 +0900 (JST)
Subject: [ruby-changes:33412] naruse:r45491 (trunk): * addr2line.c (fill_lines): use dynsym, which is used for dynamic

naruse	2014-04-01 07:39:07 +0900 (Tue, 01 Apr 2014)

  New Revision: 45491

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45491

  Log:
    * addr2line.c (fill_lines): use dynsym, which is used for dynamic
      linking and always exists, if there's no symtab.

  Modified files:
    trunk/ChangeLog
    trunk/addr2line.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45490)
+++ ChangeLog	(revision 45491)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Apr  1 07:37:00 2014  NARUSE, Yui  <naruse@r...>
+
+	* 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@r...>
 
 	* vm_dump.c (rb_print_backtrace): current implementation
Index: addr2line.c
===================================================================
--- addr2line.c	(revision 45490)
+++ addr2line.c	(revision 45491)
@@ -464,8 +464,8 @@ fill_lines(int num_traces, void **traces https://github.com/ruby/ruby/blob/trunk/addr2line.c#L464
     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 https://github.com/ruby/ruby/blob/trunk/addr2line.c#L532
 	    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 https://github.com/ruby/ruby/blob/trunk/addr2line.c#L555
 	}
     }
 
+    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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]