diff options
Diffstat (limited to 'lib/csu/amd64/crt1.c')
-rw-r--r-- | lib/csu/amd64/crt1.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/lib/csu/amd64/crt1.c b/lib/csu/amd64/crt1.c index 5df6e11..a9caf9e 100644 --- a/lib/csu/amd64/crt1.c +++ b/lib/csu/amd64/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); |