From 47e37c4a28f7e037efeb47ec2852e7714c98a276 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mar 14 2013 13:53:38 +0000 Subject: Enhance opncls.c:find_separate_debug_file() to look in Fedora specific locations. Enhance dwarf2.c:find_line() to work with shared libraries. Might resolve: #920542 --- diff --git a/binutils-2.23.52.0.1-addr2line-dynsymtab.patch b/binutils-2.23.52.0.1-addr2line-dynsymtab.patch index 5c8cabf..d434e3f 100644 --- a/binutils-2.23.52.0.1-addr2line-dynsymtab.patch +++ b/binutils-2.23.52.0.1-addr2line-dynsymtab.patch @@ -20,3 +20,125 @@ } /* 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; + } + diff --git a/binutils.spec b/binutils.spec index 665539d..8a03f72 100644 --- a/binutils.spec +++ b/binutils.spec @@ -17,7 +17,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.23.52.0.1 -Release: 8%{?dist} +Release: 9%{?dist} License: GPLv3+ Group: Development/Tools URL: http://sources.redhat.com/binutils @@ -459,6 +459,10 @@ exit 0 %endif # %{isnative} %changelog +* Thu Mar 14 2013 Nick Clifton - 2.23.52.0.1-9 +- Enhance opncls.c:find_separate_debug_file() to look in Fedora specific locations. +- Enhance dwarf2.c:find_line() to work with shared libraries. (#920542) + * Wed Mar 13 2013 Nick Clifton - 2.23.52.0.1-8 - Fix addr2line to use dynamic symbols if it failed to canonicalize ordinary symbols. (#920542)