summaryrefslogtreecommitdiff
path: root/src/libc.c
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-02-15 00:59:08 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-02-16 18:22:14 +0200
commit33a9a63787154facfdaddaf719e727947c159800 (patch)
tree46f92364199658fc3d439fc056996c9b9afc237c /src/libc.c
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.
Diffstat (limited to 'src/libc.c')
-rw-r--r--src/libc.c64
1 files changed, 64 insertions, 0 deletions
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 <unistd.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+// 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();
+}