From owner-svn-src-all@freebsd.org Wed Oct 7 18:48:12 2020 Return-Path: Delivered-To: svn-src-all@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 51D6A435C6B; Wed, 7 Oct 2020 18:48:12 +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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 4C63Hw1SjXz3dqB; Wed, 7 Oct 2020 18:48:12 +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 157261C020; Wed, 7 Oct 2020 18:48:12 +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 097ImBXB091106; Wed, 7 Oct 2020 18:48:11 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 097ImAxg091098; Wed, 7 Oct 2020 18:48:10 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202010071848.097ImAxg091098@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Wed, 7 Oct 2020 18:48:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366519 - in head/sys: amd64/amd64 arm/arm arm64/arm64 i386/i386 mips/mips powerpc/powerpc riscv/riscv X-SVN-Group: head X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: in head/sys: amd64/amd64 arm/arm arm64/arm64 i386/i386 mips/mips powerpc/powerpc riscv/riscv X-SVN-Commit-Revision: 366519 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Oct 2020 18:48:12 -0000 Author: mhorne Date: Wed Oct 7 18:48:10 2020 New Revision: 366519 URL: https://svnweb.freebsd.org/changeset/base/366519 Log: Print symbol index for unsupported relocation types It is unlikely, but possible, that an unrecognized or unsupported relocation type is encountered while trying to load a kernel module. If this occurs we should offer the symbol index as a hint to the user. While here, fix some small style issues. Reviewed by: markj, kib (amd64 part, in D26701) Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Modified: head/sys/amd64/amd64/elf_machdep.c head/sys/arm/arm/elf_machdep.c head/sys/arm64/arm64/elf_machdep.c head/sys/i386/i386/elf_machdep.c head/sys/mips/mips/elf_machdep.c head/sys/powerpc/powerpc/elf32_machdep.c head/sys/powerpc/powerpc/elf64_machdep.c head/sys/riscv/riscv/elf_machdep.c Modified: head/sys/amd64/amd64/elf_machdep.c ============================================================================== --- head/sys/amd64/amd64/elf_machdep.c Wed Oct 7 17:46:49 2020 (r366518) +++ head/sys/amd64/amd64/elf_machdep.c Wed Oct 7 18:48:10 2020 (r366519) @@ -309,11 +309,11 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas case R_X86_64_NONE: /* none */ break; - case R_X86_64_64: /* S + A */ + case R_X86_64_64: /* S + A */ error = lookup(lf, symidx, 1, &addr); val = addr + addend; if (error != 0) - return -1; + return (-1); if (*where != val) *where = val; break; @@ -325,7 +325,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas where32 = (Elf32_Addr *)where; val32 = (Elf32_Addr)(addr + addend - (Elf_Addr)where); if (error != 0) - return -1; + return (-1); if (*where32 != val32) *where32 = val32; break; @@ -335,7 +335,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas val32 = (Elf32_Addr)(addr + addend); where32 = (Elf32_Addr *)where; if (error != 0) - return -1; + return (-1); if (*where32 != val32) *where32 = val32; break; @@ -345,14 +345,15 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas * There shouldn't be copy relocations in kernel * objects. */ - printf("kldload: unexpected R_COPY relocation\n"); + printf("kldload: unexpected R_COPY relocation, " + "symbol index %ld\n", symidx); return (-1); case R_X86_64_GLOB_DAT: /* S */ case R_X86_64_JMP_SLOT: /* XXX need addend + offset */ error = lookup(lf, symidx, 1, &addr); if (error != 0) - return -1; + return (-1); if (*where != addr) *where = addr; break; @@ -372,8 +373,8 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas break; default: - printf("kldload: unexpected relocation type %ld\n", - rtype); + printf("kldload: unexpected relocation type %ld, " + "symbol index %ld\n", rtype, symidx); return (-1); } return (0); Modified: head/sys/arm/arm/elf_machdep.c ============================================================================== --- head/sys/arm/arm/elf_machdep.c Wed Oct 7 17:46:49 2020 (r366518) +++ head/sys/arm/arm/elf_machdep.c Wed Oct 7 18:48:10 2020 (r366519) @@ -236,7 +236,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas case R_ARM_ABS32: error = lookup(lf, symidx, 1, &addr); if (error != 0) - return -1; + return (-1); store_ptr(where, addr + load_ptr(where)); break; @@ -245,8 +245,9 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas * There shouldn't be copy relocations in kernel * objects. */ - printf("kldload: unexpected R_COPY relocation\n"); - return -1; + printf("kldload: unexpected R_COPY relocation, " + "symbol index %d\n", symidx); + return (-1); break; case R_ARM_JUMP_SLOT: @@ -260,9 +261,9 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas break; default: - printf("kldload: unexpected relocation type %d\n", - rtype); - return -1; + printf("kldload: unexpected relocation type %d, " + "symbol index %d\n", rtype, symidx); + return (-1); } return(0); } Modified: head/sys/arm64/arm64/elf_machdep.c ============================================================================== --- head/sys/arm64/arm64/elf_machdep.c Wed Oct 7 17:46:49 2020 (r366518) +++ head/sys/arm64/arm64/elf_machdep.c Wed Oct 7 18:48:10 2020 (r366519) @@ -227,7 +227,8 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas *where = val; break; default: - printf("kldload: unexpected relocation type %d\n", rtype); + printf("kldload: unexpected relocation type %d, " + "symbol index %d\n", rtype, symidx); return (-1); } return (error); Modified: head/sys/i386/i386/elf_machdep.c ============================================================================== --- head/sys/i386/i386/elf_machdep.c Wed Oct 7 17:46:49 2020 (r366518) +++ head/sys/i386/i386/elf_machdep.c Wed Oct 7 18:48:10 2020 (r366519) @@ -213,7 +213,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas case R_386_32: /* S + A */ error = lookup(lf, symidx, 1, &addr); if (error != 0) - return -1; + return (-1); addr += addend; if (*where != addr) *where = addr; @@ -222,7 +222,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas case R_386_PC32: /* S + A - P */ error = lookup(lf, symidx, 1, &addr); if (error != 0) - return -1; + return (-1); addr += addend - (Elf_Addr)where; if (*where != addr) *where = addr; @@ -233,14 +233,15 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas * There shouldn't be copy relocations in kernel * objects. */ - printf("kldload: unexpected R_COPY relocation\n"); - return -1; + printf("kldload: unexpected R_COPY relocation, " + "symbol index %d\n", symidx); + return (-1); break; case R_386_GLOB_DAT: /* S */ error = lookup(lf, symidx, 1, &addr); if (error != 0) - return -1; + return (-1); if (*where != addr) *where = addr; break; @@ -255,9 +256,9 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas *where = addr; break; default: - printf("kldload: unexpected relocation type %d\n", - rtype); - return -1; + printf("kldload: unexpected relocation type %d, " + "symbol index %d\n", rtype, symidx); + return (-1); } return(0); } Modified: head/sys/mips/mips/elf_machdep.c ============================================================================== --- head/sys/mips/mips/elf_machdep.c Wed Oct 7 17:46:49 2020 (r366518) +++ head/sys/mips/mips/elf_machdep.c Wed Oct 7 18:48:10 2020 (r366519) @@ -454,12 +454,12 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas break; default: - printf("kldload: unexpected relocation type %d\n", - rtype); + printf("kldload: unexpected relocation type %d, " + "symbol index %d\n", rtype, symidx); return (-1); } - return(0); + return (0); } int Modified: head/sys/powerpc/powerpc/elf32_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/elf32_machdep.c Wed Oct 7 17:46:49 2020 (r366518) +++ head/sys/powerpc/powerpc/elf32_machdep.c Wed Oct 7 18:48:10 2020 (r366519) @@ -262,14 +262,14 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas case R_PPC_ADDR32: /* word32 S + A */ error = lookup(lf, symidx, 1, &addr); if (error != 0) - return -1; + return (-1); *where = elf_relocaddr(lf, addr + addend); break; case R_PPC_ADDR16_LO: /* #lo(S) */ error = lookup(lf, symidx, 1, &addr); if (error != 0) - return -1; + return (-1); /* * addend values are sometimes relative to sections * (i.e. .rodata) in rela, where in reality they @@ -284,7 +284,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas case R_PPC_ADDR16_HA: /* #ha(S) */ error = lookup(lf, symidx, 1, &addr); if (error != 0) - return -1; + return (-1); /* * addend values are sometimes relative to sections * (i.e. .rodata) in rela, where in reality they @@ -311,7 +311,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas */ error = lookup(lf, symidx, 1, &addr); if (error != 0) - return -1; + return (-1); *where = elf_relocaddr(lf, addr + addend); break; @@ -323,11 +323,11 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas break; default: - printf("kldload: unexpected relocation type %d\n", - (int) rtype); - return -1; + printf("kldload: unexpected relocation type %d, " + "symbol index %d\n", (int)rtype, symidx); + return (-1); } - return(0); + return (0); } void Modified: head/sys/powerpc/powerpc/elf64_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/elf64_machdep.c Wed Oct 7 17:46:49 2020 (r366518) +++ head/sys/powerpc/powerpc/elf64_machdep.c Wed Oct 7 18:48:10 2020 (r366519) @@ -342,7 +342,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas case R_PPC64_ADDR64: /* doubleword64 S + A */ error = lookup(lf, symidx, 1, &addr); if (error != 0) - return -1; + return (-1); addr += addend; *where = addr; break; @@ -369,11 +369,11 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas break; default: - printf("kldload: unexpected relocation type %d\n", - (int) rtype); - return -1; + printf("kldload: unexpected relocation type %d, " + "symbol index %d\n", (int)rtype, symidx); + return (-1); } - return(0); + return (0); } void Modified: head/sys/riscv/riscv/elf_machdep.c ============================================================================== --- head/sys/riscv/riscv/elf_machdep.c Wed Oct 7 17:46:49 2020 (r366518) +++ head/sys/riscv/riscv/elf_machdep.c Wed Oct 7 18:48:10 2020 (r366519) @@ -479,7 +479,8 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas break; default: - printf("kldload: unexpected relocation type %ld\n", rtype); + printf("kldload: unexpected relocation type %ld, " + "symbol index %ld\n", rtype, symidx); return (-1); }