GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/csu/crt0.c Lines: 1 5 20.0 %
Date: 2017-11-13 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: crt0.c,v 1.10 2017/01/21 04:14:19 guenther Exp $	*/
2
3
/*
4
 * Copyright (c) 1995 Christopher G. Demetriou
5
 * All rights reserved.
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
9
 * are met:
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer.
12
 * 2. Redistributions in binary form must reproduce the above copyright
13
 *    notice, this list of conditions and the following disclaimer in the
14
 *    documentation and/or other materials provided with the distribution.
15
 * 3. All advertising materials mentioning features or use of this software
16
 *    must display the following acknowledgement:
17
 *      This product includes software developed by Christopher G. Demetriou
18
 *	for the NetBSD Project.
19
 * 4. The name of the author may not be used to endorse or promote products
20
 *    derived from this software without specific prior written permission
21
 *
22
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
 */
33
34
#include <stdlib.h>
35
#include <limits.h>
36
37
#include "md_init.h"
38
#ifdef MD_RCRT0_START
39
#include "boot.h"
40
#endif
41
#include "extern.h"
42
43
/* some defaults */
44
#ifndef	MD_START_ARGS
45
#define	MD_START_ARGS	\
46
	int argc, char **argv, char **envp, void (*cleanup)(void)
47
#endif
48
static void		___start(MD_START_ARGS) __used;
49
#ifndef	MD_EPROL_LABEL
50
#define	MD_EPROL_LABEL	__asm("  .text\n_eprol:")
51
#endif
52
53
char	***_csu_finish(char **_argv, char **_envp, void (*_cleanup)(void));
54
55
#ifdef MCRT0
56
#include <sys/gmon.h>
57
extern unsigned char _etext, _eprol;
58
#endif /* MCRT0 */
59
60
#ifdef RCRT0
61
#ifdef MD_RCRT0_START
62
MD_RCRT0_START;
63
#endif
64
#else
65
#ifdef MD_CRT0_START
66
MD_CRT0_START;
67
#endif
68
#endif
69
70
void
71
___start(MD_START_ARGS)
72
{
73
	char ***environp;
74
#ifdef MD_START_SETUP
75
	MD_START_SETUP
76
#endif
77
78
2464
	environp = _csu_finish(argv, envp, cleanup);
79
80
#ifdef MCRT0
81
	atexit(_mcleanup);
82
	_monstartup((u_long)&_eprol, (u_long)&_etext);
83
#endif
84
85
	__init();
86
87
	exit(main(argc, argv, *environp));
88
}
89
90
#ifdef MCRT0
91
MD_EPROL_LABEL;
92
#endif