diff options
author | Paul Irofti <pirofti@cvs.openbsd.org> | 2011-07-04 05:42:12 +0000 |
---|---|---|
committer | Paul Irofti <pirofti@cvs.openbsd.org> | 2011-07-04 05:42:12 +0000 |
commit | f57b852a44563605cd60c0185254420b8d416162 (patch) | |
tree | f284ec83961a1a75e473e6ad13de11304bec08b7 /lib/csu/ia64 | |
parent | 23a0d21cbfe53a9d6cfb0af3ad13ff7b31da8aa6 (diff) |
Add csu ia64 support.
Diffstat (limited to 'lib/csu/ia64')
-rw-r--r-- | lib/csu/ia64/Makefile | 61 | ||||
-rw-r--r-- | lib/csu/ia64/crt0.c | 95 | ||||
-rw-r--r-- | lib/csu/ia64/md_init.h | 57 |
3 files changed, 213 insertions, 0 deletions
diff --git a/lib/csu/ia64/Makefile b/lib/csu/ia64/Makefile new file mode 100644 index 00000000000..db7efa10885 --- /dev/null +++ b/lib/csu/ia64/Makefile @@ -0,0 +1,61 @@ +# $OpenBSD: Makefile,v 1.1 2011/07/04 05:42:10 pirofti Exp $ + +CFLAGS+= -fno-omit-frame-pointer +OBJS= crt0.o gcrt0.o +OBJS+= crtbegin.o crtend.o +OBJS+= crtbeginS.o crtendS.o +SRCS= crt0.c crtbegin.c crtbeginS.c crtend.c crtendS.c + +ELFDIR= ${.CURDIR}/../common_elf +.PATH: ${ELFDIR} +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 + @${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 + @${LD} -x -r -o ${.TARGET} ${.TARGET}.o + @rm -f ${.TARGET}.o + +crtbegin.o: crtbegin.c + @echo ${COMPILE.c} -fpie ${ELFDIR}/crtbegin.c -o ${.TARGET} + @${COMPILE.c} -fpie ${ELFDIR}/crtbegin.c -o ${.TARGET}.o + @${LD} -x -r -o ${.TARGET} ${.TARGET}.o + @rm -f ${.TARGET}.o + +crtbeginS.o: crtbeginS.c + @echo ${COMPILE.c} ${PICFLAG} ${ELFDIR}/crtbeginS.c -o ${.TARGET} + @${COMPILE.c} ${PICFLAG} ${ELFDIR}/crtbeginS.c -o ${.TARGET}.o + @${LD} -x -r -o ${.TARGET} ${.TARGET}.o + @rm -f ${.TARGET}.o + +crtend.o: crtend.c + @echo ${COMPILE.c} -fpie ${ELFDIR}/crtend.c -o ${.TARGET} + @${COMPILE.c} -fpie ${ELFDIR}/crtend.c -o ${.TARGET}.o + @${LD} -x -r -o ${.TARGET} ${.TARGET}.o + @rm -f ${.TARGET}.o + +crtendS.o: crtendS.c + @echo ${COMPILE.c} ${PICFLAG} ${ELFDIR}/crtendS.c -o ${.TARGET} + @${COMPILE.c} ${PICFLAG} ${ELFDIR}/crtendS.c -o ${.TARGET}.o + @${LD} -x -r -o ${.TARGET} ${.TARGET}.o + @rm -f ${.TARGET}.o + +realinstall: + ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 ${OBJS} \ + ${DESTDIR}/usr/lib + +afterdepend: .depend + @(TMP=/tmp/_depend$$$$; \ + sed -e 's/^\([^\.]*\).o[ ]*:/\1.o g\1.o:/' \ + < .depend > $$TMP; \ + mv $$TMP .depend) + +.include <bsd.prog.mk> diff --git a/lib/csu/ia64/crt0.c b/lib/csu/ia64/crt0.c new file mode 100644 index 00000000000..09125016be9 --- /dev/null +++ b/lib/csu/ia64/crt0.c @@ -0,0 +1,95 @@ +/* $OpenBSD: crt0.c,v 1.1 2011/07/04 05:42:11 pirofti Exp $ */ + +/* + * Copyright (c) 2011 Paul Irofti <pirofti@openbsd.org> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/param.h> +#include <sys/exec.h> +#include <stdlib.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 ("1: \ + { .mii \ + mov r15=@gprel(1b) \n \ + mov r16=ip ;; \n \ + sub gp=r16,r15 \n \ + ;; \ + } "); + +void +___start(int argc, char **argv, char **envp, void (*cleanup)(void), + const void *obj, struct ps_strings *ps_strings) +{ + char *namep; + register struct kframe *kfp; + char *s; + + environ = envp; + + 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/ia64/md_init.h b/lib/csu/ia64/md_init.h new file mode 100644 index 00000000000..0c2cfb2572b --- /dev/null +++ b/lib/csu/ia64/md_init.h @@ -0,0 +1,57 @@ +/* $OpenBSD: md_init.h,v 1.1 2011/07/04 05:42:11 pirofti Exp $ */ + +/* + * Copyright (c) 2011 Paul Irofti <pirofti@openbsd.org> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/cdefs.h> +#include <machine/asm.h> + +#define MD_SECT_CALL_FUNC(section, func) \ + __asm (".section "#section", \"ax\" \n" \ + " br.call.sptk rp="#func" \n" \ + " .previous") + + +/*- + * $FreeBSD: src/lib/csu/ia64/crti.S,v 1.3 2001/11/03 06:31:27 peter Exp $ + */ + +#define MD_SECTION_PROLOGUE(sect, entry_pt) \ + __asm ( \ + ".section "#sect",\"ax\",@progbits \n" \ + ".proc "#entry_pt" \n" \ + ".global "#entry_pt" \n" \ + #entry_pt": \n" \ + ".regstk 0,2,0,0 \n" \ + ".prologue 12,loc0 \n" \ + ".save ar.pfs,loc1 \n" \ + "alloc loc1=ar.pfs,0,2,0,0 \n" \ + "mov loc0=b0 /* Save return addr */ \n" \ + ".endp "#entry_pt" \n" \ + ".previous") + +/*- + * $FreeBSD: src/lib/csu/ia64/crtn.S,v 1.2 2001/10/29 10:18:58 peter Exp $ + */ + +#define MD_SECTION_EPILOGUE(sect) \ + __asm ( \ + ".section "#sect",\"ax\",@progbits \n" \ + ".regstk 0,2,0,0 \n" \ + "mov b0=loc0 /*Recover return addr*/ \n" \ + "mov ar.pfs=loc1 \n" \ + "br.ret.sptk.many b0 \n" \ + ".previous") |