From owner-freebsd-audit Thu Jan 17 13:49:14 2002 Delivered-To: freebsd-audit@freebsd.org Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.139.170]) by hub.freebsd.org (Postfix) with ESMTP id 9558037B416 for ; Thu, 17 Jan 2002 13:49:00 -0800 (PST) Received: (from uucp@localhost) by storm.FreeBSD.org.uk (8.11.6/8.11.6) with UUCP id g0HLmxG69030 for audit@freebsd.org; Thu, 17 Jan 2002 21:48:59 GMT (envelope-from mark@grondar.za) Received: from grondar.za (mark@localhost [127.0.0.1]) by grimreaper.grondar.org (8.11.6/8.11.6) with ESMTP id g0HLkft13995 for ; Thu, 17 Jan 2002 21:46:41 GMT (envelope-from mark@grondar.za) Message-Id: <200201172146.g0HLkft13995@grimreaper.grondar.org> To: audit@freebsd.org Subject: lib/csu cleanup Date: Thu, 17 Jan 2002 21:46:41 +0000 From: Mark Murray 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 Hi I've been running these patches for quite a while (the i386-elf ones anyway) without problems. They result is a diff reduction between i386-elf and alpha, and a mostlly clean report from the lint that I'm using. Also, it is mostly WARNS=4 clean (there is a whine about no prototype for _start()). There is a small bit of style cleanup. Questions: 1) I've wrapped some _horrible_ assembler in #ifndef lint/#endif. What is a better way (if any)? #ifndef __STDC__ does not cut it 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? 3) Could those with reviewing skills please have a look at this? M 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 @@ -60,7 +60,7 @@ #endif char **environ; -char *__progname = ""; +const char *__progname = ""; /* The entry function. */ void @@ -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 + */ - argc = * (long *) ap; + argv = xlat.a = ap; + argc = *xlat.b; argv = ap + 1; env = ap + 2 + argc; environ = env; if(argc > 0 && argv[0] != NULL) { - char *s; __progname = argv[0]; for (s = __progname; *s != '\0'; s++) if (*s == '/') @@ -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 $"); 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 #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 char **environ; -char *__progname = ""; +const char *__progname = ""; void _start(char *arguments, ...) @@ -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 + */ rtld_cleanup = get_rtld_cleanup(); - argv = &arguments; - argc = * (int *) (argv - 1); + xlat.a = argv = &arguments; + argc = *(xlat.b - 1); env = argv + argc + 1; environ = env; - if(argc > 0 && argv[0] != NULL) { - char *s; + if (argc > 0 && argv[0] != NULL) { __progname = argv[0]; for (s = __progname; *s != '\0'; s++) if (*s == '/') __progname = s + 1; } - if(&_DYNAMIC != NULL) + if (&_DYNAMIC != NULL) atexit(rtld_cleanup); #ifdef GCRT @@ -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 $"); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message