diff options
| author | H.J. Lu <hjl.tools@gmail.com> | 2024-12-20 05:31:05 +0800 |
|---|---|---|
| committer | H.J. Lu <hjl.tools@gmail.com> | 2024-12-22 13:03:46 +0800 |
| commit | 494eb254c37507e836b5c791a3dbd8552777ddf7 (patch) | |
| tree | d475caa25ab979dca97c79600f1a3660c7f92240 /include | |
| parent | 56cdc529fb553a307be459df3f1be90d1a231f0a (diff) | |
| download | glibc-494eb254c37507e836b5c791a3dbd8552777ddf7.tar.xz glibc-494eb254c37507e836b5c791a3dbd8552777ddf7.zip | |
Add include/libc-misc.h
Add include/libc-misc.h to provide miscellaneous definitions for both
glibc build and test:
1. Move inhibit_stack_protector to libc-misc.h and add Clang support.
2. Add test_inhibit_stack_protector for glibc testing.
3. Move inhibit_loop_to_libcall to libc-misc.h.
4. Add test_cc_inhibit_loop_to_libcall to handle TEST_CC != CC and
replace inhibit_loop_to_libcall with test_cc_inhibit_loop_to_libcall
in glibc tests.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Co-Authored-By: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/libc-misc.h | 67 | ||||
| -rw-r--r-- | include/libc-symbols.h | 21 |
2 files changed, 69 insertions, 19 deletions
diff --git a/include/libc-misc.h b/include/libc-misc.h new file mode 100644 index 0000000000..23fc1c1f60 --- /dev/null +++ b/include/libc-misc.h @@ -0,0 +1,67 @@ +/* Miscellaneous definitions for both glibc build and test. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef _INCLUDE_MISC_H +#define _INCLUDE_MISC_H + +#include <config.h> + +/* Add the compiler optimization to inhibit loop transformation to library + calls. This is used to avoid recursive calls in memset and memmove + default implementations in tests. */ +#ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL +# define inhibit_loop_to_libcall \ + __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns"))) +#else +# define inhibit_loop_to_libcall +#endif + +#ifdef HAVE_TEST_CC_INHIBIT_LOOP_TO_LIBCALL +# define test_cc_inhibit_loop_to_libcall \ + __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns"))) +#else +# define test_cc_inhibit_loop_to_libcall +#endif + +/* Used to disable stack protection in sensitive places, like ifunc + resolvers and early static TLS init. */ +#ifdef __clang__ +# define cc_inhibit_stack_protector \ + __attribute__((no_stack_protector)) +#else +# define cc_inhibit_stack_protector \ + __attribute__ ((__optimize__ ("-fno-stack-protector"))) +#endif + +#if IS_IN (testsuite) || IS_IN (testsuite_internal) +# ifdef HAVE_TEST_CC_NO_STACK_PROTECTOR +# define test_inhibit_stack_protector cc_inhibit_stack_protector +# define inhibit_stack_protector cc_inhibit_stack_protector +# else +# define test_inhibit_stack_protector +# define inhibit_stack_protector +# endif +#else +# ifdef HAVE_CC_NO_STACK_PROTECTOR +# define inhibit_stack_protector cc_inhibit_stack_protector +# else +# define test_inhibit_stack_protector +# endif +#endif + +#endif diff --git a/include/libc-symbols.h b/include/libc-symbols.h index 4367aa6740..ff3555be9d 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -59,6 +59,8 @@ # define IN_MODULE (-1) #endif +#include <libc-misc.h> + #ifndef _ISOMAC /* This is defined for the compilation of all C library code. features.h @@ -362,15 +364,6 @@ for linking") #define attribute_relro __attribute__ ((section (".data.rel.ro"))) -/* Used to disable stack protection in sensitive places, like ifunc - resolvers and early static TLS init. */ -#ifdef HAVE_CC_NO_STACK_PROTECTOR -# define inhibit_stack_protector \ - __attribute__ ((__optimize__ ("-fno-stack-protector"))) -#else -# define inhibit_stack_protector -#endif - /* The following macros are used for PLT bypassing within libc.so (and if needed other libraries similarly). First of all, you need to have the function prototyped somewhere, @@ -804,16 +797,6 @@ for linking") #define libm_ifunc_init() #define libm_ifunc(name, expr) \ __ifunc (name, name, expr, void, libm_ifunc_init) - -/* Add the compiler optimization to inhibit loop transformation to library - calls. This is used to avoid recursive calls in memset and memmove - default implementations. */ -#ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL -# define inhibit_loop_to_libcall \ - __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns"))) -#else -# define inhibit_loop_to_libcall -#endif /* These macros facilitate sharing source files with gnulib. |
