From patchwork Mon Nov 28 12:32:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nix X-Patchwork-Id: 84402 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1132588qgi; Mon, 28 Nov 2016 05:25:36 -0800 (PST) X-Received: by 10.98.14.82 with SMTP id w79mr21371546pfi.153.1480339536426; Mon, 28 Nov 2016 05:25:36 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 19si55111269pfz.127.2016.11.28.05.25.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 05:25:36 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-75245-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-75245-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-75245-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=gXNpkAy0UPyAQL7dWb2zRwbMm/ehnOs h3srkKgpM1EOfflF8U5ezGLik83X5LnO1HLSZY0rBihjLRZ4tM8EB2uWC44/UT5h xWNdk5LNQKqkRCjMeGjcRcU02DV7TgrzWwwtQVyud4wnTQkipblQx8HBbAMUukDM milAnojnIVpg= 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=rG7SouKjM/ZpV0iZZBVCofmLFAM=; b=kiCjf uNUMGqSAa4I/6Ur5eBbZ9rG4ADPQ2uHjv/h8mLz6D2I9fkqjgLGIm6jXG4FnpdW0 PaiEfO5VowSGy+D5rsPXMWXG5o1WrhRNAcOuSWfdt3CcEof8ogtIxVFyU+qO8yiZ vXF5NXoeDTIr1+/ByxgHzQQmpAWdR9PJmk49l0= Received: (qmail 55966 invoked by alias); 28 Nov 2016 13:25:27 -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 55909 invoked by uid 89); 28 Nov 2016 13:25:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1161 X-HELO: mail.esperi.org.uk From: Nix To: libc-alpha@sourceware.org Cc: fweimer@redhat.com, Adhemerval Zanella Subject: [PATCH 08/12] De-PLTize __stack_chk_fail internal calls within libc.so. Date: Mon, 28 Nov 2016 12:32:24 +0000 Message-Id: <20161128123228.30856-9-nix@esperi.org.uk> In-Reply-To: <20161128123228.30856-1-nix@esperi.org.uk> References: <20161128123228.30856-1-nix@esperi.org.uk> X-DCC--Metrics: spindle 1282; Body=3 Fuz1=3 Fuz2=3 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. * sysdeps/generic/symbol-hacks.h (__stack_chk_fail): Add internal alias. --- sysdeps/generic/symbol-hacks.h | 4 ++++ 1 file changed, 4 insertions(+) -- 2.10.1.208.gbec66bc diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h index ce576c9..36908b5 100644 --- a/sysdeps/generic/symbol-hacks.h +++ b/sysdeps/generic/symbol-hacks.h @@ -4,4 +4,8 @@ asm ("memmove = __GI_memmove"); asm ("memset = __GI_memset"); asm ("memcpy = __GI_memcpy"); + +/* -fstack-protector generates calls to __stack_chk_fail, which need + similar adjustments to avoid going through the PLT. */ +asm ("__stack_chk_fail = __stack_chk_fail_local"); #endif