summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-02-18 18:09:14 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-02-18 18:09:14 +0200
commit834dcb638d0d9a97943bf2a14087afae50be1861 (patch)
tree3b66b6dc894650d99cbd2c742f4a4428a44feea8
parentcd18b8599ce870fc04cdb44fbf5e6ec50d9004e6 (diff)
linker: demangle c++ symbols
-rw-r--r--src/linker/linker.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/linker/linker.c b/src/linker/linker.c
index 8f95472..6b7a2bc 100644
--- a/src/linker/linker.c
+++ b/src/linker/linker.c
@@ -163,9 +163,23 @@ enum {
WRAPPER_ARM_INJECTION,
};
+static char* (*__cxa_demangle)(const char *mangled_name, char *output_buffer, size_t *length, int *status);
+
static void
trace(const char *const symbol)
{
+ if (__cxa_demangle) {
+ // >If output_buffer is not long enough, it is expanded using realloc
+ // Holy fuck gcc what the fuck? Guess we don't use stack then, thanks
+ int status;
+ char *demangled;
+ if ((demangled = __cxa_demangle(symbol, NULL, NULL, &status))) {
+ printf("trace: %s\n", demangled);
+ free(demangled); // so pointless...
+ return;
+ }
+ }
+
printf("trace: %s\n", symbol);
}
@@ -2118,6 +2132,9 @@ static int apkenv_link_image(soinfo *si, unsigned wr_offset)
lsi = apkenv_find_library(si->strtab + d[1]);
if (!lsi && dlopen(si->strtab + d[1], RTLD_NOW | RTLD_GLOBAL)) {
DEBUG("Loaded %s with glibc dlopen\n", si->strtab + d[1]);
+
+ if (!__cxa_demangle)
+ __cxa_demangle = dlsym(RTLD_DEFAULT, "__cxa_demangle");
}
#endif
if(lsi == 0) {