summaryrefslogtreecommitdiffstats
path: root/binutils-2.23.52.0.1-addr2line-dynsymtab.patch
blob: d434e3fa7a414bc45344d45269ae7bae315a9135 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
*** ../binutils-2.23.52.0.1/binutils/addr2line.c	2013-02-27 20:28:03.000000000 +0000
--- binutils/addr2line.c	2013-03-13 16:46:36.109519735 +0000
*************** slurp_symtab (bfd *abfd)
*** 130,135 ****
--- 130,146 ----
      symcount = bfd_canonicalize_symtab (abfd, syms);
    if (symcount < 0)
      bfd_fatal (bfd_get_filename (abfd));
+ 
+   /* If there are no symbols left after canonicalization and
+      we have not tried the dynamic symbols then give them a go.  */
+   if (symcount == 0
+       && ! dynamic
+       && (storage = bfd_get_dynamic_symtab_upper_bound (abfd)) > 0)
+     {
+       free (syms);
+       syms = xmalloc (storage);
+       symcount = bfd_canonicalize_dynamic_symtab (abfd, syms);
+     }
  }
  
  /* These global variables are used to pass information between
*** ../binutils-2.23.52.0.1.orig/bfd/opncls.c	2013-03-14 11:25:30.338306122 +0000
--- bfd/opncls.c	2013-03-14 12:20:21.686397360 +0000
*************** find_separate_debug_file (bfd *abfd, con
*** 1297,1302 ****
--- 1297,1304 ----
        bfd_malloc (strlen (debug_file_directory) + 1
                    + (canon_dirlen > dirlen ? canon_dirlen : dirlen)
                    + strlen (".debug/")
+ #define FEDORA_LIB_DEBUG_DIR "/usr/lib/debug/"
+ 		  + strlen (FEDORA_LIB_DEBUG_DIR) + strlen ("usr/")
                    + strlen (base)
                    + 1);
    if (debugfile == NULL)
*************** find_separate_debug_file (bfd *abfd, con
*** 1332,1337 ****
--- 1334,1359 ----
        return debugfile;
      }
  
+   /* Then try in the global debug dir for Fedora libraries.  */
+   sprintf (debugfile, "%s%s%s", FEDORA_LIB_DEBUG_DIR, dir, base);
+   if (separate_debug_file_exists (debugfile, crc32))
+     {
+       free (base);
+       free (dir);
+       free (canon_dir);
+       return debugfile;
+     }
+ 
+   /* Then try in the usr subdirectory of the global debug dir for Fedora libraries.  */
+   sprintf (debugfile, "%s/usr%s%s", FEDORA_LIB_DEBUG_DIR, dir, base);
+   if (separate_debug_file_exists (debugfile, crc32))
+     {
+       free (base);
+       free (dir);
+       free (canon_dir);
+       return debugfile;
+     }
+   
    /* Then try in the global debugfile directory.  */
    strcpy (debugfile, debug_file_directory);
    dirlen = strlen (debug_file_directory) - 1;
*** ../binutils-2.23.52.0.1.orig/bfd/dwarf2.c	2013-03-14 11:25:30.608306129 +0000
--- bfd/dwarf2.c	2013-03-14 13:14:18.102487075 +0000
*************** find_line (bfd *abfd,
*** 3339,3346 ****
--- 3339,3349 ----
    struct dwarf2_debug *stash;
    /* What address are we looking for?  */
    bfd_vma addr;
+   /* What is the address without relocation ?  */
+   bfd_vma unrelocated_addr;
    struct comp_unit* each;
    bfd_vma found = FALSE;
+   bfd_vma possible_find = FALSE;
    bfd_boolean do_line;
  
    *filename_ptr = NULL;
*************** find_line (bfd *abfd,
*** 3380,3385 ****
--- 3383,3394 ----
    else
      abort ();
  
+   /* If we are dealing with PIC code then the debug information
+      will be based on unrelocated addresses.  Since we cannot be
+      sure if this is a PIC address we test both with and without
+      relocation.  */
+   unrelocated_addr = addr;
+ 
    if (section->output_section)
      addr += section->output_section->vma + section->output_offset;
    else
*************** find_line (bfd *abfd,
*** 3442,3447 ****
--- 3451,3466 ----
  						   stash));
  	  if (found)
  	    goto done;
+ 
+ 	  if (! possible_find)
+ 	    possible_find = ((each->arange.high == 0
+ 			      || comp_unit_contains_address (each, unrelocated_addr))
+ 			     && comp_unit_find_nearest_line (each, unrelocated_addr,
+ 							     filename_ptr,
+ 							     functionname_ptr,
+ 							     linenumber_ptr,
+ 							     discriminator_ptr,
+ 							     stash));
  	}
      }
  
*************** find_line (bfd *abfd,
*** 3535,3540 ****
--- 3554,3569 ----
  						     discriminator_ptr,
  						     stash));
  
+ 	  if (! found && ! do_line && ! possible_find)
+ 	    possible_find = ((each->arange.high == 0
+ 			      || comp_unit_contains_address (each, unrelocated_addr))
+ 			     && comp_unit_find_nearest_line (each, unrelocated_addr,
+ 							     filename_ptr,
+ 							     functionname_ptr,
+ 							     linenumber_ptr,
+ 							     discriminator_ptr,
+ 							     stash));
+ 
  	  if ((bfd_vma) (stash->info_ptr - stash->sec_info_ptr)
  	      == stash->sec->size)
  	    {
*************** find_line (bfd *abfd,
*** 3552,3557 ****
--- 3581,3588 ----
    if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
      unset_sections (stash);
  
+   if (! found)
+     return possible_find;
    return found;
  }