diff options
-rw-r--r-- | src/libc-stdio.h | 9 | ||||
-rw-r--r-- | src/linker/linker.c | 4 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/libc-stdio.h b/src/libc-stdio.h index 9e4f72a..9dacd21 100644 --- a/src/libc-stdio.h +++ b/src/libc-stdio.h @@ -21,14 +21,11 @@ const struct bionic___sFILE bionic___sF[3] = { static inline FILE* bionic_file_to_glibc_file(FILE *f) { - // Can't compare just memory addresses because GNU libstdc++ copies the FILE struct... - // Maybe there could be a cleaner solution, this may in practice break if standard streams - // are opened with different flags in C++. - if (memcmp(f, "stdin", sizeof("stdin"))) + if (f == (void*)&bionic___sF[0]) return stdin; - else if (memcmp(f, "stdout", sizeof("stdout"))) + else if (f == (void*)&bionic___sF[1]) return stdout; - else if (memcmp(f, "stderr", sizeof("stderr"))) + else if (f == (void*)&bionic___sF[2]) return stderr; return f; } diff --git a/src/linker/linker.c b/src/linker/linker.c index 12a3521..058baa5 100644 --- a/src/linker/linker.c +++ b/src/linker/linker.c @@ -1384,7 +1384,9 @@ static int apkenv_reloc_library(soinfo *si, Elf32_Rel *rel, unsigned count) } if(sym_addr != 0) { - sym_addr = (unsigned)wrapper_create(sym_name, (void*)sym_addr); + if(ELF32_ST_TYPE(((Elf32_Sym*)(intptr_t)sym_addr)->st_info) == STT_FUNC) { + sym_addr = (unsigned)wrapper_create(sym_name, (void*)sym_addr); + } } else if(s == NULL) { /* We only allow an undefined symbol if this is a weak |