Date: Sat, 29 Aug 1998 23:16:29 +0100 (IST) From: rotel@indigo.ie To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/7779: [PATCH] modload should detect stripped kernels and use consistent option names Message-ID: <199808292216.XAA03397@indigo.ie>
next in thread | raw e-mail | index | archive | help
>Number: 7779 >Category: bin >Synopsis: [PATCH] modload should detect stripped kernels and use consistent option names >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Aug 29 15:30:01 PDT 1998 >Last-Modified: >Originator: Niall Smart >Organization: >Release: FreeBSD 2.2.7-STABLE i386 >Environment: >Description: This patch addresses two problems: 1) modload should fail more intelligently when the kernel has no symbols; I inadvertantly forgot the -d argument to strip when stripping down the kernel after a config -g and it took me a while to figure out what was happening. :) 2) modload should use -N to specify the kernel file as per ps, fstat, ccdconfig, dmesg, vmstat, pstat, swapinfo, iostat, ncrcontrol, ipcs, netstat, nfsstat and w. -A is provided for backwards compatability. (ahh, perfection) >How-To-Repeat: strip -d /kernel modload -N /kernel /lkm/linux_mod.o >Fix: Index: modload.8 =================================================================== RCS file: /cvs/src/sbin/modload/modload.8,v retrieving revision 1.11 diff -c -r1.11 modload.8 *** modload.8 1998/03/19 07:45:37 1.11 --- modload.8 1998/08/29 22:11:08 *************** *** 34,40 **** .Sh SYNOPSIS .Nm modload .Op Fl dquv ! .Op Fl A Ar kernel .Op Fl e Ar entry .Op Fl p Ar postinstall .Op Fl o Ar output_file --- 34,40 ---- .Sh SYNOPSIS .Nm modload .Op Fl dquv ! .Op Fl N Ar kernel .Op Fl e Ar entry .Op Fl p Ar postinstall .Op Fl o Ar output_file *************** *** 62,72 **** temporary file to be kept rather than deleted. .It Fl v Print comments about the loading process. ! .It Fl A Ar kernel Specify the file that is passed to the linker to resolve module references to external symbols. The symbol file must be for the currently running kernel or the module is likely to crash the system. .It Fl e Ar entry Specify the module entry point. This is passed by --- 62,75 ---- temporary file to be kept rather than deleted. .It Fl v Print comments about the loading process. ! .It Fl N Ar kernel Specify the file that is passed to the linker to resolve module references to external symbols. The symbol file must be for the currently running kernel or the module is likely to crash the system. + The option + .Fl A + is synonymous and provided for backwards compatability. .It Fl e Ar entry Specify the module entry point. This is passed by Index: modload.c =================================================================== RCS file: /cvs/src/sbin/modload/modload.c,v retrieving revision 1.23 diff -c -r1.23 modload.c *** modload.c 1998/08/12 02:39:23 1.23 --- modload.c 1998/08/29 22:11:10 *************** *** 62,68 **** /* * Expected linker options: * ! * -A executable to link against * -e entry point * -o output file * -T address to link to in hex (assumes it's a page boundry) --- 62,68 ---- /* * Expected linker options: * ! * -N executable to link against * -e entry point * -o output file * -T address to link to in hex (assumes it's a page boundry) *************** *** 78,89 **** char addrbuf[32], entrybuf[_POSIX2_LINE_MAX]; pid_t pid; int status; snprintf(entrybuf, sizeof entrybuf, "_%s", entry); snprintf(addrbuf, sizeof addrbuf, "%x", address); if (debug) ! printf("%s -A %s -e %s -o %s -T %s %s\n", _PATH_LD, kernel, entrybuf, outfile, addrbuf, object); --- 78,100 ---- char addrbuf[32], entrybuf[_POSIX2_LINE_MAX]; pid_t pid; int status; + struct exec se; + int fd; + + if ( (fd = open(kernel, O_RDONLY, 0)) < 0) + err(1, "open: %s", kernel); + + if (read(fd, &se, sizeof(se)) != sizeof(se)) + errx(1, "cannot read exec structure: file too small: %s", kernel); + + if (se.a_syms == 0) + errx(1, "cannot load module: no debugging symbols found in %s", kernel); snprintf(entrybuf, sizeof entrybuf, "_%s", entry); snprintf(addrbuf, sizeof addrbuf, "%x", address); if (debug) ! printf("%s -N %s -e %s -o %s -T %s %s\n", _PATH_LD, kernel, entrybuf, outfile, addrbuf, object); *************** *** 121,127 **** { fprintf(stderr, ! "usage: modload [-d] [-v] [-q] [-u] [-A <kernel>] [-e <entry]\n"); fprintf(stderr, " [-p <postinstall>] [-o <output file>] <input file>\n"); exit(1); --- 132,138 ---- { fprintf(stderr, ! "usage: modload [-d] [-v] [-q] [-u] [-N <kernel>] [-e <entry]\n"); fprintf(stderr, " [-p <postinstall>] [-o <output file>] <input file>\n"); exit(1); *************** *** 174,180 **** int sz, bytesleft; char buf[MODIOBUF]; ! while ((c = getopt(argc, argv, "dvquA:e:p:o:")) != -1) { switch (c) { case 'd': debug = 1; --- 185,191 ---- int sz, bytesleft; char buf[MODIOBUF]; ! while ((c = getopt(argc, argv, "dvquA:N:e:p:o:")) != -1) { switch (c) { case 'd': debug = 1; *************** *** 188,194 **** case 'q': quiet = 1; break; ! case 'A': kname = optarg; break; /* kernel */ case 'e': --- 199,206 ---- case 'q': quiet = 1; break; ! case 'A': /* deprecated, use -N */ ! case 'N': kname = optarg; break; /* kernel */ case 'e': >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808292216.XAA03397>