X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=include%2Flttng%2Ftracepoint.h;h=887c9deea87b4653d944f8b9658b454d380de8bb;hb=628e1d81fe575cfd281d8e0758b672b23d890c09;hp=fa39b272d8ff19527fd065c7e393ac947b46c8b2;hpb=0cdad3b1a77f830aa0d0a385f0ed4c06fe81c7ef;p=lttng-ust.git diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h index fa39b272..887c9dee 100644 --- a/include/lttng/tracepoint.h +++ b/include/lttng/tracepoint.h @@ -152,18 +152,35 @@ extern int __tracepoint_probe_unregister(const char *name, void *func, void *dat #ifdef TRACEPOINT_DEFINE +/* + * When TRACEPOINT_PROBE_DYNAMIC_LINKAGE is defined, we do not emit a + * unresolved symbol that requires the provider to be linked in. When + * TRACEPOINT_PROBE_DYNAMIC_LINKAGE is not defined, we emit an + * unresolved symbol that depends on having the provider linked in, + * otherwise the linker complains. This deals with use of static + * libraries, ensuring that the linker does not remove the provider + * object from the executable. + */ +#ifdef TRACEPOINT_PROBE_DYNAMIC_LINKAGE +#define _TRACEPOINT_UNDEFINED_REF(provider) +#else /* TRACEPOINT_PROBE_DYNAMIC_LINKAGE */ +#define _TRACEPOINT_UNDEFINED_REF(provider) \ + &__tracepoint_provider_##provider, +#endif /* TRACEPOINT_PROBE_DYNAMIC_LINKAGE */ + /* * Note: to allow PIC code, we need to allow the linker to update the pointers * in the __tracepoints_ptrs section. * Therefore, this section is _not_ const (read-only). */ #define _DEFINE_TRACEPOINT(provider, name) \ + extern int __tracepoint_provider_##provider; \ static const char __tp_strtab_##provider##___##name[] \ __attribute__((section("__tracepoints_strings"))) = \ #provider ":" #name; \ struct tracepoint __tracepoint_##provider##___##name \ __attribute__((section("__tracepoints"))) = \ - { __tp_strtab_##provider##___##name, 0, NULL }; \ + { __tp_strtab_##provider##___##name, 0, NULL, _TRACEPOINT_UNDEFINED_REF(provider) }; \ static struct tracepoint * __tracepoint_ptr_##provider##___##name \ __attribute__((used, section("__tracepoints_ptrs"))) = \ &__tracepoint_##provider##___##name;