Have readelf suggest the use of --use-dynamic when there are dynamic relocs that could have been displayed.

Resolves: #1507694
This commit is contained in:
Nick Clifton 2017-11-01 12:02:01 +00:00
parent 6893f2da6c
commit c4cfb3f0ac
2 changed files with 68 additions and 1 deletions

View File

@ -0,0 +1,55 @@
diff -rup binutils.orig/binutils/doc/binutils.texi binutils-2.29.1/binutils/doc/binutils.texi
--- binutils.orig/binutils/doc/binutils.texi 2017-11-01 11:44:12.360707737 +0000
+++ binutils-2.29.1/binutils/doc/binutils.texi 2017-11-01 11:45:38.702652255 +0000
@@ -4661,8 +4661,13 @@ given.
@itemx --all
Equivalent to specifying @option{--file-header},
@option{--program-headers}, @option{--sections}, @option{--symbols},
-@option{--relocs}, @option{--dynamic}, @option{--notes} and
-@option{--version-info}.
+@option{--relocs}, @option{--dynamic}, @option{--notes},
+@option{--version-info}, @option{--arch-specific}, @option{--unwind},
+@option{--section-groups} and @option{--histogram}.
+
+Note - this option does not enable @option{--use-dynamic} itself, so
+if that option is not present on the command line then dynamic symbols
+and dynamic relocs will not be displayed.
@item -h
@itemx --file-header
@@ -4758,6 +4763,9 @@ When displaying symbols, this option mak
symbol hash tables in the file's dynamic section, rather than the
symbol table sections.
+When displaying relocations, this option makes @command{readelf}
+display the dynamic relocations rather than the static relocations.
+
@item -x <number or name>
@itemx --hex-dump=<number or name>
Displays the contents of the indicated section as a hexadecimal bytes.
diff -rup binutils.orig/binutils/readelf.c binutils-2.29.1/binutils/readelf.c
--- binutils.orig/binutils/readelf.c 2017-11-01 11:44:12.357707774 +0000
+++ binutils-2.29.1/binutils/readelf.c 2017-11-01 11:45:11.901979878 +0000
@@ -7117,7 +7117,21 @@ process_relocs (FILE * file)
}
if (! found)
- printf (_("\nThere are no relocations in this file.\n"));
+ {
+ /* Users sometimes forget the -D option, so try to be helpful. */
+ for (i = 0; i < ARRAY_SIZE (dynamic_relocations); i++)
+ {
+ if (dynamic_info [dynamic_relocations [i].size])
+ {
+ printf (_("\nThere are no static relocations in this file."));
+ printf (_("\nTo see the dynamic relocations add --use-dynamic to the command line.\n"));
+
+ break;
+ }
+ }
+ if (i == ARRAY_SIZE (dynamic_relocations))
+ printf (_("\nThere are no relocations in this file.\n"));
+ }
}
return TRUE;

View File

@ -54,7 +54,7 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.29.1
Release: 3%{?dist}
Release: 4%{?dist}
License: GPLv3+
Group: Development/Tools
URL: http://sources.redhat.com/binutils
@ -121,6 +121,14 @@ Patch07: binutils-2.29-filename-in-error-messages.patch
# Lifetime: Fixed in 2.30.
Patch08: binutils-2.29.1-gold-start-stop.patch
# Purpose: Update readelf so that if it is run with the --relocs option and
# there are no static relocs to be displayed, but there are dynamic
# relocs that could have been displayed, it will now issue a
# message suggesting the addition of the --use-dynamic option.
# See: BZ 1507694
# Lifetime: Fixed in 2.30.
Patch09: binutils-2.29.1-readelf-use-dynamic.patch
#----------------------------------------------------------------------------
Provides: bundled(libiberty)
@ -251,6 +259,7 @@ using libelf instead of BFD.
%patch06 -p1
%patch07 -p1
%patch08 -p1
%patch09 -p1
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
@ -650,6 +659,9 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Wed Nov 01 2017 Nick Clifton <nickc@redhat.com> 2.29.1-4
- Have readelf suggest the use of --use-dynamic when there are dynamic relocs that could have been displayed. (#1507694)
* Wed Oct 18 2017 Nick Clifton <nickc@redhat.com> 2.29.1-3
- Fix the GOLD linker's generation of relocations for start and stop symbols. (#1500898)