From 729566b9db41a4425c26ee7fad8c5d1f48355f4c Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Wed, 18 Apr 2018 16:06:36 +0300 Subject: libc: stdio must be wrapped Bionic libc does stupid stuff and defines standard streams as macros to reference of an array element. Thus we can't just point standard streams to their respective correct addresses. (Why does both glibc and bionic even expose the internal FILE structs??) So we have to wrap every function that takes FILE* as argument and mangle it with bionic_file_to_glibc_file. We can't just check addresses because gnu's libstdc++ copies the FILE*. I assume same thing happens with the c++ locale support, and we need to do more complex ctype wrapping. --- src/libc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/libc.c') diff --git a/src/libc.c b/src/libc.c index 66b0d8d..447220e 100644 --- a/src/libc.c +++ b/src/libc.c @@ -14,10 +14,6 @@ #include // h_errno #include "wrapper/verbose.h" -#ifdef VERBOSE_FUNCTIONS -# include "libc-verbose.h" -#endif - struct bionic_dirent { uint64_t d_ino; int64_t d_off; @@ -74,9 +70,10 @@ tkill(int tid, int sig) // Stuff needed for runtime compatibility, but not neccessary for linking // Also stuff that exists in glibc, but needs to be wrapped for runtime compatibility +#include "libc-stdio.h" + const char *bionic__ctype_, *bionic__tolower_tab_, *bionic__toupper_tab_; -char bionic___sF[0x54] = {0}; -unsigned int bionic___page_size = PAGE_SIZE; +const unsigned int bionic___page_size = PAGE_SIZE; __attribute_const__ int* @@ -378,3 +375,7 @@ bionic___futex_wake(volatile void* ftx, int count) return syscall(SYS_futex, ftx, FUTEX_WAKE, count, NULL, 0); } #endif + +#ifdef VERBOSE_FUNCTIONS +# include "libc-verbose.h" +#endif -- cgit v1.2.3