X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=include%2Fbabeltrace2%2Fplugin%2Fplugin-dev.h;h=1b1a8916825fd63fb31a2a80d7ab1fba7f770e05;hp=713725366f9ca9034a0dbb31f4118c84d463357f;hb=0235b0db7de5bcacdb3650c92461f2ce5eb2143d;hpb=43c59509042845f8d42c3e99ec74d45fa2dc0908 diff --git a/include/babeltrace2/plugin/plugin-dev.h b/include/babeltrace2/plugin/plugin-dev.h index 71372536..1b1a8916 100644 --- a/include/babeltrace2/plugin/plugin-dev.h +++ b/include/babeltrace2/plugin/plugin-dev.h @@ -1,28 +1,12 @@ -#ifndef BABELTRACE2_PLUGIN_PLUGIN_DEV_H -#define BABELTRACE2_PLUGIN_PLUGIN_DEV_H - /* - * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * SPDX-License-Identifier: MIT * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation */ +#ifndef BABELTRACE2_PLUGIN_PLUGIN_DEV_H +#define BABELTRACE2_PLUGIN_PLUGIN_DEV_H + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -464,7 +448,6 @@ See the \ref api-comp-cls-prop-descr "description" property. */ #define BT_PLUGIN_DESCRIPTION(_description) BT_PLUGIN_DESCRIPTION_WITH_ID(auto, _description) - /*! @brief Sets the name(s) of the author(s) of the plugin having the ID @@ -2660,13 +2643,31 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ }; \ static struct __bt_plugin_component_class_descriptor_attribute const * const __bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_component_class_id##_##_attr_name##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS = &__bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_component_class_id##_##_attr_name +/* + * Clang supports the no_sanitize variable attribute on global variables. + * GCC only supports the no_sanitize_address function attribute, which is + * not what we need. This is fine because, as far as we have seen, gcc + * does not insert red zones around global variables. + */ +#if defined(__clang__) +# if __has_feature(address_sanitizer) +# define __bt_plugin_variable_attribute_no_sanitize_address \ + __attribute__((no_sanitize("address"))) +# else +# define __bt_plugin_variable_attribute_no_sanitize_address +# endif +#else +# define __bt_plugin_variable_attribute_no_sanitize_address +#endif + /* * Variable attributes for a plugin descriptor pointer to be added to * the plugin descriptor section (internal use). */ #ifdef __APPLE__ #define __BT_PLUGIN_DESCRIPTOR_ATTRS \ - __attribute__((section("__DATA,btp_desc"), used)) + __attribute__((section("__DATA,btp_desc"), used)) \ + __bt_plugin_variable_attribute_no_sanitize_address #define __BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL \ __start___bt_plugin_descriptors @@ -2683,7 +2684,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ #else #define __BT_PLUGIN_DESCRIPTOR_ATTRS \ - __attribute__((section("__bt_plugin_descriptors"), used)) + __attribute__((section("__bt_plugin_descriptors"), used)) \ + __bt_plugin_variable_attribute_no_sanitize_address #define __BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL \ __start___bt_plugin_descriptors @@ -2702,7 +2704,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ */ #ifdef __APPLE__ #define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS \ - __attribute__((section("__DATA,btp_desc_att"), used)) + __attribute__((section("__DATA,btp_desc_att"), used)) \ + __bt_plugin_variable_attribute_no_sanitize_address #define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \ __start___bt_plugin_descriptor_attributes @@ -2719,7 +2722,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ #else #define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS \ - __attribute__((section("__bt_plugin_descriptor_attributes"), used)) + __attribute__((section("__bt_plugin_descriptor_attributes"), used)) \ + __bt_plugin_variable_attribute_no_sanitize_address #define __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \ __start___bt_plugin_descriptor_attributes @@ -2738,7 +2742,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ */ #ifdef __APPLE__ #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS \ - __attribute__((section("__DATA,btp_cc_desc"), used)) + __attribute__((section("__DATA,btp_cc_desc"), used)) \ + __bt_plugin_variable_attribute_no_sanitize_address #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL \ __start___bt_plugin_component_class_descriptors @@ -2755,7 +2760,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ #else #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS \ - __attribute__((section("__bt_plugin_component_class_descriptors"), used)) + __attribute__((section("__bt_plugin_component_class_descriptors"), used)) \ + __bt_plugin_variable_attribute_no_sanitize_address #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL \ __start___bt_plugin_component_class_descriptors @@ -2775,7 +2781,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ */ #ifdef __APPLE__ #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS \ - __attribute__((section("__DATA,btp_cc_desc_att"), used)) + __attribute__((section("__DATA,btp_cc_desc_att"), used)) \ + __bt_plugin_variable_attribute_no_sanitize_address #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \ __start___bt_plugin_component_class_descriptor_attributes @@ -2792,7 +2799,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ #else #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS \ - __attribute__((section("__bt_plugin_component_class_descriptor_attributes"), used)) + __attribute__((section("__bt_plugin_component_class_descriptor_attributes"), used)) \ + __bt_plugin_variable_attribute_no_sanitize_address #define __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL \ __start___bt_plugin_component_class_descriptor_attributes