From patchwork Sun Mar 13 15:16:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nix X-Patchwork-Id: 63767 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2047962lbc; Sun, 13 Mar 2016 08:18:12 -0700 (PDT) X-Received: by 10.66.124.226 with SMTP id ml2mr30755490pab.90.1457882292514; Sun, 13 Mar 2016 08:18:12 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id li15si4112272pab.113.2016.03.13.08.18.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Mar 2016 08:18:12 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-68097-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libc-alpha-return-68097-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-68097-patch=linaro.org@sourceware.org; dkim=pass header.i=@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Hx2K5lBxhfu//YeY15yURfgiZdIoR0P KuqeGX5e3wRXuRFm99MyJO8ayKSLAyOlQs/G5esOTIB5Z8sCm4bJ31IYPS+15dyg ZU9iVQ1QLCkvLaKpnPZlmPGU/zT2rAIr//zVPAslu1F9BYS9O0voPClwDfwH2ARZ eK4418V8jMkk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=Q16Hlp8Z/WPIjgBUGbH++tfiOCo=; b=whbz+ fn6MPzjIv9yg6PM84lB8XB0SuidTJ5OSicorWo1CB0IXMba29Dmh892mDWkb70ml 46JnDTcc0yAujNnPJrIh8lYx+beTIW5yHLN2ilvRuovuE6dj/jZ+z8/B2HdxSJkG /HO5dYOc+EOA5y4JCu6l1icwOXfxoSbX4ex99s= Received: (qmail 45971 invoked by alias); 13 Mar 2016 15:17:47 -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 45898 invoked by uid 89); 13 Mar 2016 15:17:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL, BAYES_05, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=redirect, Zanella, zanella, 59 X-HELO: mail.esperi.org.uk From: Nix To: libc-alpha@sourceware.org Subject: [PATCH 11/17 v6] De-PLTize __stack_chk_fail internal calls within libc.so. Date: Sun, 13 Mar 2016 15:16:56 +0000 Message-Id: <1457882222-22599-12-git-send-email-nix@esperi.org.uk> In-Reply-To: <1457882222-22599-1-git-send-email-nix@esperi.org.uk> References: <1457882222-22599-1-git-send-email-nix@esperi.org.uk> X-DCC-wuwien-Metrics: spindle 1290; Body=1 Fuz1=1 Fuz2=1 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(+) -- 2.7.0.198.g6dd47b6 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