From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id ADFFF385842A; Fri, 28 Oct 2022 17:45:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ADFFF385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666979123; bh=B7UPhg42HfRgcFMUy/KWwRkgUNezfisC5zRIhJ98AHM=; h=From:To:Subject:Date:From; b=WEVw7nEWo/MJL7UoTSlZV92prxUTBDFvcK1xWBFRPXBxsoOBGppWOR159u7PkF+yK zyJEwLWBGDCdqPx4iD4C36e2YQTS+BQ/iZm4tLY7VucqXf2hz3Y8Q9EIvd1ZHly5fC 6VPGtvDYSMss0jtvQpb6qf5+BVEtfaLYvMv3/sV0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] Move inhibit_stack_protector to its own header X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/clang X-Git-Oldrev: c36dffb13151898490a14c7bcd9d949f0475cbb1 X-Git-Newrev: fce1ff0930c6faa72800fea94fb99189316c2daa Message-Id: <20221028174523.ADFFF385842A@sourceware.org> Date: Fri, 28 Oct 2022 17:45:23 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fce1ff0930c6faa72800fea94fb99189316c2daa commit fce1ff0930c6faa72800fea94fb99189316c2daa Author: Adhemerval Zanella Date: Thu Aug 25 09:47:31 2022 -0300 Move inhibit_stack_protector to its own header It is used on tests as well. Diff: --- include/libc-symbols.h | 15 +-------------- include/stackprotector.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/include/libc-symbols.h b/include/libc-symbols.h index 579eca0405..aea935dc52 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -87,6 +87,7 @@ /* Obtain the definition of symbol_version_reference. */ #include #include +#include /* When PIC is defined and SHARED isn't defined, we are building PIE by default. */ @@ -430,20 +431,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 -# ifdef __clang__ -# define inhibit_stack_protector \ - __attribute__((no_stack_protector)) -# else -# define inhibit_stack_protector \ - __attribute__ ((__optimize__ ("-fno-stack-protector"))) -# endif -#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, diff --git a/include/stackprotector.h b/include/stackprotector.h new file mode 100644 index 0000000000..10230bac06 --- /dev/null +++ b/include/stackprotector.h @@ -0,0 +1,38 @@ +/* Details about stack protection enablement and how to disable it. + Copyright (C) 2022 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 + . */ + +#ifndef _INCLUDE_STACKPROTECTOR_H +#define _INCLUDE_STACKPROTECTOR_H + +#include + +/* Used to disable stack protection in sensitive places, like ifunc + resolvers and early static TLS init. */ +#ifdef HAVE_CC_NO_STACK_PROTECTOR +# ifdef __clang__ +# define inhibit_stack_protector \ + __attribute__((no_stack_protector)) +# else +# define inhibit_stack_protector \ + __attribute__ ((__optimize__ ("-fno-stack-protector"))) +# endif +#else +# define inhibit_stack_protector +#endif + +#endif