Subject: Re: newvers.sh padding problem
To: Charles M. Hannum <root@ihack.net>
From: Brian C. Grayson <bgrayson@orac.ece.utexas.edu>
List: tech-kern
Date: 02/01/1999 22:37:37
On Mon, Feb 01, 1999 at 05:08:45AM -0500, Charles M. Hannum wrote:
> 
> BTW, note that with Curt's change, libkvm, kvm_mkdb(8) and savecore(8)
> (and anything else that reads the version string out of the kernel)
> would all have to be changed, because the `version' symbol would now
> point to the address of the string.  This is kind of a PITA for
> upgrade purposes.

  Here's a different idea.  It's a gross hack, and relies upon
gcc.  But I think it successfully avoids all padding/alignment
issues:

char sccs[] = "@(#)NetBSD 1.3I ....\n";
void version () __attribute__((alias("sccs+4")));

  Note that from the version-grovelers point of view, they
don't care that `version' is supposedly a function.  Ain't C
wonderful?  :)  (I couldn't get aliasing to work with char*.)

  To take care of non-gcc compiles, we could generate:

#if defined(__GNUC__)
char sccs[] = "@(#)NetBSD 1.3I ....\n";
void version () __attribute__((alias("sccs+4")));
#else
char sccs[] = "@(#)NetBSD 1.3I ....\n";
/*  Waste a few bytes of storage in order to avoid padding/alignment issues.  */
char version[] = "NetBSD 1.3I ....\n";	
#endif

  Is the only reason to maintain a single array simply to save
those 120 bytes or so?

  Brian