From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 24 22:41:18 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D252716A419 for ; Thu, 24 Jan 2008 22:41:18 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id C46B313C447 for ; Thu, 24 Jan 2008 22:41:18 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 1D6141A4D80; Thu, 24 Jan 2008 14:19:36 -0800 (PST) Date: Thu, 24 Jan 2008 14:19:36 -0800 From: Alfred Perlstein To: hackers@freebsd.org Message-ID: <20080124221936.GS99258@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Cc: Subject: sysctl text definitions. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 22:41:18 -0000 Hey guys, something that I've always wanted to do was actually somehow export those handy description strings from the kernel SYSCTL macros in the least obtrusive method possible. The only thing I could come up with that didn't require compiling the files twice was to basically do some tricks where the text strings wound up in some throw-away section of the object files. Any suggestions on how to do this? In "psuedo-code" what I would do is something like change SYSCTL_* and add the following: SYSCTL_INT(...., text) \ ...old define...\ SYSCTL_COMMENT(parent, node, text) Also, add the following struct someplace: struct sysctl_comment { const char *parent; const char *node; const char *comment; }; Then SYSCTL_COMMENT does something like (more psuedocode): #define SYSCTL_COMMENT(parent, node, comment) \ .set sysctl_comments { \ struct sysctl_comment uniquifier = { \ .parent = parent; \ .node = node; \ .comment = comment; \ }; Then after building the kernel one should be able to do: for file in kernel ${modules} ; do strip --section=sysctl_comments file > file.install objdump --section=sysctl_comment file > file.sysctl.out sysctl_help_database_builder file.sysctl.out > file.sysctl.db done Then these would be copied into /boot or maybe some other place as part of the install process. Sysctl or some other util could then read these db files to give help with sysctls. Any ideas/pointers on how to do this linker magic? -- - Alfred Perlstein