[Buildroot] [PATCH] toolchain: introduce config options to include GCC's sanitation libraries
Markus Mayer
mmayer at broadcom.com
Wed Jun 5 21:41:55 UTC 2019
We add config options for external toolchains to allow copying the
following libraries into the root file system:
- libasan (-fsanitize=address)
- liblsan (-fsanitize=leak)
- libtsan (-fsanitize=thread)
- libubsan (-fsanitize=undefined)
Copying these shared libraries into the root file system will add
run-time support for binaries compiled with one of the above "sanitize"
options for enhanced run-time debugging.
Signed-off-by: Markus Mayer <mmayer at broadcom.com>
---
toolchain/Config.in | 12 ++++++++
.../pkg-toolchain-external.mk | 16 +++++++++++
.../Config.in.options | 28 +++++++++++++++++++
3 files changed, 56 insertions(+)
diff --git a/toolchain/Config.in b/toolchain/Config.in
index 2da537e7d4c8..15bd2179f9a2 100644
--- a/toolchain/Config.in
+++ b/toolchain/Config.in
@@ -632,4 +632,16 @@ config BR2_TOOLCHAIN_HAS_LIBQUADMATH
bool
default y if BR2_i386 || BR2_x86_64
+config BR2_TOOLCHAIN_HAS_LIBASAN
+ bool
+
+config BR2_TOOLCHAIN_HAS_LIBLSAN
+ bool
+
+config BR2_TOOLCHAIN_HAS_LIBTSAN
+ bool
+
+config BR2_TOOLCHAIN_HAS_LIBUBSAN
+ bool
+
endmenu
diff --git a/toolchain/toolchain-external/pkg-toolchain-external.mk b/toolchain/toolchain-external/pkg-toolchain-external.mk
index baf719ad1f09..ca4dd00446b5 100644
--- a/toolchain/toolchain-external/pkg-toolchain-external.mk
+++ b/toolchain/toolchain-external/pkg-toolchain-external.mk
@@ -148,6 +148,22 @@ ifeq ($(BR2_TOOLCHAIN_HAS_OPENMP),y)
TOOLCHAIN_EXTERNAL_LIBS += libgomp.so.*
endif
+ifeq ($(BR2_TOOLCHAIN_HAS_LIBASAN),y)
+TOOLCHAIN_EXTERNAL_LIBS += libasan.so*
+endif
+
+ifeq ($(BR2_TOOLCHAIN_HAS_LIBLSAN),y)
+TOOLCHAIN_EXTERNAL_LIBS += liblsan.so*
+endif
+
+ifeq ($(BR2_TOOLCHAIN_HAS_LIBTSAN),y)
+TOOLCHAIN_EXTERNAL_LIBS += libtsan.so*
+endif
+
+ifeq ($(BR2_TOOLCHAIN_HAS_LIBUBSAN),y)
+TOOLCHAIN_EXTERNAL_LIBS += libubsan.so*
+endif
+
TOOLCHAIN_EXTERNAL_LIBS += $(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
diff --git a/toolchain/toolchain-external/toolchain-external-custom/Config.in.options b/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
index cb7095632fff..c62745103740 100644
--- a/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
+++ b/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
@@ -437,6 +437,34 @@ config BR2_TOOLCHAIN_EXTERNAL_OPENMP
support. If you don't know, leave the default value,
Buildroot will tell you if it's correct or not.
+config BR2_TOOLCHAIN_EXTERNAL_LIBASAN
+ bool "Toolchain has libasan support?"
+ select BR2_TOOLCHAIN_HAS_LIBASAN
+ help
+ Select this option if your external toolchain has libasan
+ support (-fsanitize=address).
+
+config BR2_TOOLCHAIN_EXTERNAL_LIBLSAN
+ bool "Toolchain has liblsan support?"
+ select BR2_TOOLCHAIN_HAS_LIBLSAN
+ help
+ Select this option if your external toolchain has libasan
+ support (-fsanitize=leak).
+
+config BR2_TOOLCHAIN_EXTERNAL_LIBTSAN
+ bool "Toolchain has libtsan support?"
+ select BR2_TOOLCHAIN_HAS_LIBTSAN
+ help
+ Select this option if your external toolchain has libasan
+ support (-fsanitize=thread).
+
+config BR2_TOOLCHAIN_EXTERNAL_LIBUBSAN
+ bool "Toolchain has libasan support?"
+ select BR2_TOOLCHAIN_HAS_LIBUBSAN
+ help
+ Select this option if your external toolchain has libubsan
+ support (-fsanitize=undefined).
+
config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS
string "Extra toolchain libraries to be copied to target"
help
--
2.17.1
More information about the buildroot
mailing list