From 33a9a63787154facfdaddaf719e727947c159800 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Thu, 15 Feb 2018 00:59:08 +0200 Subject: Initial commit Stuff in src/linker will get rewritten from scratch eventually, it's all horrible. But for now focus is getting on shit work. --- src/libc.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/libc.c (limited to 'src/libc.c') diff --git a/src/libc.c b/src/libc.c new file mode 100644 index 0000000..f83395b --- /dev/null +++ b/src/libc.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +// Stuff that doesn't exist in glibc + +void +__assert2(const char* file, int line, const char* function, const char* failed_expression) +{ + fprintf(stderr, "%s:%d: %s: assertion \"%s\" failed", file, line, function, failed_expression); + abort(); +} + +pid_t +gettid(void) +{ + return syscall(SYS_gettid); +} + +#include "libc-sha1.h" + +// Stuff needed for runtime compatibility, but not neccessary for linking +// Also stuff that exists in glibc, but needs to be wrapped for runtime compatibility + +const char *bionic__ctype_, *bionic__tolower_tab_, *bionic__toupper_tab_; +char bionic___sF[0x54]; +int bionic___errno; + +int +bionic_stat(const char *restrict path, struct stat *restrict buf) +{ + return stat(path, buf); +} + +int +bionic_lstat(const char *restrict path, struct stat *restrict buf) +{ + return lstat(path, buf); +} + +int +bionic_fstat(int fd, struct stat *buf) +{ + return fstat(fd, buf); +} + +int +bionic___isfinitef(float f) +{ + return isfinite(f); +} + +uintptr_t bionic___stack_chk_guard = 4; + +__attribute__((noreturn)) +void bionic___stack_chk_fail(void) +{ + abort(); +} -- cgit v1.2.3