|
|
@@ -318,3 +318,91 @@ static void memory_clear(uint32_t *dest, uint32_t *dest_end) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// syscall functions need to be in the same C file as the entry point "ResetVector" |
|
|
|
// otherwise the linker will discard them in some cases. |
|
|
|
|
|
|
|
#include <errno.h> |
|
|
|
|
|
|
|
// from the linker script |
|
|
|
extern unsigned long _heap_start; |
|
|
|
extern unsigned long _heap_end; |
|
|
|
|
|
|
|
char *__brkval = (char *)&_heap_start; |
|
|
|
|
|
|
|
void * _sbrk(int incr) |
|
|
|
{ |
|
|
|
char *prev = __brkval; |
|
|
|
if (incr != 0) { |
|
|
|
if (prev + incr > (char *)&_heap_end) { |
|
|
|
errno = ENOMEM; |
|
|
|
return (void *)-1; |
|
|
|
} |
|
|
|
__brkval = prev + incr; |
|
|
|
} |
|
|
|
return prev; |
|
|
|
} |
|
|
|
|
|
|
|
__attribute__((weak)) |
|
|
|
int _read(int file, char *ptr, int len) |
|
|
|
{ |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
__attribute__((weak)) |
|
|
|
int _close(int fd) |
|
|
|
{ |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
#include <sys/stat.h> |
|
|
|
|
|
|
|
__attribute__((weak)) |
|
|
|
int _fstat(int fd, struct stat *st) |
|
|
|
{ |
|
|
|
st->st_mode = S_IFCHR; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
__attribute__((weak)) |
|
|
|
int _isatty(int fd) |
|
|
|
{ |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
__attribute__((weak)) |
|
|
|
int _lseek(int fd, long long offset, int whence) |
|
|
|
{ |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
__attribute__((weak)) |
|
|
|
void _exit(int status) |
|
|
|
{ |
|
|
|
while (1); |
|
|
|
} |
|
|
|
|
|
|
|
__attribute__((weak)) |
|
|
|
void __cxa_pure_virtual() |
|
|
|
{ |
|
|
|
while (1); |
|
|
|
} |
|
|
|
|
|
|
|
__attribute__((weak)) |
|
|
|
int __cxa_guard_acquire (char *g) |
|
|
|
{ |
|
|
|
return !(*g); |
|
|
|
} |
|
|
|
|
|
|
|
__attribute__((weak)) |
|
|
|
void __cxa_guard_release(char *g) |
|
|
|
{ |
|
|
|
*g = 1; |
|
|
|
} |
|
|
|
|
|
|
|
__attribute__((weak)) |
|
|
|
void abort(void) |
|
|
|
{ |
|
|
|
while (1) ; |
|
|
|
} |
|
|
|
|