summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Das Mohapatra <vivek@collabora.co.uk>2017-09-13 22:07:50 (GMT)
committerVivek Das Mohapatra <vivek@collabora.co.uk>2017-09-13 22:07:50 (GMT)
commitbe22a664367468fc4b7073694ce1ba551a3d974b (patch)
tree545b8082a370ef76e32459436875574c13f09015
parent7b19760b1064c7ef6a4c3611edb2285a8f446441 (diff)
downloadlibcapsule-be22a664367468fc4b7073694ce1ba551a3d974b.tar.gz
libcapsule-be22a664367468fc4b7073694ce1ba551a3d974b.tar.xz
If a stubroutine in the shim is called dump some backtrace info
We shouldn't ever reach a shim stubroutine, so if we do it means a relocation has probably failed: We dump a few backtrace frames if this happens so we can track down which DSO called into the shim, and hopefully figure out what kind of relocation it was.
-rw-r--r--data/capsule-shim.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/data/capsule-shim.h b/data/capsule-shim.h
index 3283f55..fb2ad30 100644
--- a/data/capsule-shim.h
+++ b/data/capsule-shim.h
@@ -21,15 +21,36 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
+#include <execinfo.h>
#include <capsule.h>
#define UNVERSIONED_STUB(name) \
- void name (void) { fprintf(stderr, "! SHIM " #name " called\n" ); return; }
+ void name (void) \
+ { \
+ fprintf(stderr, "! SHIM " #name " called\n" ); \
+ backtrace_shim_call(); \
+ return; \
+ }
#define VERSIONED_STUB(name,version) \
UNVERSIONED_STUB(name);
+void backtrace_shim_call (void)
+{
+ void *trace[16] = { NULL };
+ int traced = 0;
+ char **symbols = NULL;
+
+ traced = backtrace( trace, sizeof(trace)/sizeof(void *) );
+ symbols = backtrace_symbols( trace, traced );
+
+ for( int x = 1; x < traced; x++ )
+ fprintf( stderr, " -> %s\n", symbols[x] );
+
+ free( symbols );
+}
+
// We don't support versioned symbols properly yet, they need som
// asm magic that looks like this and I'm not clear on the details:
// __asm__(".symver _" #name "," #name #version)