[lttng-dev] tracepoint provider: static versus dynamic linking (TRACEPOINT_PROBE_DYNAMIC_LINKAGE)

David Bryant david.bryant at quantum.com
Wed Nov 7 22:11:54 EST 2012


Hello,

What are the pros and cons of static versus dynamic linking of the 
tracepoint provider? I can't find much information looking around.

Are their any licensing related issues? For example, is closed-source 
software not allowed to use static linking?

Is it just an optimisation - allowing the program to run without probes 
connected?

Thanks,
Dave


Notes from my digging of how it works:

Looking at the preprocessor output of sample.c without/with 
TRACEPOINT_PROBE_DYNAMIC_LINKAGE defined I see:

$ diff -u sample.i.static sample.i.dynamic
--- sample.i.static    2012-11-08 13:29:04.049059515 +1030
+++ sample.i.dynamic    2012-11-08 13:29:04.169062438 +1030
@@ -746,7 +746,7 @@
  struct tracepoint __tracepoint_sample_component___message 
__attribute__((section("__tracepoints"))) = {
      __tp_strtab_sample_component___message,
      0,
      ((void *)0),
-    &__tracepoint_provider_sample_component,
+    ((void *)0),
      "char *, text",
  };

(line breaks added by me).

So the "int * tracepoint::tracepoint_provider_ref" member is set to 
((void *)0) in struct tracepoint:

struct tracepoint {
  const char *name;
  int state;
  struct tracepoint_probe *probes;
  int *tracepoint_provider_ref;         /* XXX */
  const char *signature;
  char padding[16];
};

So the static version is not dependent on the symbol 
"__tracepoint_provider_sample_component". Running 
LD_PRELOAD=libprovider.so ./sample (somehow?) reinstates that symbol. 
(Can't quite see how that works).

----------------------------------------------------------------------
The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic communications, including email and attachments, sent across its networks filtered through anti virus and spam software programs and retain such messages in order to comply with applicable data security and retention requirements. Quantum is not responsible for the proper and complete transmission of the substance of this communication or for any delay in its receipt.



More information about the lttng-dev mailing list