Make readelf and objdump recursively follow debug links. (PR 26595)

This commit is contained in:
Nick Clifton 2020-10-15 15:11:10 +01:00
parent 13a86b8b66
commit 842839bbb1
2 changed files with 133 additions and 17 deletions

View File

@ -0,0 +1,109 @@
--- binutils.orig/binutils/dwarf.c 2020-10-15 12:13:21.960799738 +0100
+++ binutils-2.35.1/binutils/dwarf.c 2020-10-15 13:02:39.454692627 +0100
@@ -10427,7 +10427,7 @@ load_separate_debug_info (const char *
{
warn (_("Corrupt debuglink section: %s\n"),
xlink->name ? xlink->name : xlink->uncompressed_name);
- return FALSE;
+ return NULL;
}
/* Attempt to locate the separate file.
@@ -10587,7 +10587,7 @@ load_separate_debug_info (const char *
{
warn (_("failed to open separate debug file: %s\n"), debug_filename);
free (debug_filename);
- return FALSE;
+ return NULL;
}
/* FIXME: We do not check to see if there are any other separate debug info
@@ -10632,6 +10632,52 @@ load_dwo_file (const char * main_filenam
return separate_handle;
}
+/* Load a debuglink section and/or a debugaltlink section, if either are present.
+ Recursively check the loaded files for more of these sections.
+ FIXME: Should also check for DWO_* entries in the newlu loaded files. */
+
+static void
+check_for_and_load_links (void * file, const char * filename)
+{
+ void * handle = NULL;
+
+ if (load_debug_section (gnu_debugaltlink, file))
+ {
+ Build_id_data build_id_data;
+
+ handle = load_separate_debug_info (filename,
+ & debug_displays[gnu_debugaltlink].section,
+ parse_gnu_debugaltlink,
+ check_gnu_debugaltlink,
+ & build_id_data,
+ file);
+ if (handle)
+ {
+ assert (handle == first_separate_info->handle);
+ check_for_and_load_links (first_separate_info->handle,
+ first_separate_info->filename);
+ }
+ }
+
+ if (load_debug_section (gnu_debuglink, file))
+ {
+ unsigned long crc32;
+
+ handle = load_separate_debug_info (filename,
+ & debug_displays[gnu_debuglink].section,
+ parse_gnu_debuglink,
+ check_gnu_debuglink,
+ & crc32,
+ file);
+ if (handle)
+ {
+ assert (handle == first_separate_info->handle);
+ check_for_and_load_links (first_separate_info->handle,
+ first_separate_info->filename);
+ }
+ }
+}
+
/* Load the separate debug info file(s) attached to FILE, if any exist.
Returns TRUE if any were found, FALSE otherwise.
If TRUE is returned then the linked list starting at first_separate_info
@@ -10707,34 +10753,10 @@ load_separate_debug_files (void * file,
return FALSE;
/* FIXME: We do not check for the presence of both link sections in the same file. */
- /* FIXME: We do not check the separate debug info file to see if it too contains debuglinks. */
/* FIXME: We do not check for the presence of multiple, same-name debuglink sections. */
/* FIXME: We do not check for the presence of a dwo link as well as a debuglink. */
- if (load_debug_section (gnu_debugaltlink, file))
- {
- Build_id_data * build_id_data;
-
- load_separate_debug_info (filename,
- & debug_displays[gnu_debugaltlink].section,
- parse_gnu_debugaltlink,
- check_gnu_debugaltlink,
- & build_id_data,
- file);
- }
-
- if (load_debug_section (gnu_debuglink, file))
- {
- unsigned long crc32;
-
- load_separate_debug_info (filename,
- & debug_displays[gnu_debuglink].section,
- parse_gnu_debuglink,
- check_gnu_debuglink,
- & crc32,
- file);
- }
-
+ check_for_and_load_links (file, filename);
if (first_separate_info != NULL)
return TRUE;

View File

@ -2,7 +2,7 @@
Summary: A GNU collection of binary utilities Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug} Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.35.1 Version: 2.35.1
Release: 5%{?dist} Release: 6%{?dist}
License: GPLv3+ License: GPLv3+
URL: https://sourceware.org/binutils URL: https://sourceware.org/binutils
@ -186,69 +186,73 @@ Patch10: binutils-attach-to-group.patch
# Purpose: Allow OS specific sections in section groups. # Purpose: Allow OS specific sections in section groups.
# Lifetime: Fixed in 2.36 (maybe) # Lifetime: Fixed in 2.36 (maybe)
Patch12: binutils-special-sections-in-groups.patch Patch11: binutils-special-sections-in-groups.patch
# Purpose: Fix linker testsuite failures. # Purpose: Fix linker testsuite failures.
# Lifetime: Fixed in 2.36 (maybe) # Lifetime: Fixed in 2.36 (maybe)
Patch13: binutils-fix-testsuite-failures.patch Patch12: binutils-fix-testsuite-failures.patch
# Purpose: Stop gold from aborting when input sections with the same name # Purpose: Stop gold from aborting when input sections with the same name
# have different flags. # have different flags.
# Lifetime: Fixed in 2.36 (maybe) # Lifetime: Fixed in 2.36 (maybe)
Patch14: binutils-gold-mismatched-section-flags.patch Patch13: binutils-gold-mismatched-section-flags.patch
# Purpose: Add a check to the GOLD linker for a corrupt input file # Purpose: Add a check to the GOLD linker for a corrupt input file
# with a fuzzed section offset. # with a fuzzed section offset.
# Lifetime: Fixed in 2.36 (maybe) # Lifetime: Fixed in 2.36 (maybe)
Patch15: binutils-CVE-2019-1010204.patch Patch14: binutils-CVE-2019-1010204.patch
# Purpose: Change the gold configuration script to only warn about # Purpose: Change the gold configuration script to only warn about
# unsupported targets. This allows the binutils to be built with # unsupported targets. This allows the binutils to be built with
# BPF support enabled. # BPF support enabled.
# Lifetime: Permanent. # Lifetime: Permanent.
Patch17: binutils-gold-warn-unsupported.patch Patch15: binutils-gold-warn-unsupported.patch
# Purpose: Fix compile time warning messages building s390 target with gcc-10. # Purpose: Fix compile time warning messages building s390 target with gcc-10.
# Lifetime: Should be fixed in 2.36. # Lifetime: Should be fixed in 2.36.
Patch19: binutils-s390-build.patch Patch16: binutils-s390-build.patch
# Purpose: Fix LTO problems running config mini-builds. # Purpose: Fix LTO problems running config mini-builds.
# Lifetime: Should be fixed in 2.36. # Lifetime: Should be fixed in 2.36.
Patch20: binutils-config.patch Patch17: binutils-config.patch
# Purpose: Fix compile time warning messages building with gcc-10. # Purpose: Fix compile time warning messages building with gcc-10.
# Lifetime: Should be fixed in 2.36. # Lifetime: Should be fixed in 2.36.
Patch21: binutils-warnings.patch Patch18: binutils-warnings.patch
# Purpose: Fix compile time warning messages building with gcc-10. (part 2). # Purpose: Fix compile time warning messages building with gcc-10. (part 2).
# Lifetime: Should be fixed in 2.36. # Lifetime: Should be fixed in 2.36.
Patch22: binutils-gcc-10-fixes.patch Patch19: binutils-gcc-10-fixes.patch
# Purpose: Fixes for linking LTO objects. # Purpose: Fixes for linking LTO objects.
# Lifetime: Fixed in 2.36 # Lifetime: Fixed in 2.36
Patch23: binutils-add-sym-cache-to-elf-link-hash.patch Patch20: binutils-add-sym-cache-to-elf-link-hash.patch
Patch24: binutils-elf-add-objects.patch Patch21: binutils-elf-add-objects.patch
# Purpose: Fix handling of relocations for AArch64 conditional branches. # Purpose: Fix handling of relocations for AArch64 conditional branches.
# Lifetime: Fixed in 2.36 # Lifetime: Fixed in 2.36
Patch25: binutils-aarch64-condbranch-relocs.patch Patch22: binutils-aarch64-condbranch-relocs.patch
# Purpose: Fix the PowerPC disassembler so that it ignores annobin symbols. # Purpose: Fix the PowerPC disassembler so that it ignores annobin symbols.
# Lifetime: Fixed in 2.36 # Lifetime: Fixed in 2.36
Patch26: binutils-ppc-annobin-disassembly.patch Patch23: binutils-ppc-annobin-disassembly.patch
# Purpose: Fix the strip program to cope when merging multiple same-named # Purpose: Fix the strip program to cope when merging multiple same-named
# sections. # sections.
# Lifetime: Fixed in 2.36 # Lifetime: Fixed in 2.36
Patch27: binutils-strip-merge.patch Patch24: binutils-strip-merge.patch
# Purpose: Fix various problems with the PowerPC arch10 extensions. # Purpose: Fix various problems with the PowerPC arch10 extensions.
# Lifetime: Fixed in 2.36 # Lifetime: Fixed in 2.36
Patch28: binutils-Power10-fixes.patch Patch25: binutils-Power10-fixes.patch
# Purpose: Allow plugin syms to mark as-needed shared libs needed. # Purpose: Allow plugin syms to mark as-needed shared libs needed.
# Lifetime: Fixed in 2.36 # Lifetime: Fixed in 2.36
Patch29: binutils-plugin-as-needed.patch Patch26: binutils-plugin-as-needed.patch
# Purpose: Recursively follow .gnu_debuglink and .gnu_debugaltlink sections.
# Lifetime: Fixed in 2.36
Patch27: binutils-recursive-debuglink-following.patch
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -823,6 +827,9 @@ exit 0
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
%changelog %changelog
* Thu Oct 15 2020 Nick Clifton <nickc@redhat.com> - 2.35.1-6
- Make readelf and objdump recursively follow debug links. (PR 26595)
* Fri Oct 09 2020 Nick Clifton <nickc@redhat.com> - 2.35.1-5 * Fri Oct 09 2020 Nick Clifton <nickc@redhat.com> - 2.35.1-5
- Allow plugin syms to mark as-needed shared libs needed - Allow plugin syms to mark as-needed shared libs needed