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: 69494 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1924067qgf; Tue, 7 Jun 2016 04:25:30 -0700 (PDT) X-Received: by 10.98.6.69 with SMTP id 66mr31170329pfg.115.1465298730782; Tue, 07 Jun 2016 04:25:30 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id h7si25164290paf.20.2016.06.07.04.25.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jun 2016 04:25:30 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-70256-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-70256-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-70256-patch=linaro.org@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:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=upd/MuzzM93kbhPRUQcyoPduJPu6XpK bQM67XNArhlba89VvOX3KWimgtTNu6gCjBMLOsXP8G9ls00vEajfjdCS8aXEvMhC fXGlM9+UZqeuDRlB7kJBA9qVi6/zq424oOYlGZafGekw7g30qqJj6oAs0L9NcbNx pzZrXnEjzJfk= 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:cc:subject:date:message-id:in-reply-to :references; s=default; bh=xeZieA7S69WzXC7pcKIzN6+6BB4=; b=cvwlc UVBkDvAvEGtnP99082/vCH+ACq75D5IdyiXxuqnNC2NqqLHrfoJI9Ux/eMAFnSOk R0DALfS93arQm0Arn3cxjkC2+5Wg1hvZ7Y2B1s5Ltkmi0G3vbz4XrR46JhUy2PhQ PoDktj/YaS2iIP49UF2UxtiFKqlHNqIJTysYRg= 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(+) -- 2.8.2.202.g98588b6 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