diff options
Diffstat (limited to 'lib/csu/alpha')
-rw-r--r-- | lib/csu/alpha/Makefile | 10 | ||||
-rw-r--r-- | lib/csu/alpha/crt0.c | 108 | ||||
-rw-r--r-- | lib/csu/alpha/md_init.h | 19 |
3 files changed, 23 insertions, 114 deletions
diff --git a/lib/csu/alpha/Makefile b/lib/csu/alpha/Makefile index 1c688ccf8de..f668d772d21 100644 --- a/lib/csu/alpha/Makefile +++ b/lib/csu/alpha/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.20 2011/11/08 10:37:09 guenther Exp $ +# $OpenBSD: Makefile,v 1.21 2013/12/03 06:21:40 guenther Exp $ # $NetBSD: Makefile,v 1.6 1996/10/18 05:27:38 thorpej Exp $ CFLAGS+= -DELFSIZE=64 @@ -12,14 +12,14 @@ CFLAGS+= -I${ELFDIR} -I${.CURDIR} all: ${OBJS} crt0.o: crt0.c - @echo ${COMPILE.c} -DCRT0 -fPIE ${.CURDIR}/crt0.c -o ${.TARGET} - @${COMPILE.c} -DCRT0 -fPIE ${.CURDIR}/crt0.c -o ${.TARGET}.o + @echo ${COMPILE.c} -DCRT0 -fPIE ${ELFDIR}/crt0.c -o ${.TARGET} + @${COMPILE.c} -DCRT0 -fPIE ${ELFDIR}/crt0.c -o ${.TARGET}.o @${LD} -x -r -o ${.TARGET} ${.TARGET}.o @rm -f ${.TARGET}.o gcrt0.o: crt0.c - @echo ${COMPILE.c} -DMCRT0 ${.CURDIR}/crt0.c -o ${.TARGET} - @${COMPILE.c} -DMCRT0 ${.CURDIR}/crt0.c -o ${.TARGET}.o + @echo ${COMPILE.c} -DMCRT0 ${ELFDIR}/crt0.c -o ${.TARGET} + @${COMPILE.c} -DMCRT0 ${ELFDIR}/crt0.c -o ${.TARGET}.o @${LD} -x -r -o ${.TARGET} ${.TARGET}.o @rm -f ${.TARGET}.o diff --git a/lib/csu/alpha/crt0.c b/lib/csu/alpha/crt0.c deleted file mode 100644 index 28873820552..00000000000 --- a/lib/csu/alpha/crt0.c +++ /dev/null @@ -1,108 +0,0 @@ -/* $OpenBSD: crt0.c,v 1.10 2005/08/04 16:33:04 espie Exp $ */ -/* $NetBSD: crt0.c,v 1.1 1996/09/12 16:59:02 cgd Exp $ */ -/* - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * 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. - */ - -#include <stdlib.h> -#include <limits.h> - -static char *_strrchr(char *, char); - -char **environ; -char *__progname = ""; -char __progname_storage[NAME_MAX+1]; - -#ifdef MCRT0 -extern void monstartup(u_long, u_long); -extern void _mcleanup(void); -extern unsigned char _etext, _eprol; -#endif /* MCRT0 */ - -__asm(".globl _start"); -__asm(".type _start@function"); -__asm("_start = __start"); -void -__start(sp, cleanup, obj) - char **sp; - void (*cleanup)(void); /* from shared loader */ - const void *obj; /* from shared loader */ -{ - long argc; - char **argv, *namep; - char *s; - - argc = *(long *)sp; - argv = sp + 1; - environ = sp + 2 + argc; /* 2: argc + NULL ending argv */ - - if ((namep = argv[0]) != NULL) { /* NULL ptr if argc = 0 */ - if ((__progname = _strrchr(namep, '/')) == NULL) - __progname = namep; - else - __progname++; - for (s = __progname_storage; *__progname && - s < &__progname_storage[sizeof __progname_storage - 1]; ) - *s++ = *__progname++; - *s = '\0'; - __progname = __progname_storage; - } - -#ifdef MCRT0 - atexit(_mcleanup); - monstartup((u_long)&_eprol, (u_long)&_etext); -#endif - - __init(); - - exit(main(argc, argv, environ)); -} - - -static char * -_strrchr(p, ch) -register char *p, ch; -{ - register char *save; - - for (save = NULL;; ++p) { - if (*p == ch) - save = (char *)p; - if (!*p) - return(save); - } -/* NOTREACHED */ -} - -#ifdef MCRT0 -asm (" .text"); -asm ("_eprol:"); -#endif - diff --git a/lib/csu/alpha/md_init.h b/lib/csu/alpha/md_init.h index 020b05c3bff..04a726860ab 100644 --- a/lib/csu/alpha/md_init.h +++ b/lib/csu/alpha/md_init.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md_init.h,v 1.1 2004/01/08 14:59:15 drahn Exp $ */ +/* $OpenBSD: md_init.h,v 1.2 2013/12/03 06:21:40 guenther Exp $ */ /*- * Copyright (c) 2001 Ross Harvey * All rights reserved. @@ -61,3 +61,20 @@ " lda $30, 16($30) \n" \ " ret \n" \ " .previous") + +/* XXX this should not be necessary: ld should use __start */ +#define MD_CRT0_START \ + __asm ( \ + ".globl _start \n" \ + ".type _start@function \n" \ + "_start = __start") + +#define MD_START __start +#define MD_START_ARGS char **sp, void (*cleanup)(void) +#define MD_START_SETUP \ + char **argv, **envp; \ + long argc; \ + \ + argc = *(long *)sp; \ + argv = sp + 1; \ + environ = envp = sp + 2 + argc; /* 2: argc + NULL ending argv */ |