From patchwork Thu May 11 15:56:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 761242 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wNygR6Mrmz9rxm for ; Fri, 12 May 2017 02:07:47 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kdHDJvLW"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wNygR5JP8zDqLg for ; Fri, 12 May 2017 02:07:47 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kdHDJvLW"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3wNyRV2hrmzDqMG for ; Fri, 12 May 2017 01:57:26 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kdHDJvLW"; dkim-atps=neutral Received: by mail-pf0-x242.google.com with SMTP id a23so3726418pfe.0 for ; Thu, 11 May 2017 08:57:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JEoRpxTa/4qxpoyXnB+n9ZxHAETwlG4Il9cWnlmWTYk=; b=kdHDJvLW9yprHsx3QKpY6vh53vKmEQvIcO3C6m9hkDrLf+upQIx9ZhGexcTkun2kZJ ZzBMvNw50RyqqykFgU9gybzcXBdkymudqDGG0gS/guWLFVX79fr3hYqoHwJ6ieHlv2dB 6kbNtwgnif8N/4X4cmEomXUR7VNe+2HR4yLfGxvqOUE2oOCkVTTU5RmD6pXPquf/rqPV j9ZViI3yoBzfugmLgJ3GfhMMlVK+4BXnor3FrOc5mQKMf5VgCbM1qoiNAT0ehaN03fnJ RupAT6N2Y+CI956HRkjn9MAYpLH7E68YOQWrM9BJZooFstRk2y/crsmx5PZqIXDw0RXN KYIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JEoRpxTa/4qxpoyXnB+n9ZxHAETwlG4Il9cWnlmWTYk=; b=bCjDKLiWLb/WJUEKdOSMeotOBrybvPKP3z0A8gMvXgQzBZpWnRCSWi2eGN99XHr8Ua uRnIZDzOkXQqJ/lFju+Pzp6LmjQBBV5DZ3Cp1SvFGSTYHephbOu5YiUQuEdYhFi3TwEV eWw4GnSz+/Gl1YFKEbz/RaSS/ZLIFxnuTNn1wXftMiL1HgOW3lIsQYNDcHeJOZM6rXmB IdWtbZpzu6OrFkGxcA/n9web+C9jfSkpY/sXBZJjaqla1MZ39b+MZsHWH1vaqupkXHpb Fo3K6yiEQ5GmfoPZbX6ICS3HNDgsbwBo34q4t/DN+zMH15FOxAEiIOUBx1d54/+rKBDb WXEQ== X-Gm-Message-State: AODbwcDmBN+jNIoYvRdQVUT1muavARSJMGx5hqGvwtsP2M/oQSHgM+3r BlM9K1crRWJhAMgV X-Received: by 10.98.252.8 with SMTP id e8mr1169702pfh.190.1494518244119; Thu, 11 May 2017 08:57:24 -0700 (PDT) Received: from roar.au.ibm.com ([210.185.118.93]) by smtp.gmail.com with ESMTPSA id c7sm1194002pfk.103.2017.05.11.08.57.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 May 2017 08:57:23 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 5/5] powerpc/64: Linker on-demand sfpr functions for modules Date: Fri, 12 May 2017 01:56:52 +1000 Message-Id: <20170511155652.8287-6-npiggin@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170511155652.8287-1-npiggin@gmail.com> References: <20170511155652.8287-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" For final link, the powerpc64 linker generates fpr save/restore functions on-demand, placing them in the .sfpr section. Starting with binutils 2.25, these can be provided for non-final links with --save-restore-funcs. Use that where possible for module links. This saves about 200 bytes per module (~60kB) on powernv defconfig build. Signed-off-by: Nicholas Piggin --- arch/powerpc/Makefile | 10 ++++++++++ arch/powerpc/lib/Makefile | 13 ++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 3e0f0e1fadef..eaa1865e4a8d 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -189,7 +189,17 @@ else CHECKFLAGS += -D__LITTLE_ENDIAN__ endif +ifdef CONFIG_PPC32 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o +else +ifeq ($(call ld-ifversion, -ge, 225000000, y),y) +# Have the linker provide sfpr if possible. +# There is a corresponding test in arch/powerpc/lib/Makefile +KBUILD_LDFLAGS_MODULE += --save-restore-funcs +else +KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o +endif +endif ifeq ($(CONFIG_476FPE_ERR46),y) KBUILD_LDFLAGS_MODULE += --ppc476-workaround \ diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile index 0ca405a27ac1..2c56f4636c2b 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile @@ -11,12 +11,15 @@ CFLAGS_REMOVE_feature-fixups.o = $(CC_FLAGS_FTRACE) obj-y += string.o alloc.o code-patching.o feature-fixups.o -# 64-bit linker creates .sfpr on demand for final link (vmlinux), -# so it is only needed for modules. -obj-$(CONFIG_PPC32) += crtsavres.o -extra-$(CONFIG_PPC64) += crtsavres.o +obj-$(CONFIG_PPC32) += div64.o copy_32.o crtsavres.o -obj-$(CONFIG_PPC32) += div64.o copy_32.o +# See corresponding test in arch/powerpc/Makefile +# 64-bit linker creates .sfpr on demand for final link (vmlinux), +# so it is only needed for modules, and only for older linkers which +# do not support --save-restore-funcs +ifeq ($(call ld-ifversion, -lt, 225000000, y),y) +extra-$(CONFIG_PPC64) += crtsavres.o +endif obj64-y += copypage_64.o copyuser_64.o mem_64.o hweight_64.o \ copyuser_power7.o string_64.o copypage_power7.o memcpy_power7.o \