Created
July 20, 2021 20:43
-
-
Save klange/f825c6ef4c0ff37f14329d1f215d5434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1 "libc/main.c" | |
# 1 "<built-in>" | |
# 1 "<command-line>" | |
# 1 "libc/main.c" | |
# 1 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stdint.h" 1 3 4 | |
# 11 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stdint.h" 3 4 | |
# 1 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stdint-gcc.h" 1 3 4 | |
# 34 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stdint-gcc.h" 3 4 | |
# 34 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stdint-gcc.h" 3 4 | |
typedef signed char int8_t; | |
typedef short int int16_t; | |
typedef int int32_t; | |
typedef long int int64_t; | |
typedef unsigned char uint8_t; | |
typedef short unsigned int uint16_t; | |
typedef unsigned int uint32_t; | |
typedef long unsigned int uint64_t; | |
typedef signed char int_least8_t; | |
typedef short int int_least16_t; | |
typedef int int_least32_t; | |
typedef long int int_least64_t; | |
typedef unsigned char uint_least8_t; | |
typedef short unsigned int uint_least16_t; | |
typedef unsigned int uint_least32_t; | |
typedef long unsigned int uint_least64_t; | |
typedef signed char int_fast8_t; | |
typedef long int int_fast16_t; | |
typedef long int int_fast32_t; | |
typedef long int int_fast64_t; | |
typedef unsigned char uint_fast8_t; | |
typedef long unsigned int uint_fast16_t; | |
typedef long unsigned int uint_fast32_t; | |
typedef long unsigned int uint_fast64_t; | |
typedef long int intptr_t; | |
typedef long unsigned int uintptr_t; | |
typedef long int intmax_t; | |
typedef long unsigned int uintmax_t; | |
# 12 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stdint.h" 2 3 4 | |
# 2 "libc/main.c" 2 | |
# 1 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stddef.h" 1 3 4 | |
# 143 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stddef.h" 3 4 | |
typedef long int ptrdiff_t; | |
# 209 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stddef.h" 3 4 | |
typedef long unsigned int size_t; | |
# 321 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stddef.h" 3 4 | |
typedef int wchar_t; | |
# 415 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stddef.h" 3 4 | |
typedef struct { | |
long long __max_align_ll __attribute__((__aligned__(__alignof__(long long)))); | |
long double __max_align_ld __attribute__((__aligned__(__alignof__(long double)))); | |
# 426 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stddef.h" 3 4 | |
} max_align_t; | |
# 3 "libc/main.c" 2 | |
# 1 "/home/klange/Projects/workspace/misaka/base/usr/include/stdlib.h" 1 3 4 | |
# 1 "/home/klange/Projects/workspace/misaka/base/usr/include/_cheader.h" 1 3 4 | |
# 4 "/home/klange/Projects/workspace/misaka/base/usr/include/stdlib.h" 2 3 4 | |
# 1 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stddef.h" 1 3 4 | |
# 5 "/home/klange/Projects/workspace/misaka/base/usr/include/stdlib.h" 2 3 4 | |
extern void exit(int status); | |
extern char * getenv(const char *name); | |
extern void *malloc(size_t size); | |
extern void free(void *ptr); | |
extern void *calloc(size_t nmemb, size_t size); | |
extern void *realloc(void *ptr, size_t size); | |
extern void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void*,const void*)); | |
extern int system(const char * command); | |
extern int abs(int j); | |
extern int putenv(char * name); | |
extern int setenv(const char *name, const char *value, int overwrite); | |
extern int unsetenv(const char * str); | |
extern double strtod(const char *nptr, char **endptr); | |
extern float strtof(const char *nptr, char **endptr); | |
extern double atof(const char * nptr); | |
extern int atoi(const char * nptr); | |
extern long atol(const char * nptr); | |
extern long int labs(long int j); | |
extern long int strtol(const char * s, char **endptr, int base); | |
extern long long int strtoll(const char *nptr, char **endptr, int base); | |
extern unsigned long int strtoul(const char *nptr, char **endptr, int base); | |
extern unsigned long long int strtoull(const char *nptr, char **endptr, int base); | |
extern void srand(unsigned int); | |
extern int rand(void); | |
extern int atexit(void (*h)(void)); | |
extern void _handle_atexit(void); | |
extern void abort(void); | |
extern void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, | |
int (*compar)(const void *, const void *)); | |
extern char * mktemp(char *); | |
extern int mkstemp(char *); | |
extern size_t mbstowcs(wchar_t *dest, const char *src, size_t n); | |
extern size_t wcstombs(char * dest, const wchar_t *src, size_t n); | |
typedef struct { int quot; int rem; } div_t; | |
typedef struct { long int quot; long int rem; } ldiv_t; | |
extern div_t div(int numerator, int denominator); | |
extern ldiv_t ldiv(long numerator, long denominator); | |
extern char *realpath(const char *path, char *resolved_path); | |
# 4 "libc/main.c" 2 | |
# 1 "/home/klange/Projects/workspace/misaka/base/usr/include/syscall.h" 1 3 4 | |
# 1 "/home/klange/Projects/workspace/misaka/util/local/lib/gcc/x86_64-pc-toaru/10.3.0/include/stddef.h" 1 3 4 | |
# 6 "/home/klange/Projects/workspace/misaka/base/usr/include/syscall.h" 2 3 4 | |
# 63 "/home/klange/Projects/workspace/misaka/base/usr/include/syscall.h" 3 4 | |
long syscall_exit(int); | |
long syscall_geteuid(); | |
long syscall_open(const char *,int,int); | |
long syscall_read(int,char *,size_t); | |
long syscall_write(int,char *,size_t); | |
long syscall_close(int); | |
long syscall_gettimeofday(void *,void *); | |
long syscall_execve(char *,char **,char **); | |
long syscall_fork(); | |
long syscall_getpid(); | |
long syscall_sbrk(int); | |
long syscall_socket(int,int,int); | |
long syscall_uname(void *); | |
long syscall_openpty(int *,int *,char *,void *,void *); | |
long syscall_seek(int,long,int); | |
long syscall_stat(int,void *); | |
long syscall_setsockopt(int,int,int,const void*,size_t); | |
long syscall_bind(int,const void*,size_t); | |
long syscall_accept(int,void*,size_t*,int); | |
long syscall_listen(int,int); | |
long syscall_connect(int,const void*,size_t); | |
long syscall_dup2(int,int); | |
long syscall_getuid(); | |
long syscall_setuid(unsigned int); | |
long syscall_getsockopt(int,int,int,void*,size_t*); | |
long syscall_reboot(); | |
long syscall_readdir(int,int,void *); | |
long syscall_chdir(char *); | |
long syscall_getcwd(char *,size_t); | |
long syscall_clone(uintptr_t,uintptr_t,void *); | |
long syscall_sethostname(char *); | |
long syscall_gethostname(char *); | |
long syscall_mkdir(char *,unsigned int); | |
long syscall_shm_obtain(char *,size_t *); | |
long syscall_shm_release(char *); | |
long syscall_kill(int,int); | |
long syscall_signal(int,void *); | |
long syscall_recv(int,void*,int); | |
long syscall_send(int,const void*,int); | |
long syscall_gettid(); | |
long syscall_yield(); | |
long syscall_sysfunc(int,char **); | |
long syscall_shutdown(int,int); | |
long syscall_sleepabs(unsigned long,unsigned long); | |
long syscall_sleep(unsigned long,unsigned long); | |
long syscall_ioctl(int,int,void *); | |
long syscall_access(char *,int); | |
long syscall_statf(char *,void *); | |
long syscall_chmod(char *,int); | |
long syscall_umask(int); | |
long syscall_unlink(char *); | |
long syscall_waitpid(int,int *,int); | |
long syscall_pipe(int *); | |
long syscall_mount(char *,char *,char *,unsigned long,void *); | |
long syscall_symlink(const char *,const char *); | |
long syscall_readlink(char *,char *,int); | |
long syscall_lstat(char *,void *); | |
long syscall_fswait(int,int*); | |
long syscall_fswait2(int,int*,int); | |
long syscall_chown(char*,int,int); | |
long syscall_setsid(); | |
long syscall_setpgid(int,int); | |
long syscall_getpgid(int); | |
long syscall_fswait3(int,int*,int,int*); | |
# 6 "libc/main.c" 2 | |
# 1 "/home/klange/Projects/workspace/misaka/base/usr/include/syscall_nums.h" 1 3 4 | |
# 7 "libc/main.c" 2 | |
long syscall_exit( | |
# 8 "libc/main.c" | |
int | |
# 8 "libc/main.c" 3 4 | |
p1) { long __res = 0; __asm__ __volatile__("int $0x7F" : "=a" (__res) : "a" (__res), "b" ((long)(p1))); return __res; } | |
# 8 "libc/main.c" | |
; | |
# 9 "libc/main.c" 3 4 | |
long syscall_sleepabs( | |
# 9 "libc/main.c" | |
unsigned long | |
# 9 "libc/main.c" 3 4 | |
p1, | |
# 9 "libc/main.c" | |
unsigned long | |
# 9 "libc/main.c" 3 4 | |
p2) { long __res = 45; __asm__ __volatile__("int $0x7F" : "=a" (__res) : "a" (__res), "b" ((long)(p1)), "c"((long)(p2))); return __res; } | |
# 9 "libc/main.c" | |
; | |
extern void _init(); | |
extern void _fini(); | |
char ** environ = | |
# 14 "libc/main.c" 3 4 | |
0 | |
# 14 "libc/main.c" | |
; | |
int _environ_size = 0; | |
char * _argv_0 = | |
# 16 "libc/main.c" 3 4 | |
0 | |
# 16 "libc/main.c" | |
; | |
int __libc_debug = 0; | |
char ** __argv = | |
# 19 "libc/main.c" 3 4 | |
0 | |
# 19 "libc/main.c" | |
; | |
extern char ** __get_argv(void) { | |
return __argv; | |
} | |
extern void __stdio_init_buffers(void); | |
extern void __stdio_cleanup(void); | |
void _exit(int val){ | |
_fini(); | |
__stdio_cleanup(); | |
syscall_exit(val); | |
__builtin_unreachable(); | |
} | |
extern void __make_tls(void); | |
static int __libc_init_called = 0; | |
__attribute__((constructor)) | |
static void _libc_init(void) { | |
__libc_init_called = 1; | |
__make_tls(); | |
__stdio_init_buffers(); | |
unsigned int x = 0; | |
unsigned int nulls = 0; | |
for (x = 0; 1; ++x) { | |
if (!__get_argv()[x]) { | |
++nulls; | |
if (nulls == 2) { | |
break; | |
} | |
continue; | |
} | |
if (nulls == 1) { | |
environ = &__get_argv()[x]; | |
break; | |
} | |
} | |
if (!environ) { | |
environ = malloc(sizeof(char *) * 4); | |
environ[0] = | |
# 61 "libc/main.c" 3 4 | |
0 | |
# 61 "libc/main.c" | |
; | |
environ[1] = | |
# 62 "libc/main.c" 3 4 | |
0 | |
# 62 "libc/main.c" | |
; | |
environ[2] = | |
# 63 "libc/main.c" 3 4 | |
0 | |
# 63 "libc/main.c" | |
; | |
environ[3] = | |
# 64 "libc/main.c" 3 4 | |
0 | |
# 64 "libc/main.c" | |
; | |
_environ_size = 4; | |
} else { | |
int size = 0; | |
char ** tmp = environ; | |
while (*tmp) { | |
size++; | |
tmp++; | |
} | |
if (size < 4) { | |
_environ_size = 4; | |
} else { | |
_environ_size = size * 2; | |
} | |
char ** new_environ = malloc(sizeof(char*) * _environ_size); | |
int i = 0; | |
while (i < _environ_size && environ[i]) { | |
new_environ[i] = environ[i]; | |
i++; | |
} | |
while (i < _environ_size) { | |
new_environ[i] = | |
# 91 "libc/main.c" 3 4 | |
0 | |
# 91 "libc/main.c" | |
; | |
i++; | |
} | |
environ = new_environ; | |
} | |
if (getenv("__LIBC_DEBUG")) __libc_debug = 1; | |
_argv_0 = __get_argv()[0]; | |
} | |
void pre_main(int argc, char * argv[], char ** envp, int (*main)(int,char**)) { | |
if (!__get_argv()) { | |
__argv = argv; | |
if (!__libc_init_called) { | |
extern uintptr_t __init_array_start; | |
extern uintptr_t __init_array_end; | |
for (uintptr_t * constructor = &__init_array_start; constructor < &__init_array_end; ++constructor) { | |
void (*constr)(void) = (void*)*constructor; | |
constr(); | |
} | |
} | |
} | |
_init(); | |
exit(main(argc, argv)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment