ANDROID: kasan: fix has_attribute check on older GCC versions

A previously backported commit 8712cc728d ("BACKPORT: kasan: add
CONFIG_KASAN_GENERIC and CONFIG_KASAN_SW_TAGS") introduced a
__has_attribute(__no_sanitize_address__) check into
include/linux/compiler-gcc.h. Unfortunately older GCCs (before version 5)
don't support support this macro, which results in a compilation error.

Fix by checking GCC version instead. The same fix was applied to the 4.14
common kernel during the backport, but was forgotten here.

Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Bug: 128674696
Bug: 142406440
Change-Id: I79cbc3fdc568c0d4905d296b8e5f979da5b41bbb
This commit is contained in:
Andrey Konovalov 2019-10-10 16:44:25 +02:00 committed by Alistair Delva
parent 8ea67644ba
commit c9083aa80b

View file

@ -183,6 +183,15 @@
#define KASAN_ABI_VERSION 3
#endif
/*
* Older GCCs (< 5) don't support __has_attribute, so instead of checking
* __has_attribute(__no_sanitize_address__) do a GCC version check.
*/
#ifndef __has_attribute
# define __has_attribute(x) __GCC4_has_attribute_##x
# define __GCC4_has_attribute___no_sanitize_address__ (__GNUC_MINOR__ >= 8)
#endif
#if __has_attribute(__no_sanitize_address__)
#define __no_sanitize_address __attribute__((no_sanitize_address))
#else