1 |
207 |
jeremybenn |
/*
|
2 |
|
|
* RTEMS Fake crt0
|
3 |
|
|
*
|
4 |
|
|
* Each RTEMS BSP provides its own crt0 and linker script. Unfortunately
|
5 |
|
|
* this means that crt0 and the linker script are not available as
|
6 |
|
|
* each tool is configured. Without a crt0 and linker script, some
|
7 |
|
|
* targets do not successfully link "conftest.c" during the configuration
|
8 |
|
|
* process. So this fake crt0.c provides all the symbols required to
|
9 |
|
|
* successfully link a program. The resulting program will not run
|
10 |
|
|
* but this is enough to satisfy the autoconf macro AC_PROG_CC.
|
11 |
|
|
*/
|
12 |
|
|
|
13 |
|
|
#include <reent.h>
|
14 |
|
|
|
15 |
|
|
#include <signal.h> // sigset_t
|
16 |
|
|
#include <time.h> // struct timespec
|
17 |
|
|
|
18 |
|
|
void rtems_provides_crt0( void ) {} /* dummy symbol so file always has one */
|
19 |
|
|
|
20 |
|
|
#define RTEMS_STUB(ret, func) \
|
21 |
|
|
ret rtems_stub_##func {}; \
|
22 |
|
|
ret func
|
23 |
|
|
|
24 |
|
|
/* RTEMS provides some of its own routines including a Malloc family */
|
25 |
|
|
RTEMS_STUB(void *,malloc(size_t s)) { return 0; }
|
26 |
|
|
RTEMS_STUB(void *,realloc(void* p, size_t s)) { return 0; }
|
27 |
|
|
RTEMS_STUB(void, free(void)) { ; }
|
28 |
|
|
RTEMS_STUB(_PTR, calloc(struct _reent *r, size_t s1, size_t s2)) {}
|
29 |
|
|
|
30 |
|
|
#if defined(__GNUC__)
|
31 |
|
|
/*
|
32 |
|
|
* stubs for libstdc++ rtems-threads support functions from gcc/gthr-rtems.h
|
33 |
|
|
*/
|
34 |
|
|
int rtems_gxx_once() { return -1; }
|
35 |
|
|
int rtems_gxx_key_create() { return -1; }
|
36 |
|
|
int rtems_gxx_key_delete() { return -1; }
|
37 |
|
|
void *rtems_gxx_getspecific() { return 0; }
|
38 |
|
|
int rtems_gxx_setspecific() { return -1; }
|
39 |
|
|
|
40 |
|
|
void rtems_gxx_mutex_init() { }
|
41 |
|
|
int rtems_gxx_mutex_lock() { return -1; }
|
42 |
|
|
int rtems_gxx_mutex_trylock() { return -1; }
|
43 |
|
|
int rtems_gxx_mutex_unlock() { return -1; }
|
44 |
|
|
|
45 |
|
|
void rtems_gxx_recursive_mutex_init() { }
|
46 |
|
|
int rtems_gxx_recursive_mutex_lock() { return -1; }
|
47 |
|
|
int rtems_gxx_recursive_mutex_trylock() { return -1; }
|
48 |
|
|
int rtems_gxx_recursive_mutex_unlock() { return -1; }
|
49 |
|
|
#endif
|
50 |
|
|
|
51 |
|
|
/* stubs for functions RTEMS provides */
|
52 |
|
|
RTEMS_STUB(int, close (int fd)) { return -1; }
|
53 |
|
|
RTEMS_STUB(int, dup2(int oldfd, int newfd)) { return -1; }
|
54 |
|
|
RTEMS_STUB(int, fcntl( int fd, int cmd, ... /* arg */ )) { return -1; }
|
55 |
|
|
RTEMS_STUB(pid_t, fork(void)) { return -1; }
|
56 |
|
|
RTEMS_STUB(int, fstat(int fd, struct stat *buf)) { return -1; }
|
57 |
|
|
RTEMS_STUB(int, getdents(int fd, void *dp, int count)) { return -1; }
|
58 |
|
|
RTEMS_STUB(char *, getlogin(void)) { return 0; }
|
59 |
|
|
RTEMS_STUB(struct passwd *, getpwnam(const char *name)) { return 0; }
|
60 |
|
|
RTEMS_STUB(struct passwd *, getpwuid(uid_t uid)) { return 0; }
|
61 |
|
|
RTEMS_STUB(uid_t, getuid(void)) { return 0; }
|
62 |
|
|
RTEMS_STUB(int, nanosleep(const struct timespec *req, struct timespec *rem)) { return -1; }
|
63 |
|
|
RTEMS_STUB(_off_t, lseek(int fd, _off_t offset, int whence)) { return -1; }
|
64 |
|
|
RTEMS_STUB(int, lstat(const char *path, struct stat *buf)) { return -1; }
|
65 |
|
|
RTEMS_STUB(int, open(const char *pathname, int flags, int mode)) { return -1; }
|
66 |
|
|
RTEMS_STUB(int, pipe(int pipefd[2])) { return -1; }
|
67 |
|
|
RTEMS_STUB(_ssize_t, read(int fd, void *buf, size_t count)) { return -1; }
|
68 |
|
|
RTEMS_STUB(int, sigfillset(sigset_t *set)) { return -1; }
|
69 |
|
|
RTEMS_STUB(int, sigprocmask(int how, const sigset_t *set, sigset_t *oldset)) { return -1; }
|
70 |
|
|
RTEMS_STUB(int, stat(const char *path, struct stat *buf)) { return -1; }
|
71 |
|
|
RTEMS_STUB(int, unlink(const char *pathname)) { return -1; }
|
72 |
|
|
RTEMS_STUB(pid_t, vfork(void)) { return -1; }
|
73 |
|
|
#if !defined(_NO_POPEN) && !defined(_NO_WORDEXP)
|
74 |
|
|
/* pulled in by libc/sys/posix/popen.c and libc/sys/posix/word*.c */
|
75 |
|
|
RTEMS_STUB(int, waitpid (pid_t pid, int *status, int options)) { return -1; }
|
76 |
|
|
#endif
|
77 |
|
|
RTEMS_STUB(_ssize_t, write (int fd, const void *buf, size_t nbytes)) { return -1; }
|
78 |
|
|
|
79 |
|
|
/* stubs for functions from reent.h */
|
80 |
|
|
RTEMS_STUB(int, _close_r (struct _reent *r, int fd)) { return -1; }
|
81 |
|
|
#if defined(_NO_EXECVE)
|
82 |
|
|
RTEMS_STUB(int, _execve_r (struct _reent *r, char *, char **, char **)) { return -1; }
|
83 |
|
|
#endif
|
84 |
|
|
RTEMS_STUB(int, _fcntl_r (struct _reent *ptr, int fd, int cmd, int arg )) { return -1; }
|
85 |
|
|
#if !(defined (REENTRANT_SYSCALLS_PROVIDED) || defined (NO_EXEC))
|
86 |
|
|
#ifndef NO_FORK
|
87 |
|
|
/* cf. newlib/libc/reent/execr.c */
|
88 |
|
|
RTEMS_STUB(int, _fork_r (struct _reent *r)) { return -1; }
|
89 |
|
|
#endif
|
90 |
|
|
#endif
|
91 |
|
|
RTEMS_STUB(int, _fstat_r (struct _reent *r, int fd, struct stat *buf)) { return -1; }
|
92 |
|
|
RTEMS_STUB(int, _getpid_r (struct _reent *r)) { return -1; }
|
93 |
|
|
RTEMS_STUB(int, _gettimeofday_r(struct _reent *r, struct timeval *tp, void *tzp)) { return 0; }
|
94 |
|
|
RTEMS_STUB(int, _isatty_r (struct _reent *r, int fd)) { return isatty( fd ); }
|
95 |
|
|
RTEMS_STUB(int, _kill_r (struct _reent *r, int pid, int sig )) { return -1; }
|
96 |
|
|
#if !defined(REENTRANT_SYSCALLS_PROVIDED)
|
97 |
|
|
/* cf. newlib/libc/reent/linkr.c */
|
98 |
|
|
RTEMS_STUB(int, _link_r (struct _reent *, const char *, const char *)) { return -1; }
|
99 |
|
|
#endif
|
100 |
|
|
RTEMS_STUB(_off_t, _lseek_r ( struct _reent *ptr, int fd, _off_t offset, int whence )) { return -1; }
|
101 |
|
|
RTEMS_STUB(int, _open_r (struct _reent *r, const char *buf, int flags, int mode)) { return -1; }
|
102 |
|
|
RTEMS_STUB(_ssize_t, _read_r (struct _reent *r, int fd, void *buf, size_t nbytes)) { return -1; }
|
103 |
|
|
RTEMS_STUB(int, _rename_r (struct _reent *r, const char *a, const char *b)){ return -1; }
|
104 |
|
|
#if !(defined (REENTRANT_SYSCALLS_PROVIDED) || defined (MALLOC_PROVIDED))
|
105 |
|
|
/* cf. newlib/libc/reent/sbrkr.c */
|
106 |
|
|
RTEMS_STUB(void *,_sbrk_r (struct _reent *r, ptrdiff_t)) { return -1; }
|
107 |
|
|
#endif
|
108 |
|
|
RTEMS_STUB(int, _stat_r (struct _reent *r, const char *path, struct stat *buf)) { return -1; }
|
109 |
|
|
RTEMS_STUB(_CLOCK_T_, _times_r (struct _reent *r, struct tms *ptms)) { return -1; }
|
110 |
|
|
RTEMS_STUB(int, _unlink_r (struct _reent *r, const char *path)) { return -1; }
|
111 |
|
|
#if !(defined (REENTRANT_SYSCALLS_PROVIDED) || defined (NO_EXEC))
|
112 |
|
|
/* cf. newlib/libc/reent/execr.c */
|
113 |
|
|
RTEMS_STUB(int, _wait_r (struct _reent *r, int *)) { return -1; }
|
114 |
|
|
#endif
|
115 |
|
|
RTEMS_STUB(_ssize_t, _write_r (struct _reent *r, int fd, const void *buf, size_t nbytes)) { return -1; }
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
RTEMS_STUB(int, _execve(const char *path, char * const *argv, char * const *envp)) { return -1; }
|
119 |
|
|
RTEMS_STUB(void, _exit(int status)) { while(1); }
|
120 |
|
|
|
121 |
|
|
/* Pulled in by newlib/libc/posix/glob.c */
|
122 |
|
|
#ifndef _NO_GLOB
|
123 |
|
|
#ifndef __NETBSD_SYSCALLS
|
124 |
|
|
RTEMS_STUB(int, issetugid (void)) { return 0; }
|
125 |
|
|
#endif
|
126 |
|
|
#endif
|
127 |
|
|
|
128 |
|
|
/* stdlib.h */
|
129 |
|
|
RTEMS_STUB(_PTR, _realloc_r(struct _reent *r, _PTR p, size_t s)) {}
|
130 |
|
|
RTEMS_STUB(_PTR, _calloc_r(struct _reent *r, size_t s1, size_t s2)) {}
|
131 |
|
|
RTEMS_STUB(_PTR, _malloc_r(struct _reent *r, size_t s)) {}
|
132 |
|
|
RTEMS_STUB(_VOID, _free_r(struct _reent *r, _PTR p)) {}
|
133 |
|
|
|
134 |
|
|
/* stubs for functions required by libc/stdlib */
|
135 |
|
|
RTEMS_STUB(void, __assert_func(const char *file, int line, const char *failedexpr)) {}
|
136 |
|
|
|
137 |
|
|
/* The PowerPC expects certain symbols to be defined in the linker script. */
|
138 |
|
|
|
139 |
|
|
#if defined(__PPC__)
|
140 |
|
|
int __SDATA_START__; int __SDATA2_START__;
|
141 |
|
|
int __GOT_START__; int __GOT_END__;
|
142 |
|
|
int __GOT2_START__; int __GOT2_END__;
|
143 |
|
|
int __SBSS_END__; int __SBSS2_END__;
|
144 |
|
|
int __FIXUP_START__; int __FIXUP_END__;
|
145 |
|
|
int __EXCEPT_START__; int __EXCEPT_END__;
|
146 |
|
|
int __init; int __fini;
|
147 |
|
|
int __CTOR_LIST__; int __CTOR_END__;
|
148 |
|
|
int __DTOR_LIST__; int __DTOR_END__;
|
149 |
|
|
#endif
|
150 |
|
|
|
151 |
|
|
/* The SH expects certain symbols to be defined in the linker script. */
|
152 |
|
|
|
153 |
|
|
#if defined(__sh__)
|
154 |
|
|
int __EH_FRAME_BEGIN__;
|
155 |
|
|
#endif
|
156 |
|
|
|
157 |
|
|
/* The hppa expects this to be defined in the real crt0.s.
|
158 |
|
|
* Also for some reason, the hppa1.1 does not find atexit()
|
159 |
|
|
* during the AC_PROG_CC tests.
|
160 |
|
|
*/
|
161 |
|
|
|
162 |
|
|
#if defined(__hppa__)
|
163 |
|
|
/*
|
164 |
|
|
asm ( ".subspa \$GLOBAL\$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=40");
|
165 |
|
|
asm ( ".export \$global\$" );
|
166 |
|
|
asm ( "\$global\$:");
|
167 |
|
|
*/
|
168 |
|
|
|
169 |
|
|
asm (".text");
|
170 |
|
|
asm (".global");
|
171 |
|
|
asm (".EXPORT $$dyncall,ENTRY");
|
172 |
|
|
asm ("$$dyncall:");
|
173 |
|
|
int atexit(void (*function)(void)) { return 0; }
|
174 |
|
|
#endif
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
/*
|
178 |
|
|
* The AMD a29k generates code expecting the following.
|
179 |
|
|
*/
|
180 |
|
|
|
181 |
|
|
#if defined(_AM29000) || defined(_AM29K)
|
182 |
|
|
asm (".global V_SPILL, V_FILL" );
|
183 |
|
|
asm (".global V_EPI_OS, V_BSD_OS" );
|
184 |
|
|
|
185 |
|
|
asm (".equ V_SPILL, 64" );
|
186 |
|
|
asm (".equ V_FILL, 65" );
|
187 |
|
|
|
188 |
|
|
asm (".equ V_BSD_OS, 66" );
|
189 |
|
|
asm (".equ V_EPI_OS, 69" );
|
190 |
|
|
#endif
|
191 |
|
|
|
192 |
|
|
#if defined(__AVR__)
|
193 |
|
|
/*
|
194 |
|
|
* Initial stack pointer address "__stack"
|
195 |
|
|
* hard coded into GCC instead of providing it through ldscripts
|
196 |
|
|
*/
|
197 |
|
|
const char* __stack ;
|
198 |
|
|
#endif
|