delete all the a.out csu code.

This commit is contained in:
mrg 2010-07-05 21:27:55 +00:00
parent e73db95236
commit 4f893703d8
19 changed files with 4 additions and 1611 deletions

View File

@ -1,12 +1,12 @@
# $NetBSD: Makefile,v 1.25 2009/12/13 08:03:44 mrg Exp $
# $NetBSD: Makefile,v 1.26 2010/07/05 21:27:55 mrg Exp $
.include <bsd.own.mk>
.if ${OBJECT_FMT} == "ELF" && exists(${CSU_MACHINE_ARCH}_elf)
.if exists(${CSU_MACHINE_ARCH}_elf)
SUBDIR= ${CSU_MACHINE_ARCH}_elf
.elif ${OBJECT_FMT} == "ELF" && exists(${MACHINE_ARCH}_elf)
.elif exists(${MACHINE_ARCH}_elf)
SUBDIR= ${MACHINE_ARCH}_elf
.elif ${OBJECT_FMT} == "ELF" && exists(${MACHINE_CPU}_elf)
.elif exists(${MACHINE_CPU}_elf)
SUBDIR= ${MACHINE_CPU}_elf
.elif exists(${MACHINE_ARCH})
SUBDIR= ${MACHINE_ARCH}
@ -19,8 +19,4 @@ SUBDIR= ${MACHINE_CPU}
@false
.endif
.if (${OBJECT_FMT} != "ELF")
SUBDIR+= c++
.endif
.include <bsd.subdir.mk>

View File

@ -1,13 +0,0 @@
# $NetBSD: Makefile,v 1.14 2008/07/21 15:34:58 lukem Exp $
.include <bsd.own.mk>
OBJS+= c++rt0.o
c++rt0.o: c++rt0.c
${_MKTARGET_COMPILE}
${COMPILE.c} -fpic ${.ALLSRC}
${LD} -x -r ${.TARGET}
mv a.out ${.TARGET}
.include "${.CURDIR}/../common_aout/Makefile.inc"

View File

@ -1,156 +0,0 @@
/* $NetBSD: c++rt0.c,v 1.4 2008/04/28 20:22:54 martin Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Paul Kranenburg.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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.
*/
/*
* Run-time module for GNU C++ compiled shared libraries.
*
* The linker constructs the following arrays of pointers to global
* constructors and destructors. The first element contains the
* number of pointers in each.
* The tables are also null-terminated.
*/
#include <stdlib.h>
/*
* We make the __{C,D}TOR_LIST__ symbols appear as type `SETD' and
* include a dummy local function in the set. This keeps references
* to these symbols local to the shared object this module is linked to.
*/
static void dummy __P((void)) { return; }
/* Note: this is "a.out" dependent. */
__asm(".stabs \"___CTOR_LIST__\",22,0,0,_dummy");
__asm(".stabs \"___DTOR_LIST__\",22,0,0,_dummy");
#ifdef __arm32__ /* XXX ARM32_BROKEN_RELOCATIONS */
#define ARM32_BROKEN_RELOCATIONS /* XXX ARM32_BROKEN_RELOCATIONS */
#endif /* XXX ARM32_BROKEN_RELOCATIONS */
void (*__CTOR_LIST__[0]) __P((void));
void (*__DTOR_LIST__[0]) __P((void));
#ifdef ARM32_BROKEN_RELOCATIONS /* XXX ARM32_BROKEN_RELOCATIONS */
static void __dtors __P((long)); /* XXX ARM32_BROKEN_RELOCATIONS */
static void __ctors __P((long)); /* XXX ARM32_BROKEN_RELOCATIONS */
#else /* XXX ARM32_BROKEN_RELOCATIONS */
static void __dtors __P((void));
static void __ctors __P((void));
#endif
static void
#ifdef ARM32_BROKEN_RELOCATIONS /* XXX ARM32_BROKEN_RELOCATIONS */
__dtors(base) /* XXX ARM32_BROKEN_RELOCATIONS */
long base; /* XXX ARM32_BROKEN_RELOCATIONS */
#else /* XXX ARM32_BROKEN_RELOCATIONS */
__dtors()
#endif
{
unsigned long i = (unsigned long) __DTOR_LIST__[0];
void (**p)(void) = __DTOR_LIST__ + i;
while (i--)
#ifdef ARM32_BROKEN_RELOCATIONS /* XXX ARM32_BROKEN_RELOCATIONS */
(*(void (*)(void))((char *)(*p--) + base))(); /* XXX ... */
#else /* XXX ARM32_BROKEN_RELOCATIONS */
(**p--)();
#endif
}
static void
#ifdef ARM32_BROKEN_RELOCATIONS /* XXX ARM32_BROKEN_RELOCATIONS */
__ctors(base) /* XXX ARM32_BROKEN_RELOCATIONS */
long base; /* XXX ARM32_BROKEN_RELOCATIONS */
#else /* XXX ARM32_BROKEN_RELOCATIONS */
__ctors()
#endif
{
unsigned long i = (unsigned long) __CTOR_LIST__[0];
void (**p)(void) = __CTOR_LIST__ + 1;
while (i--)
#ifdef ARM32_BROKEN_RELOCATIONS /* XXX ARM32_BROKEN_RELOCATIONS */
(*(void (*)(void))((char *)(*p++) + base))(); /* XXX ... */
#else /* XXX ARM32_BROKEN_RELOCATIONS */
(**p++)();
#endif
}
#ifdef ARM32_BROKEN_RELOCATIONS /* XXX ARM32_BROKEN_RELOCATIONS */
extern void __init __P((long)) __asm(".init"); /* XXX ARM32_BROKEN_RELOCATIONS */
extern void __fini __P((long)) __asm(".fini"); /* XXX ARM32_BROKEN_RELOCATIONS */
#else /* XXX ARM32_BROKEN_RELOCATIONS */
extern void __init __P((void)) __asm(".init");
extern void __fini __P((void)) __asm(".fini");
#endif
void
#ifdef ARM32_BROKEN_RELOCATIONS /* XXX ARM32_BROKEN_RELOCATIONS */
__init(base) /* XXX ARM32_BROKEN_RELOCATIONS */
long base; /* XXX ARM32_BROKEN_RELOCATIONS */
#else /* XXX ARM32_BROKEN_RELOCATIONS */
__init()
#endif
{
static int initialized = 0;
/*
* Call global constructors.
* Arrange to call global destructors at exit.
*/
if (!initialized) {
initialized = 1;
#ifdef ARM32_BROKEN_RELOCATIONS /* XXX ARM32_BROKEN_RELOCATIONS */
__ctors(base); /* XXX ARM32_BROKEN_RELOCATIONS */
#else /* XXX ARM32_BROKEN_RELOCATIONS */
__ctors();
#endif /* XXX ARM32_BROKEN_RELOCATIONS */
}
}
void
#ifdef ARM32_BROKEN_RELOCATIONS /* XXX ARM32_BROKEN_RELOCATIONS */
__fini(base) /* XXX ARM32_BROKEN_RELOCATIONS */
long base; /* XXX ARM32_BROKEN_RELOCATIONS */
#else /* XXX ARM32_BROKEN_RELOCATIONS */
__fini()
#endif /* XXX ARM32_BROKEN_RELOCATIONS */
{
/*
* Call global destructors.
*/
#ifdef ARM32_BROKEN_RELOCATIONS /* XXX ARM32_BROKEN_RELOCATIONS */
__dtors(base); /* XXX ARM32_BROKEN_RELOCATIONS */
#else /* XXX ARM32_BROKEN_RELOCATIONS */
__dtors();
#endif /* XXX ARM32_BROKEN_RELOCATIONS */
}

View File

@ -1,158 +0,0 @@
/* $NetBSD: crt0.c,v 1.13 2008/06/21 00:52:52 gmcgarry Exp $ */
/*
* Copyright (C) 1997 Mark Brinicombe
* Copyright (C) 1995 Wolfgang Solfrank.
* Copyright (C) 1995 TooLs GmbH.
* 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 TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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 <sys/cdefs.h>
#include <stdlib.h>
#include "common.h"
#if defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5__) || \
defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5TE__) || \
defined (__ARM_ARCH_5TEJ__)
#define _ARM_ARCH_5
#endif
#if defined (_ARM_ARCH_5) || defined (__ARM_ARCH_4T__)
#define _ARM_ARCH_4T
#endif
#undef mmap
#define mmap(addr, len, prot, flags, fd, off) \
__syscall(SYS_mmap, (addr), (len), (prot), (flags), \
(fd), 0, (off_t)(off))
extern void start(void) __asm("start");
void __start(int, char *[], char *[]);
__asm("
.text
.align 0
.global start
start:
/* Get ps_strings pointer from kernel */
teq r10, #0
ldr r3, Lps_strings
movne r0, #0
str r0, [r3]
/* Get argc, argv, and envp from stack */
ldr r0, [sp, #0x0000]
add r1, sp, #0x0004
add r2, r1, r0, lsl #2
add r2, r2, #0x0004
b " ___STRING(_C_LABEL(__start)) "
.align 0
Lps_strings:
.word " ___STRING(_C_LABEL(__ps_strings)) "
");
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: crt0.c,v 1.13 2008/06/21 00:52:52 gmcgarry Exp $");
#endif /* LIBC_SCCS and not lint */
void
__start(int argc, char **argv, char **envp)
{
char *ap;
environ = envp;
if ((ap = argv[0]))
if ((__progname = _strrchr(ap, '/')) == NULL)
__progname = ap;
else
++__progname;
#ifdef DYNAMIC
/* ld(1) convention: if DYNAMIC = 0 then statically linked */
if (&_DYNAMIC)
__load_rtld(&_DYNAMIC);
#endif /* DYNAMIC */
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&eprol, (u_long)&etext);
#endif /* MCRT0 */
__asm("__callmain:"); /* Defined for the benefit of debuggers */
exit(main(argc, argv, envp));
}
#ifndef ntohl
inline in_addr_t
__crt0_swap(x)
in_addr_t x;
{
#if BYTE_ORDER == LITTLE_ENDIAN
return( ((x & 0x000000ff) << 24)
| ((x & 0x0000ff00) << 8)
| ((x & 0x00ff0000) >> 8)
| ((x & 0xff000000) >> 24));
#else
return x;
#endif /* BYTE_ORDER */
}
#define ntohl(x) __crt0_swap(x)
#define htonl(x) __crt0_swap(x)
#endif /* ntohl */
#ifdef DYNAMIC
__asm("
.text
.align 0
___syscall:
swi 0
mvncs r0, #0
"
#ifdef _ARM_ARCH_4T
" bx lr
"
#else
" mov pc, lr
"
#endif
);
#endif /* DYNAMIC */
#include "common.c"
#ifdef MCRT0
__asm("
.text
.align 0
eprol:
");
#endif /* MCRT0 */

View File

@ -1,22 +0,0 @@
# $NetBSD: Makefile,v 1.17 2008/07/21 15:34:58 lukem Exp $
.include <bsd.own.mk>
CPPFLAGS+= -DLIBC_SCCS
.if ${MKPIC} != "no"
COPTS+= -fPIC
.endif
OBJS= c++rt0.o
realall: ${OBJS}
c++rt0.o: c++rt0.c
${_MKTARGET_COMPILE}
${COMPILE.c} ${.ALLSRC}
${LD} -x -r ${.TARGET}
mv a.out ${.TARGET}
FILES=${OBJS}
FILESDIR=${LIBDIR}
.include <bsd.prog.mk>

View File

@ -1,106 +0,0 @@
/* $NetBSD: c++rt0.c,v 1.11 2008/04/28 20:22:54 martin Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Paul Kranenburg.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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.
*/
/*
* Run-time module for GNU C++ compiled shared libraries.
*
* The linker constructs the following arrays of pointers to global
* constructors and destructors. The first element contains the
* number of pointers in each.
* The tables are also null-terminated.
*/
#include <stdlib.h>
/*
* We make the __{C,D}TOR_LIST__ symbols appear as type `SETD' and
* include a dummy local function in the set. This keeps references
* to these symbols local to the shared object this module is linked to.
*/
static void dummy __P((void)) { return; }
/* Note: this is "a.out" dependent. */
__asm(".stabs \"___CTOR_LIST__\",22,0,0,_dummy");
__asm(".stabs \"___DTOR_LIST__\",22,0,0,_dummy");
void (*__CTOR_LIST__[0]) __P((void));
void (*__DTOR_LIST__[0]) __P((void));
static void __dtors __P((void));
static void __ctors __P((void));
static void
__dtors()
{
unsigned long i = (unsigned long) __DTOR_LIST__[0];
void (**p)(void) = __DTOR_LIST__ + i;
while (i--)
(**p--)();
}
static void
__ctors()
{
unsigned long i = (unsigned long) __CTOR_LIST__[0];
void (**p)(void) = __CTOR_LIST__ + 1;
while (i--)
(**p++)();
}
extern void __init __P((void)) __asm(".init");
extern void __fini __P((void)) __asm(".fini");
void
__init()
{
static int initialized = 0;
/*
* Call global constructors.
* Arrange to call global destructors at exit.
*/
if (!initialized) {
initialized = 1;
__ctors();
}
}
void
__fini()
{
/*
* Call global destructors.
*/
__dtors();
}

View File

@ -1,56 +0,0 @@
# $NetBSD: Makefile.inc,v 1.10 2008/07/21 15:34:58 lukem Exp $
# from: @(#)Makefile 5.5 (Berkeley) 5/21/91
CPPFLAGS+= -DLIBC_SCCS -I${.CURDIR}/../common_aout
OBJS+= crt0.o gcrt0.o scrt0.o
SRCS= crt0.c
.include <bsd.own.mk>
.include <bsd.shlib.mk>
.if ${MKPIC} != "no" && ${SHLINKINSTALLDIR} != "/usr/libexec"
OBJS+= lcrt0.o
.endif
realall: ${OBJS}
crt0.o: ${SRCS}
${_MKTARGET_COMPILE}
${COMPILE.c} -DCRT0 -DDYNAMIC ${.CURDIR}/${SRCS} -o ${.TARGET}.o
${LD} -x -r -o ${.TARGET} ${.TARGET}.o
rm -f ${.TARGET}.o
# dependant on crt0.o to pick up header dependencies
gcrt0.o: ${SRCS} crt0.o
${_MKTARGET_COMPILE}
${COMPILE.c} -DMCRT0 ${.CURDIR}/${SRCS} -o ${.TARGET}.o
${LD} -x -r -o ${.TARGET} ${.TARGET}.o
rm -f ${.TARGET}.o
scrt0.o: ${SRCS} crt0.o
${_MKTARGET_COMPILE}
${COMPILE.c} -DSCRT0 ${.CURDIR}/${SRCS} -o ${.TARGET}.o
${LD} -x -r -o ${.TARGET} ${.TARGET}.o
rm -f ${.TARGET}.o
# same as crt0.o modulo the dynamic linker is in /libexec
lcrt0.o: ${SRCS} crt0.o
${_MKTARGET_COMPILE}
${COMPILE.c} -DCRT0 -DDYNAMIC -DLDSO=\"${SHLINKINSTALLDIR}/ld.so\" ${.CURDIR}/${SRCS} -o ${.TARGET}.o
${LD} -x -r -o ${.TARGET} ${.TARGET}.o
rm -f ${.TARGET}.o
.if make(depend)
CPPFLAGS+= -DDYNAMIC
.endif
FILES=${OBJS}
FILESDIR=${LIBDIR}
CLEANFILES=${OBJS}
.if ${MKPIC} != "no" && ${SHLINKINSTALLDIR} != "/usr/libexec"
FILESDIR_lcrt0.o:=${SHLIBINSTALLDIR}
FILESNAME_lcrt0.o:=crt0.o
.endif
.include <bsd.prog.mk>

View File

@ -1,284 +0,0 @@
/* $NetBSD: common.c,v 1.20 2008/04/28 20:22:54 martin Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Paul Kranenburg.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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.
*/
#ifdef DYNAMIC
typedef int (*rtld_entry_fn) __P((int, struct crt_ldso *));
static struct ld_entry **ld_entry;
static void
__load_rtld(dp)
struct _dynamic *dp;
{
static struct crt_ldso crt;
struct exec hdr;
rtld_entry_fn entry;
#if defined(sun) && defined(DUPZFD)
int dupzfd;
#endif
#ifdef DEBUG
/* Provision for alternate ld.so - security risk! */
if ((crt.crt_ldso = _getenv("LDSO")) == NULL)
#endif
crt.crt_ldso = LDSO;
crt.crt_ldfd = open(crt.crt_ldso, 0, 0);
if (crt.crt_ldfd == -1) {
_FATAL("No ld.so\n");
}
/* Read LDSO exec header */
if (read(crt.crt_ldfd, &hdr, sizeof hdr) < sizeof hdr) {
_FATAL("Failure reading ld.so\n");
}
if (N_GETMAGIC(hdr) != ZMAGIC && N_GETMAGIC(hdr) != QMAGIC) {
_FATAL("Bad magic: ld.so\n");
}
#ifdef sun
/* Get bucket of zeroes */
crt.crt_dzfd = open("/dev/zero", 0, 0);
if (crt.crt_dzfd == -1) {
_FATAL("No /dev/zero\n");
}
#endif
#ifdef __NetBSD__
/* We use MAP_ANON */
crt.crt_dzfd = -1;
#endif
#if defined(sun) && defined(DUPZFD)
if ((dupzfd = dup(crt.crt_dzfd)) < 0) {
_FATAL("Cannot dup /dev/zero\n");
}
#endif
/* Map in ld.so */
crt.crt_ba = mmap(0, hdr.a_text+hdr.a_data+hdr.a_bss,
PROT_READ|PROT_EXEC,
MAP_FILE|MAP_PRIVATE,
crt.crt_ldfd, N_TXTOFF(hdr));
if (crt.crt_ba == -1) {
_FATAL("Cannot map ld.so\n");
}
#ifdef __NetBSD__
/* !!!
* This is gross, ld.so is a ZMAGIC a.out, but has `sizeof(hdr)' for
* an entry point and not at PAGSIZ as the N_*ADDR macros assume.
*/
#undef N_DATADDR
#undef N_BSSADDR
#define N_DATADDR(x) ((x).a_text)
#define N_BSSADDR(x) ((x).a_text + (x).a_data)
#endif
/* Map in data segment of ld.so writable */
if (mmap(crt.crt_ba+N_DATADDR(hdr), hdr.a_data,
PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_FILE|MAP_PRIVATE|MAP_FIXED,
crt.crt_ldfd, N_DATOFF(hdr)) == -1) {
_FATAL("Cannot map ld.so\n");
}
/* Map bss segment of ld.so zero */
if (hdr.a_bss && mmap(crt.crt_ba+N_BSSADDR(hdr), hdr.a_bss,
PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE|MAP_FIXED,
crt.crt_dzfd, 0) == -1) {
_FATAL("Cannot map ld.so\n");
}
crt.crt_dp = dp;
crt.crt_ep = environ;
crt.crt_bp = (caddr_t)_callmain;
crt.crt_prog = __progname;
#ifdef sun
/* Call Sun's ld.so entry point: version 1, offset crt */
__call(CRT_VERSION_SUN, &crt, crt.crt_ba + sizeof hdr);
#else
ld_entry = &crt.crt_ldentry;
entry = (rtld_entry_fn)(crt.crt_ba + sizeof hdr);
if ((*entry)(CRT_VERSION_BSD_4, &crt) == -1) {
/* Feeble attempt to deal with out-dated ld.so */
#ifdef __STDC__
# define str "crt0: update " LDSO "\n"
#else
# define str "crt0: update ld.so\n"
#endif
(void)write(2, str, sizeof(str)-1);
# undef str
if ((*entry)(CRT_VERSION_BSD_3, &crt) == -1) {
_FATAL("ld.so failed\n");
}
ld_entry = &dp->d_entry;
return;
}
atexit((*ld_entry)->dlexit);
#endif
#if defined(sun) && defined(DUPZFD)
if (dup2(dupzfd, crt.crt_dzfd) < 0) {
_FATAL("Cannot dup2 /dev/zero\n");
}
(void)close(dupzfd);
#endif
return;
}
/*
* DL stubs
*/
void *
dlopen(name, mode)
const char *name;
int mode;
{
if ((*ld_entry) == NULL)
return NULL;
return ((*ld_entry)->dlopen)(name, mode);
}
int
dlclose(fd)
void *fd;
{
if ((*ld_entry) == NULL)
return -1;
return ((*ld_entry)->dlclose)(fd);
}
void *
dlsym(fd, name)
void *fd;
const char *name;
{
if ((*ld_entry) == NULL)
return NULL;
return ((*ld_entry)->dlsym)(fd, name);
}
int
dlctl(fd, cmd, arg)
void *fd, *arg;
int cmd;
{
if ((*ld_entry) == NULL)
return -1;
return ((*ld_entry)->dlctl)(fd, cmd, arg);
}
__aconst char *
dlerror()
{
int error;
if ((*ld_entry) == NULL ||
(*(*ld_entry)->dlctl)(NULL, DL_GETERRNO, &error) == -1)
return "Service unavailable";
return ((char *)(error == 0 ? NULL : strerror(error)));
}
int
dladdr(addr, dli)
const void *addr;
Dl_info *dli;
{
if ((*ld_entry) == NULL || (*ld_entry)->dladdr == NULL)
return (0);
return ((*ld_entry)->dladdr)(addr, dli);
}
/*
* Support routines
*/
#ifdef DEBUG
static int
_strncmp(s1, s2, n)
char *s1, *s2;
int n;
{
if (n == 0)
return (0);
do {
if (*s1 != *s2++)
return (*(unsigned char *)s1 - *(unsigned char *)--s2);
if (*s1++ == 0)
break;
} while (--n != 0);
return (0);
}
static char *
_getenv(name)
char *name;
{
extern char **environ;
int len;
char **P, *C;
for (C = name, len = 0; *C && *C != '='; ++C, ++len);
for (P = environ; *P; ++P)
if (!_strncmp(*P, name, len))
if (*(C = *P + len) == '=') {
return(++C);
}
return (char *)0;
}
#endif
static char *
_strrchr(p, ch)
char *p, ch;
{
char *save;
for (save = NULL;; ++p) {
if (*p == ch)
save = (char *)p;
if (!*p)
return(save);
}
/* NOTREACHED */
}
#endif /* DYNAMIC */

View File

@ -1,115 +0,0 @@
/* $NetBSD: common.h,v 1.15 2008/04/28 20:22:54 martin Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Paul Kranenburg.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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 <string.h>
#ifdef DYNAMIC
#include <sys/syscall.h>
#include <a.out.h>
#ifndef N_GETMAGIC
#define N_GETMAGIC(x) ((x).a_magic)
#endif
#ifndef N_BSSADDR
#define N_BSSADDR(x) (N_DATADDR(x)+(x).a_data)
#endif
#include <sys/mman.h>
#ifdef sun
#define MAP_ANON 0
#endif
#include <dlfcn.h>
#include <link.h>
extern struct _dynamic _DYNAMIC;
static void __load_rtld __P((struct _dynamic *));
extern int __syscall __P((int, ...));
int _callmain __P((void));
static char *_strrchr __P((char *, char));
#ifdef DEBUG
static char *_getenv __P((char *));
static int _strncmp __P((char *, char *, int));
#endif
#ifdef sun
#define LDSO "/usr/lib/ld.so"
#endif
#ifdef __NetBSD__
#ifndef LDSO
#define LDSO "/usr/libexec/ld.so"
#endif
#endif
/*
* We need these system calls, but can't use library stubs
*/
#define _exit(v) __syscall(SYS_exit, (v))
#define open(name, f, m) __syscall(SYS_open, (name), (f), (m))
#define close(fd) __syscall(SYS_close, (fd))
#define read(fd, s, n) __syscall(SYS_read, (fd), (s), (n))
#define write(fd, s, n) __syscall(SYS_write, (fd), (s), (n))
#define dup(fd) __syscall(SYS_dup, (fd))
#define dup2(fd, fdnew) __syscall(SYS_dup2, (fd), (fdnew))
#ifdef sun
#define mmap(addr, len, prot, flags, fd, off) \
__syscall(SYS_mmap, (addr), (len), (prot), _MAP_NEW|(flags), (fd), (off))
#else
#define mmap(addr, len, prot, flags, fd, off) \
__syscall(SYS___syscall, (quad_t)SYS_mmap, (addr), (len), (prot), (flags), \
(fd), 0, (off_t)(off))
#endif
#define _FATAL(str) \
write(2, str, sizeof(str) - 1), \
_exit(1);
#endif /* DYNAMIC */
extern int main __P((int, char **, char **));
#ifdef MCRT0
extern void monstartup __P((u_long, u_long));
extern void _mcleanup __P((void));
#endif
char **environ;
int errno;
static char empty[1];
char *__progname = empty;
struct ps_strings;
struct ps_strings *__ps_strings = 0;
#ifndef DYNAMIC
#define _strrchr strrchr
#endif
extern unsigned char etext;
extern unsigned char eprol __asm ("eprol");

View File

@ -1,3 +0,0 @@
# $NetBSD: Makefile,v 1.26 1999/03/19 22:54:40 thorpej Exp $
.include "${.CURDIR}/../common_aout/Makefile.inc"

View File

@ -1,114 +0,0 @@
/* $NetBSD: crt0.c,v 1.35 2008/06/21 00:52:52 gmcgarry Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum and Paul Kranenburg.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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 "common.h"
extern void start __P((void)) __asm("start");
void __start __P((int, char *[], char *[]));
__asm("
.text
.align 2
.globl start
start:
movl %ebx,___ps_strings
movl (%esp),%eax
leal 8(%esp,%eax,4),%ecx
leal 4(%esp),%edx
pushl %ecx
pushl %edx
pushl %eax
call ___start
");
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: crt0.c,v 1.35 2008/06/21 00:52:52 gmcgarry Exp $");
#endif /* LIBC_SCCS and not lint */
void
__start(argc, argv, envp)
int argc;
char *argv[];
char *envp[];
{
char *ap;
environ = envp;
if ((ap = argv[0]))
if ((__progname = _strrchr(ap, '/')) == NULL)
__progname = ap;
else
++__progname;
#ifdef DYNAMIC
/* ld(1) convention: if DYNAMIC = 0 then statically linked */
if (&_DYNAMIC)
__load_rtld(&_DYNAMIC);
#endif /* DYNAMIC */
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&eprol, (u_long)&etext);
#endif /* MCRT0 */
__asm("__callmain:"); /* Defined for the benefit of debuggers */
exit(main(argc, argv, envp));
}
#ifdef DYNAMIC
__asm("
.text
.align 2
___syscall:
popl %ecx
popl %eax
pushl %ecx
int $0x80
jc 1f
jmp %ecx
1:
movl $-1,%eax
jmp %ecx
");
#endif /* DYNAMIC */
#include "common.c"
#ifdef MCRT0
__asm("
.text
.align 2
eprol:
");
#endif /* MCRT0 */

View File

@ -1,3 +0,0 @@
# $NetBSD: Makefile,v 1.18 1999/03/19 22:54:40 thorpej Exp $
.include "${.CURDIR}/../common_aout/Makefile.inc"

View File

@ -1,114 +0,0 @@
/* $NetBSD: crt0.c,v 1.24 2008/06/21 00:52:52 gmcgarry Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum and Paul Kranenburg.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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 "common.h"
extern void start __P((void)) __asm("start");
void __start __P((int, char *[], char *[]));
__asm("
.text
.align 2
.globl start
start:
movel a2,___ps_strings
movel sp@,d0
lea sp@(8,d0:l:4),a0
lea sp@(4),a1
movel a0,sp@-
movel a1,sp@-
movel d0,sp@-
jsr ___start
");
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: crt0.c,v 1.24 2008/06/21 00:52:52 gmcgarry Exp $");
#endif /* LIBC_SCCS and not lint */
void
__start(argc, argv, envp)
int argc;
char *argv[];
char *envp[];
{
char *ap;
environ = envp;
if (ap = argv[0])
if ((__progname = _strrchr(ap, '/')) == NULL)
__progname = ap;
else
++__progname;
#ifdef DYNAMIC
/* ld(1) convention: if DYNAMIC = 0 then statically linked */
if (&_DYNAMIC)
__load_rtld(&_DYNAMIC);
#endif /* DYNAMIC */
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&eprol, (u_long)&etext);
#endif /* MCRT0 */
__asm("__callmain:"); /* Defined for the benefit of debuggers */
exit(main(argc, argv, envp));
}
#ifdef DYNAMIC
__asm("
.text
.align 2
___syscall:
movel a7@+,a0
movel a7@,d0
movel a0,a7@
trap #0
bcs 1f
jmp a0@
1:
moveq #-1,d0
jmp a0@
");
#endif /* DYNAMIC */
#include "common.c"
#ifdef MCRT0
__asm("
.text
.align 2
eprol:
");
#endif /* MCRT0 */

View File

@ -1,3 +0,0 @@
# $NetBSD: Makefile,v 1.1 1999/10/07 11:56:28 msaitoh Exp $
.include "${.CURDIR}/../common_aout/Makefile.inc"

View File

@ -1,114 +0,0 @@
/* $NetBSD: crt0.c,v 1.3 2008/06/21 00:52:52 gmcgarry Exp $ */
/*
* Copyright (c) 1996 Charles M. Hannum. All rights reserved.
* Copyright (c) 1993 Paul Kranenburg
* 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 Paul Kranenburg.
* 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.
*/
#undef DYNAMIC
#include <stdlib.h>
#include "common.h"
extern void start __P((void)) __asm("start");
void __start __P((int, char *[], char *[]));
__asm("
.text
.align 2
.globl start
start:
bra ___start
nop
");
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: crt0.c,v 1.3 2008/06/21 00:52:52 gmcgarry Exp $");
#endif /* LIBC_SCCS and not lint */
void
__start(argc, argv, envp)
int argc;
char *argv[];
char *envp[];
{
char *ap;
environ = envp;
if ((ap = argv[0]))
if ((__progname = _strrchr(ap, '/')) == NULL)
__progname = ap;
else
++__progname;
#ifdef DYNAMIC
/* ld(1) convention: if DYNAMIC = 0 then statically linked */
if (&_DYNAMIC)
__load_rtld(&_DYNAMIC);
#endif /* DYNAMIC */
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&eprol, (u_long)&etext);
#endif /* MCRT0 */
__asm("__callmain:"); /* Defined for the benefit of debuggers */
exit(main(argc, argv, envp));
}
#ifdef DYNAMIC
__asm("
.text
.align 2
___syscall:
sts pr, r1
mov r4, r0
mov r1, r0
trapa #0x80
bf 1f
jmp @r1
nop
1:
mov #0xff,r0
jmp @r1
nop
");
#endif /* DYNAMIC */
#include "common.c"
#ifdef MCRT0
__asm("
.text
.align 2
eprol:
");
#endif /* MCRT0 */

View File

@ -1,3 +0,0 @@
# $NetBSD: Makefile,v 1.19 1999/03/19 22:54:40 thorpej Exp $
.include "${.CURDIR}/../common_aout/Makefile.inc"

View File

@ -1,221 +0,0 @@
/* $NetBSD: crt0.c,v 1.29 2008/04/28 20:22:55 martin Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Paul Kranenburg.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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 "common.h"
extern void start __P((void)) __asm ("start");
#if defined(sun) && defined(sparc)
static void __call __P((void));
#endif
#ifdef __NetBSD__
#undef mmap
#define mmap(addr, len, prot, flags, fd, off) \
__syscall2((quad_t)SYS_mmap, (addr), (len), (prot), (flags), \
(fd), 0, (off_t)(off))
extern int __syscall2 __P((quad_t, ...));
#endif
__asm("
.text
.align 4
.global start
start:
mov 0, %fp
ld [%sp + 64], %l0 ! get argc
add %sp, 68, %l1 ! get argv
sll %l0, 2, %l2 !
add %l2, 4, %l2 ! envp = argv + (argc << 2) + 4
add %l1, %l2, %l2 !
sethi %hi(_environ), %l3
st %l2, [%l3+%lo(_environ)] ! *environ = l2
");
/*
* We get a pointer to PSSTRINGS in %g1.
*/
__asm("
cmp %g1, 0
be 1f
sethi %hi(___ps_strings), %l3
st %g1, [%l3+%lo(___ps_strings)]
1:
");
/*
* Finish diddling with stack.
*/
__asm("
andn %sp, 7, %sp ! align
sub %sp, 24, %sp ! expand to standard stack frame size
");
/*
* Set __progname:
* if (argv[0])
* if ((__progname = _strrchr(argv[0], '/')) == NULL)
* __progname = argv[0];
* else
* ++__progname;
*/
__asm("
ld [%l1], %o0
cmp %o0, 0
mov %o0, %l6
be 1f
sethi %hi(___progname), %l7
");
#ifdef DYNAMIC
__asm("call __strrchr");
#else
__asm("call _strrchr");
#endif
__asm("
mov 47, %o1
cmp %o0, 0
be,a 1f
st %l6, [%l7+%lo(___progname)]
add %o0, 1, %o0
st %o0, [%l7+%lo(___progname)]
1:
");
#ifdef DYNAMIC
/* Resolve symbols in dynamic libraries */
__asm("
sethi %hi(__DYNAMIC), %o0
orcc %o0, %lo(__DYNAMIC), %o0
be 1f
nop
call ___load_rtld
nop
1:
");
#endif
/* From here, all symbols should have been resolved, so we can use libc */
#ifdef MCRT0
/*
* atexit(_mcleanup);
* monstartup((u_long)&eprol, (u_long)&etext);
*/
__asm("
sethi %hi(__mcleanup), %o0
call _atexit
or %o0, %lo(__mcleanup), %o0
sethi %hi(_eprol), %o0
or %o0, %lo(_eprol), %o0
sethi %hi(_etext), %o1
call _monstartup
or %o1, %lo(_etext), %o1
");
#endif
#ifdef sun
/*
* SunOS compatibility
*/
__asm("
call start_float
nop
");
#endif
/*
* Move `argc', `argv', and `envp' from locals to parameters for `main'.
*/
__asm("
mov %l0,%o0
mov %l1,%o1
__callmain:
call _main
mov %l2,%o2
call _exit
nop
");
#ifdef DYNAMIC
/*
* System call entry
*/
__asm("
.set SYSCALL_G2RFLAG, 0x400
.set SYS___syscall, 198
___syscall2:
sethi %hi(SYS___syscall), %g1
ba 1f
or %g1, %lo(SYS___syscall), %g1
___syscall:
clr %g1
1:
or %g1, SYSCALL_G2RFLAG, %g1
add %o7, 8, %g2
ta %g0
mov -0x1, %o0
jmp %o7 + 0x8
mov -0x1, %o1
");
#endif
#ifdef sun
static
__call()
{
/*
* adjust the C generated pointer to the crt struct to the
* likings of ld.so, which is an offset relative to its %fp
*/
__asm("
mov %i0, %o0
mov %i1, %o1
call %i2
sub %o1, %sp, %o1
");
/*NOTREACHED, control is transferred directly to our caller */
}
#endif
#include "common.c"
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: crt0.c,v 1.29 2008/04/28 20:22:55 martin Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef MCRT0
__asm ("
.text
_eprol:
");
#endif

View File

@ -1,3 +0,0 @@
# $NetBSD: Makefile,v 1.11 1999/03/19 22:54:41 thorpej Exp $
.include "${.CURDIR}/../common_aout/Makefile.inc"

View File

@ -1,115 +0,0 @@
/* $NetBSD: crt0.c,v 1.17 2008/06/21 00:52:52 gmcgarry Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Paul Kranenburg.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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 "common.h"
extern void start __P((void)) __asm("start");
struct kframe {
int kargc;
char *kargv[1]; /* size depends on kargc */
char kargstr[1]; /* size varies */
char kenvstr[1]; /* size varies */
};
__asm(" .text");
__asm(" .align 2");
__asm(" .globl start");
__asm(" .type start,@function");
__asm(" start:");
__asm(" .word 0x0101"); /* two nops just in case */
__asm(" pushl %sp"); /* no registers to save */
__asm(" calls $1,___start"); /* do the real start */
__asm(" halt");
void
__start(kfp)
struct kframe *kfp;
{
/*
* ALL REGISTER VARIABLES!!!
*/
char **argv, *ap;
argv = &kfp->kargv[0];
environ = argv + kfp->kargc + 1;
if (ap = argv[0])
if ((__progname = _strrchr(ap, '/')) == NULL)
__progname = ap;
else
++__progname;
#ifdef DYNAMIC
/* ld(1) convention: if DYNAMIC = 0 then statically linked */
if (&_DYNAMIC)
__load_rtld(&_DYNAMIC);
#endif /* DYNAMIC */
__asm("eprol:");
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&eprol, (u_long)&etext);
#endif /* MCRT0 */
__asm ("__callmain:"); /* Defined for the benefit of debuggers */
exit(main(kfp->kargc, argv, environ));
}
#ifdef DYNAMIC
__asm(" ___syscall:");
__asm(" .word 0"); /* no registers to save */
__asm(" addl2 $4,%ap"); /* n-1 args to syscall */
__asm(" movl (%ap),r0"); /* get syscall number */
__asm(" subl3 $1,-4(%ap),(%ap)"); /* n-1 args to syscall */
__asm(" chmk %r0"); /* do system call */
__asm(" jcc 1f"); /* check error */
__asm(" mnegl $1,%r0");
__asm(" ret");
__asm(" 1: movpsl -(%sp)"); /* flush the icache */
__asm(" pushab 2f"); /* by issuing an REI */
__asm(" rei");
__asm(" 2: ret");
#endif /* DYNAMIC */
#include "common.c"
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: crt0.c,v 1.17 2008/06/21 00:52:52 gmcgarry Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef MCRT0
__asm (" .text");
__asm ("_eprol:");
#endif