diff options
author | markm <markm@FreeBSD.org> | 2002-07-16 12:28:50 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2002-07-16 12:28:50 +0000 |
commit | bedd05ccecbd002c4865f3dff35af258f0e5dd94 (patch) | |
tree | 4dcd84e724c9495af7116ae6dbbcee1b0420fb84 /lib/csu/i386-elf | |
parent | 4de6bef14519eb23505d35e15226e5711028252c (diff) | |
download | FreeBSD-src-bedd05ccecbd002c4865f3dff35af258f0e5dd94.zip FreeBSD-src-bedd05ccecbd002c4865f3dff35af258f0e5dd94.tar.gz |
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
Diffstat (limited to 'lib/csu/i386-elf')
-rw-r--r-- | lib/csu/i386-elf/crt1.c | 43 |
1 files changed, 25 insertions, 18 deletions
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 <stddef.h> #include <stdlib.h> #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); |