Date: Thu, 26 Sep 2019 00:58:47 +0000 (UTC) From: Mitchell Horne <mhorne@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r352730 - head/sys/riscv/riscv Message-ID: <201909260058.x8Q0wlYf033914@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mhorne Date: Thu Sep 26 00:58:47 2019 New Revision: 352730 URL: https://svnweb.freebsd.org/changeset/base/352730 Log: 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 MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D21773 Modified: head/sys/riscv/riscv/elf_machdep.c Modified: head/sys/riscv/riscv/elf_machdep.c ============================================================================== --- head/sys/riscv/riscv/elf_machdep.c Thu Sep 26 00:54:07 2019 (r352729) +++ head/sys/riscv/riscv/elf_machdep.c Thu Sep 26 00:58:47 2019 (r352730) @@ -373,6 +373,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; @@ -385,6 +389,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; @@ -396,6 +404,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; @@ -412,6 +424,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?201909260058.x8Q0wlYf033914>