plugin-dev: mark symbols meant to be public with __attribute__((visibility("default")))
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 20 Oct 2023 16:12:20 +0000 (12:12 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 21 Oct 2023 11:56:09 +0000 (07:56 -0400)
This is a partial backport of commit 1353b066072 ("Visibility hidden by
default"), from the master branch.

If a plugin author compiles their plugin with `-fvisibility=hidden`,
symbols such as `__bt_get_begin_section_plugin_descriptor` are local,
therefore not seen by libbbabeltrace2, and the plugin fails to load.

To avoid this, use `__attribute__((visibility("default")))` on those
symbols that we really want to be externally visible.

Reported-By: Kienan Stewart <kstewart@efficios.com>
Change-Id: Ia08173fa69ed699583a0957ce42f305d443b2952
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11111
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Kienan Stewart <kstewart@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
include/babeltrace2/plugin/plugin-dev.h

index fd628b9e1efcd10f38bbcf355ff16236b247f201..3aeb1ebfdb76e730db167267a6f74d039014127a 100644 (file)
 #define _BT_HIDDEN __attribute__((visibility("hidden")))
 #endif
 
+/*
+ * _BT_EXPORT: set the visibility for exported functions.
+ */
+#if defined(_WIN32) || defined(__CYGWIN__)
+#define _BT_EXPORT
+#else
+#define _BT_EXPORT __attribute__((visibility("default")))
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -352,35 +361,35 @@ other <code>BT_PLUGIN*()</code> macro.
        _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor_attribute const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA; \
        _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor_attribute const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_EXTRA; \
        \
-       struct __bt_plugin_descriptor const * const *__bt_get_begin_section_plugin_descriptors(void) \
+       _BT_EXPORT struct __bt_plugin_descriptor const * const *__bt_get_begin_section_plugin_descriptors(void) \
        { \
                return &__BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL; \
        } \
-       struct __bt_plugin_descriptor const * const *__bt_get_end_section_plugin_descriptors(void) \
+       _BT_EXPORT struct __bt_plugin_descriptor const * const *__bt_get_end_section_plugin_descriptors(void) \
        { \
                return &__BT_PLUGIN_DESCRIPTOR_END_SYMBOL; \
        } \
-       struct __bt_plugin_descriptor_attribute const * const *__bt_get_begin_section_plugin_descriptor_attributes(void) \
+       _BT_EXPORT struct __bt_plugin_descriptor_attribute const * const *__bt_get_begin_section_plugin_descriptor_attributes(void) \
        { \
                return &__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL; \
        } \
-       struct __bt_plugin_descriptor_attribute const * const *__bt_get_end_section_plugin_descriptor_attributes(void) \
+       _BT_EXPORT struct __bt_plugin_descriptor_attribute const * const *__bt_get_end_section_plugin_descriptor_attributes(void) \
        { \
                return &__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_SYMBOL; \
        } \
-       struct __bt_plugin_component_class_descriptor const * const *__bt_get_begin_section_component_class_descriptors(void) \
+       _BT_EXPORT struct __bt_plugin_component_class_descriptor const * const *__bt_get_begin_section_component_class_descriptors(void) \
        { \
                return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL; \
        } \
-       struct __bt_plugin_component_class_descriptor const * const *__bt_get_end_section_component_class_descriptors(void) \
+       _BT_EXPORT struct __bt_plugin_component_class_descriptor const * const *__bt_get_end_section_component_class_descriptors(void) \
        { \
                return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_SYMBOL; \
        } \
-       struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_begin_section_component_class_descriptor_attributes(void) \
+       _BT_EXPORT struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_begin_section_component_class_descriptor_attributes(void) \
        { \
                return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL; \
        } \
-       struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_end_section_component_class_descriptor_attributes(void) \
+       _BT_EXPORT struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_end_section_component_class_descriptor_attributes(void) \
        { \
                return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL; \
        }
This page took 0.026935 seconds and 4 git commands to generate.