From patchwork Mon Dec 19 11:15:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nix X-Patchwork-Id: 88458 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1103383qgi; Mon, 19 Dec 2016 03:26:08 -0800 (PST) X-Received: by 10.84.170.67 with SMTP id i61mr13129129plb.40.1482146768219; Mon, 19 Dec 2016 03:26:08 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y19si18033714pgj.61.2016.12.19.03.26.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Dec 2016 03:26:08 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-76060-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-76060-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-76060-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=qgLIG7en/6JOOPNNKem5a5WycJeGUyk RFzJqXh+YrY2CQTtePDr9XNdFSQDX824V9WoNRJheh2JqPsysOvXzGlNHL+pokbX qo4zefxIo1Ehj+RbNxrFZpkWvKwVzaHz3wE2vVV2bH+SYadFaXpV7lh5IDsYf8FG kvOZS8vQ9aDY= 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=nsevlsxS96BOmhfKZd6sbuipGvU=; b=dqppy YnIEFEbOunpfZe8mdUa1hdzJLAxkmLXERYgszbEz/TM6HYea79XsRj9W1ot2Z7ZU sQxOGkJ/SmeQyiTGP3WEbnngT1ZSdudzd0qMWHsqr+VkQKE9gdPcPZyCCkQGaJaa k/fURWJFLjNXVqEAtUVbm+NdHGLbCp9umc5HIs= Received: (qmail 121229 invoked by alias); 19 Dec 2016 11:25:54 -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 121055 invoked by uid 89); 19 Dec 2016 11:25:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1614 X-HELO: mail.esperi.org.uk From: Nix To: libc-alpha@sourceware.org Cc: fweimer@redhat.com Subject: [PATCH 09/15] De-PLTize __stack_chk_fail internal calls within libc.so. Date: Mon, 19 Dec 2016 11:15:22 +0000 Message-Id: <20161219111528.14969-10-nix@esperi.org.uk> In-Reply-To: <20161219111528.14969-1-nix@esperi.org.uk> References: <20161219111528.14969-1-nix@esperi.org.uk> X-DCC--Metrics: spindle 1480; Body=2 Fuz1=2 Fuz2=2 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. v8: Merge #ifdef blocks. v10: Use STACK_PROTECTOR_LEVEL to avoid renaming in files where stack-protection is suppressed. * sysdeps/generic/symbol-hacks.h [STACK_PROTECTOR_LEVEL && STACK_PROTECTOR_LEVEL > 0] (__stack_chk_fail): Add internal alias. --- sysdeps/generic/symbol-hacks.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.10.1.208.gbec66bc diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h index ce576c9..d614c09 100644 --- a/sysdeps/generic/symbol-hacks.h +++ b/sysdeps/generic/symbol-hacks.h @@ -4,4 +4,16 @@ asm ("memmove = __GI_memmove"); asm ("memset = __GI_memset"); asm ("memcpy = __GI_memcpy"); + +/* Some targets do not use __stack_chk_fail_local. In libc.so, + redirect __stack_chk_fail to a hidden reference + __stack_chk_fail_local, to avoid the PLT reference. + __stack_chk_fail itself is a global symbol, exported from libc.so, + and cannot be made hidden. */ + +# if IS_IN (libc) && defined SHARED && \ + defined STACK_PROTECTOR_LEVEL && STACK_PROTECTOR_LEVEL > 0 +asm (".hidden __stack_chk_fail_local\n" + "__stack_chk_fail = __stack_chk_fail_local"); +# endif #endif