From patchwork Tue Jun 7 11:06:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nix X-Patchwork-Id: 12839 Received: (qmail 49092 invoked by alias); 7 Jun 2016 11:25:19 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 49066 invoked by uid 89); 7 Jun 2016 11:25:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL, BAYES_20, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=adhemerval.zanella@linaro.org, Zanella, zanella, adhemerval X-HELO: mail.esperi.org.uk From: Nix To: libc-alpha@sourceware.org Cc: fweimer@redhat.com, Adhemerval Zanella Subject: [PATCH 10/14 v6] De-PLTize __stack_chk_fail internal calls within libc.so. Date: Tue, 7 Jun 2016 12:06:12 +0100 Message-Id: <1465297576-10981-11-git-send-email-nix@esperi.org.uk> In-Reply-To: <1465297576-10981-1-git-send-email-nix@esperi.org.uk> References: <1465297576-10981-1-git-send-email-nix@esperi.org.uk> X-DCC--Metrics: spindle 1282; Body=4 Fuz1=4 Fuz2=4 From: Adhemerval Zanella We use the same assembler-macro trick we use to de-PLTize compiler-generated libcalls to memcpy and memset to redirect __stack_chk_fail to __stack_chk_fail_local. v5: New. v6: Only do it within the shared library: with __stack_chk_fail_local in libc_pic.a now we don't need to worry about calls from inside other routines in libc_nonshared.a any more. * sysdeps/generic/symbol-hacks.h (__stack_chk_fail): Add internal alias. --- sysdeps/generic/symbol-hacks.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h index ce576c9..fd3d2de 100644 --- a/sysdeps/generic/symbol-hacks.h +++ b/sysdeps/generic/symbol-hacks.h @@ -5,3 +5,9 @@ asm ("memmove = __GI_memmove"); asm ("memset = __GI_memset"); asm ("memcpy = __GI_memcpy"); #endif + +/* -fstack-protector generates calls to __stack_chk_fail, which need + similar adjustments to avoid going through the PLT. */ +#if !defined __ASSEMBLER__ && IS_IN (libc) && defined SHARED +asm ("__stack_chk_fail = __stack_chk_fail_local"); +#endif