Skip to content

Commit ecbb46b

Browse files
committed
Compiler Attributes: Add __overloadable for Clang
In order for FORTIFY_SOURCE to use __pass_object_size on an "extern inline" function, as all the fortified string functions are, the functions must be marked as being overloadable (i.e. different prototypes due to the implicitly injected object size arguments). This allows the __pass_object_size versions to take precedence. Cc: Nathan Chancellor <nathan@kernel.org> Cc: llvm@lists.linux.dev Reviewed-by: Miguel Ojeda <ojeda@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20220208225350.1331628-4-keescook@chromium.org
1 parent f868dab commit ecbb46b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/linux/compiler_attributes.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,18 @@
257257
*/
258258
#define __noreturn __attribute__((__noreturn__))
259259

260+
/*
261+
* Optional: not supported by gcc.
262+
* Optional: not supported by icc.
263+
*
264+
* clang: https://clang.llvm.org/docs/AttributeReference.html#overloadable
265+
*/
266+
#if __has_attribute(__overloadable__)
267+
# define __overloadable __attribute__((__overloadable__))
268+
#else
269+
# define __overloadable
270+
#endif
271+
260272
/*
261273
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-packed-type-attribute
262274
* clang: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-packed-variable-attribute

0 commit comments

Comments
 (0)