From 20d4a3c2b4f37b2f50bb2163fa1476e0a75ce973 Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Thu, 6 Nov 2014 18:17:49 -0800 Subject: [PATCH] Use dlerror() to clear any error before retrying with the mangled name Thanks to Catalin Ontanu for reporting this, and then doing more investigation to find and test the solution. --- deodexerant/deodexerant.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/deodexerant/deodexerant.c b/deodexerant/deodexerant.c index e4b89a22..1cadee92 100644 --- a/deodexerant/deodexerant.c +++ b/deodexerant/deodexerant.c @@ -48,18 +48,20 @@ void main(int argc, char **argv) { void *libdvm = dlopen("libdvm.so", RTLD_LAZY); if (libdvm == NULL) { - printf("Failed to load libdvm\n"); + printf("Failed to load libdvm: %s\n", dlerror()); return; } dvmGetInlineOpsTablePtr dvmGetInlineOpsTable = dlsym(libdvm, "dvmGetInlineOpsTable"); if (dvmGetInlineOpsTable == NULL) { + // clear the error, and retry with the c++ mangled name + dlerror(); dvmGetInlineOpsTable = dlsym(libdvm, "_Z20dvmGetInlineOpsTablev"); } if (dvmGetInlineOpsTable == NULL) { - printf("Failed to load dvmGetInlineOpsTable\n"); + printf("Failed to load dvmGetInlineOpsTable: %s\n", dlerror()); dlclose(libdvm); return; } @@ -67,11 +69,13 @@ void main(int argc, char **argv) { dvmGetInlineOpsTableLengthPtr dvmGetInlineOpsTableLength = dlsym(libdvm, "dvmGetInlineOpsTableLength"); if (dvmGetInlineOpsTableLength == NULL) { + // clear the error, and retry with the c++ mangled name + dlerror(); dvmGetInlineOpsTableLength = dlsym(libdvm, "_Z26dvmGetInlineOpsTableLengthv"); } if (dvmGetInlineOpsTableLength == NULL) { - printf("Failed to load dvmGetInlineOpsTableLength\n"); + printf("Failed to load dvmGetInlineOpsTableLength: %s\n", dlerror()); dlclose(libdvm); return; }