svn commit: r354262 - stable/12/sys/riscv/riscv

Mitchell Horne mhorne at FreeBSD.org
Sat Nov 2 19:50:36 UTC 2019


Author: mhorne
Date: Sat Nov  2 19:50:36 2019
New Revision: 354262
URL: https://svnweb.freebsd.org/changeset/base/354262

Log:
  MFC r352730:
  
  Fix some broken relocation handling
  
  In a few cases, the symbol lookup is missing before attempting to
  perform the relocation. While the relocation types affected are
  currently unused, this results in an uninitialized variable warning,
  that is escalated to an error when building with clang.
  
  Reviewed by:	markj
  Differential Revision:	https://reviews.freebsd.org/D21773

Modified:
  stable/12/sys/riscv/riscv/elf_machdep.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/riscv/riscv/elf_machdep.c
==============================================================================
--- stable/12/sys/riscv/riscv/elf_machdep.c	Sat Nov  2 19:48:42 2019	(r354261)
+++ stable/12/sys/riscv/riscv/elf_machdep.c	Sat Nov  2 19:50:36 2019	(r354262)
@@ -374,6 +374,10 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas
 		break;
 
 	case R_RISCV_PCREL_HI20:
+		error = lookup(lf, symidx, 1, &addr);
+		if (error != 0)
+			return (-1);
+
 		val = addr - (Elf_Addr)where;
 		insn32p = (uint32_t *)where;
 		before32 = *insn32p;
@@ -386,6 +390,10 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas
 		break;
 
 	case R_RISCV_PCREL_LO12_I:
+		error = lookup(lf, symidx, 1, &addr);
+		if (error != 0)
+			return (-1);
+
 		val = addr - (Elf_Addr)where;
 		insn32p = (uint32_t *)where;
 		before32 = *insn32p;
@@ -397,6 +405,10 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas
 		break;
 
 	case R_RISCV_PCREL_LO12_S:
+		error = lookup(lf, symidx, 1, &addr);
+		if (error != 0)
+			return (-1);
+
 		val = addr - (Elf_Addr)where;
 		insn32p = (uint32_t *)where;
 		before32 = *insn32p;
@@ -413,6 +425,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas
 		if (error != 0)
 			return (-1);
 
+		val = addr;
 		insn32p = (uint32_t *)where;
 		before32 = *insn32p;
 		imm20 = calc_hi20_imm(val);


More information about the svn-src-stable mailing list