vlib: fix asan compilation with gcc 43/27843/2
authorBenoît Ganne <bganne@cisco.com>
Thu, 9 Jul 2020 12:23:51 +0000 (14:23 +0200)
committerDamjan Marion <dmarion@me.com>
Thu, 16 Jul 2020 21:42:40 +0000 (21:42 +0000)
clang tends to force alignment of all sections when compiling for
address sanitizer, confusing VPP plugin infra.
On the contrary, GCC does not support this attribute on sections.
Selectively enable it depending upon the compiler.

Type: fix
Fixes: cea46522e79637f6ec37c03ec3fbeb87b160a378

Change-Id: I2dd6e52e70e6b4d89c101171cafc813e175ec472
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/vlib/unix/plugin.h
src/vppinfra/sanitizer.h

index a52c57b..c9a33cc 100644 (file)
@@ -122,7 +122,7 @@ u8 *vlib_get_vat_plugin_path (void);
 
 #define VLIB_PLUGIN_REGISTER() \
   vlib_plugin_registration_t vlib_plugin_registration \
-  CLIB_NOSANITIZE_ADDR \
+  CLIB_NOSANITIZE_PLUGIN_REG_SECTION \
   __attribute__((__section__(".vlib_plugin_registration")))
 
 /* Call a plugin init function: used for init function dependencies. */
index d099d3a..db4daea 100644 (file)
@@ -51,6 +51,18 @@ CLIB_MEM_POISON_LEN (void *src, size_t oldlen, size_t newlen)
 
 #endif /* CLIB_SANITIZE_ADDR */
 
+/*
+ * clang tends to force alignment of all sections when compiling for address
+ * sanitizer. This confuse VPP plugin infra, prevent clang to do that
+ * On the contrary, GCC does not support this kind of attribute on sections
+ * sigh.
+ */
+#ifdef __clang__
+#define CLIB_NOSANITIZE_PLUGIN_REG_SECTION      CLIB_NOSANITIZE_ADDR
+#else
+#define CLIB_NOSANITIZE_PLUGIN_REG_SECTION
+#endif
+
 #endif /* _included_clib_sanitizer_h */
 
 /*