Update for AMD64. repocopied from i386-elf/crt1.c. Deal with regparm

argument passing rather than stack based args.  The kernel passes the
base of the argument/env vector in %rdi (arg1).
This commit is contained in:
Peter Wemm 2003-04-30 19:27:07 +00:00
parent fbc8f8a2dc
commit 1b376078fd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=114319

View File

@ -43,7 +43,7 @@ typedef void (*fptr)(void);
extern void _fini(void);
extern void _init(void);
extern int main(int, char **, char **);
extern void _start(char *, ...);
extern void _start(char **, void (*)(void));
#ifdef GCRT
extern void _mcleanup(void);
@ -55,33 +55,18 @@ extern int etext;
char **environ;
const char *__progname = "";
static __inline fptr
get_rtld_cleanup(void)
{
fptr retval;
#ifdef __GNUC__
__asm__("movl %%edx,%0" : "=rm"(retval));
#else
retval = (fptr)0; /* XXXX Fix this for other compilers */
#endif
return(retval);
}
/* The entry function. */
void
_start(char *ap, ...)
_start(char **ap, void (*cleanup)(void))
{
fptr cleanup;
int argc;
char **argv;
char **env;
const char *s;
cleanup = get_rtld_cleanup();
argv = ≈
argc = *(long *)(void *)(argv - 1);
env = argv + argc + 1;
argc = *(long *)(void *)ap;
argv = ap + 1;
env = ap + 2 + argc;
environ = env;
if (argc > 0 && argv[0] != NULL) {
__progname = argv[0];