From bedd05ccecbd002c4865f3dff35af258f0e5dd94 Mon Sep 17 00:00:00 2001 From: markm Date: Tue, 16 Jul 2002 12:28:50 +0000 Subject: The main reason for this is to reduce diffs between all the crt1.c's. Assembler macros are tidied up and made as similar as sanely possible. The macros are translated into C (__inline static) functions for lint. Declaration orders are made the same. Declarations are all ISOfied and tidied up. Comment contents have gratuitous diffs removed. The net result is a bunch of crt1.c's that are 90% the same. It may be possible to now encapsulate the differences in one MD header, and have only one MI crt1.c file (although the macros to do this may be ugly). Helpful comments by: obrien, bde Alpha tested by: des i386-elf tested by: markm --- lib/csu/i386-elf/crt1.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'lib/csu/i386-elf') diff --git a/lib/csu/i386-elf/crt1.c b/lib/csu/i386-elf/crt1.c index 5df6e11..a9caf9e 100644 --- a/lib/csu/i386-elf/crt1.c +++ b/lib/csu/i386-elf/crt1.c @@ -23,21 +23,26 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef lint #ifndef __GNUC__ #error "GCC is needed to compile this file" #endif +#endif /* lint */ -#include #include #include "libc_private.h" #include "crtbrand.c" +extern int _DYNAMIC; +#pragma weak _DYNAMIC + typedef void (*fptr)(void); extern void _fini(void); extern void _init(void); extern int main(int, char **, char **); +extern void _start(char *, ...); #ifdef GCRT extern void _mcleanup(void); @@ -46,33 +51,35 @@ extern int eprol; extern int etext; #endif -extern int _DYNAMIC; -#pragma weak _DYNAMIC +char **environ; +const char *__progname = ""; -#ifdef __i386__ -#define get_rtld_cleanup() \ - ({ fptr __value; \ - __asm__("movl %%edx,%0" : "=rm"(__value)); \ - __value; }) +static __inline fptr +get_rtld_cleanup(void) +{ + fptr retval; + +#ifdef __GNUC__ + __asm__("movl %%edx,%0" : "=rm"(retval)); #else -#error "This file only supports the i386 architecture" + retval = (fptr)0; /* XXXX Fix this for other compilers */ #endif + return(retval); +} -char **environ; -const char *__progname = ""; - +/* The entry function. */ void -_start(char *arguments, ...) +_start(char *ap, ...) { - fptr rtld_cleanup; + fptr cleanup; int argc; char **argv; char **env; const char *s; - rtld_cleanup = get_rtld_cleanup(); - argv = &arguments; - argc = * (int *) (argv - 1); + cleanup = get_rtld_cleanup(); + argv = ≈ + argc = *(long *)(void *)(argv - 1); env = argv + argc + 1; environ = env; if (argc > 0 && argv[0] != NULL) { @@ -83,7 +90,7 @@ _start(char *arguments, ...) } if (&_DYNAMIC != NULL) - atexit(rtld_cleanup); + atexit(cleanup); #ifdef GCRT atexit(_mcleanup); -- cgit v1.1