V850/BFD: Fix uninitialized `insn[4]' with R_V850_LONGJUMP warning

Message ID alpine.LFD.2.21.2002031546350.18621@redsun52.ssa.fujisawa.hgst.com
State New
Headers show
Series
  • V850/BFD: Fix uninitialized `insn[4]' with R_V850_LONGJUMP warning
Related show

Commit Message

Maciej W. Rozycki Feb. 3, 2020, 4:06 p.m.
Correctly point at `insn[2]' rather than `insn[4]' in determining that 
the third instruction from where an R_V850_LONGJUMP relocation points at 
is not a recognized one, fixing a problem with commit 86aba9dbfa7e ("Add 
linker relaxation to v850 toolchain") resulting in a build failure like:

.../bfd/elf32-v850.c: In function 'v850_elf_relax_section':
.../bfd/elf32-v850.c:3854:5: error: 'insn[4]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 3854 |     _bfd_error_handler
      |     ^~~~~~~~~~~~~~~~~~
 3855 |       /* xgettext:c-format */
      |       ~~~~~~~~~~~~~~~~~~~~~~~
 3856 |       (_("%pB: %#" PRIx64 ": warning: %s points to "
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3857 |          "unrecognized insn %#x"),
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~
 3858 |        abfd,
      |        ~~~~~
 3859 |        (uint64_t) (irel->r_offset + no_match),
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3860 |        "R_V850_LONGJUMP",
      |        ~~~~~~~~~~~~~~~~~~
 3861 |        insn[no_match]);
      |        ~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Makefile:1608: recipe for target 'elf32-v850.lo' failed
make[4]: *** [elf32-v850.lo] Error 1

with GCC 10.

	bfd/
	* elf32-v850.c (v850_elf_relax_section): Fix the index used for
	reporting an unrecognized instruction with R_V850_LONGJUMP.
---
Hi,

 Observed in a GDB build with `--enable-targets=all'.  Obviously GCC must 
have become cleverer lately.  OK to apply?

  Maciej
---
 bfd/elf32-v850.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

binutils-bfd-v850-longjump-no-match.diff

Comments

Nick Clifton Feb. 6, 2020, 10:44 a.m. | #1
HI Maciej,

> 	bfd/

> 	* elf32-v850.c (v850_elf_relax_section): Fix the index used for

> 	reporting an unrecognized instruction with R_V850_LONGJUMP.


Approved - please apply.

Cheers
  Nick

PS.  I think that this one counts as "obvious"...
Maciej W. Rozycki Feb. 6, 2020, 1:41 p.m. | #2
Hi Nick,

> > 	* elf32-v850.c (v850_elf_relax_section): Fix the index used for

> > 	reporting an unrecognized instruction with R_V850_LONGJUMP.

> 

> Approved - please apply.

> 

> Cheers

>   Nick

> 

> PS.  I think that this one counts as "obvious"...


 I had such a thought, but decided to err on the side of caution, 
especially as it's been so long since this code was added.  Now committed, 
thanks for your review.

  Maciej

Patch

Index: binutils-gdb/bfd/elf32-v850.c
===================================================================
--- binutils-gdb.orig/bfd/elf32-v850.c
+++ binutils-gdb/bfd/elf32-v850.c
@@ -3837,7 +3837,7 @@  v850_elf_relax_section (bfd *abfd,
 		  if (no_match < 0
 		      && ((insn[2] & JMP_R_MASK) != JMP_R
 			   || MOVEA_R2 (insn[1]) != JMP_R1 (insn[2])))
-		    no_match = 4;
+		    no_match = 2;
 		}
 	      else
 		{