From owner-svn-src-stable-12@freebsd.org Sat Nov 2 19:50:36 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DF5AF161CF9; Sat, 2 Nov 2019 19:50:36 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4758mr5dgSz46YQ; Sat, 2 Nov 2019 19:50:36 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A50DC4DD; Sat, 2 Nov 2019 19:50:36 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA2JoaFv051034; Sat, 2 Nov 2019 19:50:36 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA2Joa6S051033; Sat, 2 Nov 2019 19:50:36 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <201911021950.xA2Joa6S051033@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Sat, 2 Nov 2019 19:50:36 +0000 (UTC) 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 X-SVN-Group: stable-12 X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 354262 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Nov 2019 19:50:36 -0000 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);