Date: Thu, 24 Jan 2008 14:19:36 -0800 From: Alfred Perlstein <alfred@freebsd.org> To: hackers@freebsd.org Subject: sysctl text definitions. Message-ID: <20080124221936.GS99258@elvis.mu.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080124221936.GS99258>