Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Jul 2005 14:39:37 +0900
From:      "R. Imura" <imura@ryu16.org>
To:        Jilles Tjoelker <jilles@stack.nl>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: what(1) on kernel binary
Message-ID:  <20050701053937.GA40965%imura@ryu16.org>
In-Reply-To: <20050620152649.GA1201@stack.nl>
References:  <20050620152649.GA1201@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

On Mon, Jun 20, 2005 at 05:26:49PM +0200, Jilles Tjoelker wrote:
> On FreeBSD 4.x, one could easily determine the version and compilation
> date of a kernel binary like this:
> 
> jilles@toad /home/jilles% what /kernel
> /kernel:
>         FreeBSD 4.11-STABLE #20: Mon May  9 18:43:52 CEST 2005
> 
> On FreeBSD 5.x/6.x with GCC 3.x, this doesn't work anymore.
> 
> The cause is that these two arrays (in /sys/conf/newvers.sh) are now both
> aligned to a 32-byte boundary, so there are 28 null bytes between @(#)
> and the version number:
> 
> char sccspad[32 - 4 /* sizeof(sccs) */] = { '\\0' };
> char sccs[4] = { '@', '(', '#', ')' };
> 
> A possible solution is to change the two arrays to a single one
> containing 28 null bytes and @(#).
> 
> char sccs[32] = { '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0',
> '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0',
> '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0',
> '\\0', '@', '(', '#', ')' };

It works ok with the former option(A), but it doesn't with latter(B) with my
FreeBSD box.

(A) cc -c vers.c

(B) cc -c -O2 -frename-registers -pipe -fno-strict-aliasing  -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -fformat-extensions -std=c99 -g -nostdinc -I-  -I. -I/usr/src/sys -I/usr/src/sys/contrib/dev/acpica -I/usr/src/sys/contrib/altq -I/usr/src/sys/contrib/ipfilter -I/usr/src/sys/contrib/pf -I/usr/src/sys/contrib/dev/ath -I/usr/src/sys/contrib/dev/ath/freebsd -I/usr/src/sys/contrib/ngatm -I/usr/src/sys/dev/twa -D_KERNEL -include opt_global.h -fno-common -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000  -fno-omit-frame-pointer -mcmodel=kernel -mno-red-zone  -mfpmath=387 -mno-sse -mno-sse2 -mno-mmx -mno-3dnow  -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -Werror  vers.c

IMHO, the simplest solution is duplicate writing ${VERSION} like this,
but this would let kernel be 20-30bytes bigger.

-------------------------------
cat << EOF > vers.c
$COPYRIGHT
char sccs[] = "@(#)${VERSION} #${v}: ${t}";
char version[] = "${VERSION} #${v}: ${t}\\n    ${u}@${h}:${d}\\n";
char ostype[] = "${TYPE}";
char osrelease[] = "${RELEASE}";
int osreldate = ${RELDATE};
char kern_ident[] = "${i}";
EOF
-------------------------------

Regards,
- R. Imura



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050701053937.GA40965%imura>