From 1aaa17802c92d99ae170245c2b2f15a6c27b133e Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Mon, 6 Oct 2014 14:49:00 -0700 Subject: [PATCH] cdefs.h: add artificial attribute to FORTIFY_SOURCE functions Otherwise the gcc compiler warning doesn't show up. Add -Wno-error to fortify related tests. Fortify related tests are expected to be examples of bad programs, and in many cases shouldn't compile cleanly. Rewriting them to compile cleanly isn't feasible nor desirable. Bug: 17784968 Change-Id: I93bececa7444d965f18c7c27d46e7abce5c49a02 --- libc/include/sys/cdefs.h | 7 +++++++ tests/Android.mk | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h index 5082327dc..6f238a93d 100644 --- a/libc/include/sys/cdefs.h +++ b/libc/include/sys/cdefs.h @@ -53,6 +53,9 @@ #ifndef __has_builtin #define __has_builtin(x) 0 #endif +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif /* @@ -534,8 +537,12 @@ #endif #define __bos0(s) __builtin_object_size((s), 0) +#if __GNUC_PREREQ(4,3) || __has_attribute(__artificial__) +#define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline)) __attribute__((__artificial__)) +#else #define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline)) #endif +#endif #define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1) /* Used to tag non-static symbols that are private and never exposed by the shared library. */ diff --git a/tests/Android.mk b/tests/Android.mk index d946d307c..039057b93 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -152,11 +152,10 @@ $(foreach compiler,gcc clang, \ $(foreach test,1 2, \ $(eval fortify$(test)-tests-$(compiler)_cflags := \ $(test_cflags) \ + -Wno-error \ -U_FORTIFY_SOURCE \ -D_FORTIFY_SOURCE=$(test) \ -DTEST_NAME=Fortify$(test)_$(compiler)); \ - $(eval fortify$(test)-tests-$(compiler)_cflags_host := \ - -Wno-error); \ $(eval fortify$(test)-tests-$(compiler)_src_files := \ fortify_test.cpp); \ $(eval fortify_libs += fortify$(test)-tests-$(compiler)); \