Commit: Fix uninitialised use in gold/target-reloc.h

Message ID 87imfgbetn.fsf@redhat.com
State New
Headers show
Series
  • Commit: Fix uninitialised use in gold/target-reloc.h
Related show

Commit Message

Cui, Lili via Binutils June 24, 2020, 4:37 p.m.
Hi Guys,

  I am applying the patch below to fix a potential uninitialised use
  detected in gold's target-reloc.h file.  (The detection was triggered
  when compiling for the s390x target using gcc-10).

Cheers
  Nick

gold/ChangeLog
2020-06-24  Nick Clifton  <nickc@redhat.com>

	* target-reloc.h (issue_discarded_error): Initialise the
	key_symndx variable.

Patch

diff --git a/gold/target-reloc.h b/gold/target-reloc.h
index 2b205a1a74..e9e3e5b002 100644
--- a/gold/target-reloc.h
+++ b/gold/target-reloc.h
@@ -258,7 +258,7 @@  issue_discarded_error(
 							     &is_ordinary);
   if (orig_shndx != elfcpp::SHN_UNDEF)
     {
-      unsigned int key_symndx;
+      unsigned int key_symndx = 0;
       Relobj* kept_obj = object->find_kept_section_object(orig_shndx,
 							  &key_symndx);
       if (key_symndx != 0)