From owner-freebsd-audit Thu Jan 17 22:19:47 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id ABAB737B417 for ; Thu, 17 Jan 2002 22:19:41 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id RAA13730; Fri, 18 Jan 2002 17:18:26 +1100 Date: Fri, 18 Jan 2002 17:19:45 +1100 (EST) From: Bruce Evans X-X-Sender: To: Mark Murray Cc: Subject: Re: lib/csu cleanup In-Reply-To: <200201172146.g0HLkft13995@grimreaper.grondar.org> Message-ID: <20020118165527.R4892-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 17 Jan 2002, Mark Murray wrote: > 1) I've wrapped some _horrible_ assembler in #ifndef lint/#endif. > What is a better way (if any)? #ifndef __STDC__ does not cut it Wrap it in __GNUC__ (it is gcc-specific), and unbreak lint so that it doesn't define __GNUC__. > as GCC's preprocessor defines that for lint. I have a half-baked > idea for COMPILING and LINTING macros, but I'm sure there is > a better way. Mebbe its just using 'lint'? > > 2) Where can _start() be prototyped? Where is is used? Before itself. ld(1). > Index: alpha/crt1.c > =================================================================== > RCS file: /home/ncvs/src/lib/csu/alpha/crt1.c,v > retrieving revision 1.10 > diff -u -d -r1.10 crt1.c > --- alpha/crt1.c 26 Oct 2001 06:45:10 -0000 1.10 > +++ alpha/crt1.c 17 Jan 2002 21:11:52 -0000 > ... > @@ -72,13 +72,20 @@ > int argc; > char **argv; > char **env; > + const char *s; > + union { > + char **a; > + long *b; > + } xlat; /* Looks horrible, but is a convincing way > + * to translate different pointer types > + */ s/Looks horrible/Is horrible/ It just breaks lint's detection of unportabilities. Block comments are not formatted like this in KNF. > ... > @@ -108,7 +115,5 @@ > /* > * NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text. > */ > -#ifndef lint > -static const char rcsid[] = > - "$FreeBSD: src/lib/csu/alpha/crt1.c,v 1.10 2001/10/26 06:45:10 obrien Exp $"; > -#endif > + > +__FBSDID("$FreeBSD: src/lib/csu/alpha/crt1.c,v 1.10 2001/10/26 06:45:10 obrien Exp $"); The comment has rotted: old bitrot: __start() doesn't exist. new bitrot: _FBSDID() never puts the ID in .text for elf (check this). New style bug: blank line separates the comment from the code. > Index: i386-elf/crt1.c > =================================================================== > RCS file: /home/ncvs/src/lib/csu/i386-elf/crt1.c,v > retrieving revision 1.5 > diff -u -d -r1.5 crt1.c > --- i386-elf/crt1.c 28 Oct 2000 21:26:48 -0000 1.5 > +++ i386-elf/crt1.c 17 Jan 2002 21:18:03 -0000 > @@ -21,14 +21,13 @@ > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > - * > - * $FreeBSD: src/lib/csu/i386-elf/crt1.c,v 1.5 2000/10/28 21:26:48 obrien Exp $ > */ > > #ifndef __GNUC__ > #error "GCC is needed to compile this file" > #endif > > +#include Style bug. Including explicitly is a necessary evil if __FBSDID() is placed before other includes, but is not needed here. > #include > #include > #include "crtbrand.c" > @@ -50,16 +49,20 @@ > #pragma weak _DYNAMIC > > #ifdef __i386__ > +#ifndef lint > #define get_rtld_cleanup() \ > ({ fptr __value; \ > __asm__("movl %%edx,%0" : "=rm"(__value)); \ > __value; }) > #else > +#define get_rtld_cleanup() 0 > +#endif > +#else > #error "This file only supports the i386 architecture" > #endif See above. Also, lint failures when the function declared in asm doesn't exist (because it is hidden by __GNUC__) are correct. Linting this file should have failed already with the #error for the !__GNUC__ case. > ... > @@ -68,21 +71,27 @@ > int argc; > char **argv; > char **env; > + const char *s; > + union { > + char **a; > + int *b; > + } xlat; /* Looks horrible, but is a convincing way > + * to translate different pointer types > + */ As above. > @@ -101,3 +110,9 @@ > __asm__("eprol:"); > __asm__(".previous"); > #endif > + > +/* > + * NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text. > + */ > + > +__FBSDID("$FreeBSD: src/lib/csu/i386-elf/crt1.c,v 1.5 2000/10/28 21:26:48 obrien Exp $"); As above, except the comment was born broken. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message