Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Nov 2019 19:50:36 +0000 (UTC)
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r354262 - stable/12/sys/riscv/riscv
Message-ID:  <201911021950.xA2Joa6S051033@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911021950.xA2Joa6S051033>