summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-04-19 15:16:05 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2018-04-19 15:16:05 +0300
commitf2c5d2cf28d92c77a729054d12053f433fad9e1c (patch)
tree19a90ff01ddd24354c55271319f8a5724c9481e7
parentd194dfe969ca5fb5d405fad102b58c114ee83b9b (diff)
linker/libc: don't wrap variable symbols
This is why the bionic_file_to_glibc_file did not work with just pointers. The input is actually pointer to our wrapper, doh.
-rw-r--r--src/libc-stdio.h9
-rw-r--r--src/linker/linker.c4
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