From patchwork Thu Aug 11 10:16:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 9274981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9007560231 for ; Thu, 11 Aug 2016 10:17:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80591284DE for ; Thu, 11 Aug 2016 10:17:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74C3E285E9; Thu, 11 Aug 2016 10:17:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D0C3284DE for ; Thu, 11 Aug 2016 10:17:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752797AbcHKKRH (ORCPT ); Thu, 11 Aug 2016 06:17:07 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:36713 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750797AbcHKKRG (ORCPT ); Thu, 11 Aug 2016 06:17:06 -0400 Received: by mail-pa0-f68.google.com with SMTP id ez1so4543328pab.3; Thu, 11 Aug 2016 03:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uhfpcoZfpKWn1sEty1SnE9m6uG35R1B6vMZQrAY95UM=; b=iF4H/tG+1t+VRYTagVWNI/PljSfQKekjHLDxwk8Vc6MBTR2HKWKPPzFVj0m2aHtABz mAqk6xxY6hlZOY5mqE7eaMz1N/+oZTocgV9W1Lfx1T2t8Q7leFR2thwyMwmx1Q17DZ9e esMFtQHPfNF9V0CFQm7kXw4DqHHG3JDzc/bpwRm9IMJVVSbVHbK51eLH2ewt/JFY07aD HhixT8nFuTydMz5ANmg+Q1o+lX3wlOgLM7B8ww/Vqkf065qzKqemljNKhuF5AjpXZJfV 0a8fwcN48q8Lqo7clAz4Pd4FyX4XgyV9w2vjw68JTM+H5yXIkEzZ7zutuvqRYXw2qTXa qtPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uhfpcoZfpKWn1sEty1SnE9m6uG35R1B6vMZQrAY95UM=; b=D0sjncl6KYnvioB/Q9Ddp95qKrCMB5pODbE/fi59EVDNiRt3GAK8Vi1QD50POW8Pen mLyO9uCJH68T85G0YTUqevMxPdKeKIw6fObFBnBHwX625WkMbhfndkHH6L5Yte1u3HUr MfCbmZOlRbAYdRvNr3YB2ol1B06/vTGUtHvQjZPfenTPwy6lzjklKR2SAA1AXR5qLY7L 4+7v1SdOi9P56/LGtj4GK6ha2uP/tgeK6/EGB2c6VcIj3wLh2uvNPjm3+uDTekw7Unn7 dEw0lqwMTlQEyJDdMKn2taDNMxrfY7RrmX3ExdNg4K3iasZiTTjwLpDS+Gvb4jqWTPEO FOeA== X-Gm-Message-State: AEkoous57Y/TxdCnb8THENjBWwSfPUjUm1DFENwLZfhOZLzmp3u72fg0xupk/h/Qb0pcwA== X-Received: by 10.66.185.14 with SMTP id ey14mr15877278pac.71.1470910625925; Thu, 11 Aug 2016 03:17:05 -0700 (PDT) Received: from roar.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id ao6sm4028351pac.8.2016.08.11.03.17.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Aug 2016 03:17:05 -0700 (PDT) From: Nicholas Piggin To: linux-kbuild@vger.kernel.org Cc: Nicholas Piggin , linux-arch@vger.kernel.org, Michal Marek , Sam Ravnborg , Stephen Rothwell , Arnd Bergmann , Nicolas Pitre , Segher Boessenkool , Alan Modra Subject: [PATCH 3/6] kbuild: add arch specific post-link pass Date: Thu, 11 Aug 2016 20:16:17 +1000 Message-Id: <1470910580-18458-4-git-send-email-npiggin@gmail.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1470910580-18458-1-git-send-email-npiggin@gmail.com> References: <1470910580-18458-1-git-send-email-npiggin@gmail.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add an option for architectures to pass over modules after they are linked. powerpc will use this to check linker relocations for sanity, and possibly to fix up alternate instruction patch relocations. Signed-off-by: Nicholas Piggin --- Since v1, - Switched to a more flexible arch makefile invocation. - Provide a powerpc patch to use it to help existing build issue (rather than only justification being out-of-tree patch). Documentation/kbuild/makefiles.txt | 10 ++++++++++ arch/Kconfig | 7 +++++++ scripts/Makefile.modpost | 3 +++ scripts/link-vmlinux.sh | 4 ++++ 4 files changed, 24 insertions(+) diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 385a5ef..8581e38 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -41,6 +41,7 @@ This document describes the Linux kernel Makefiles. --- 6.8 Custom kbuild commands --- 6.9 Preprocessing linker scripts --- 6.10 Generic header files + --- 6.11 Post-link pass === 7 Kbuild syntax for exported headers --- 7.1 header-y @@ -1237,6 +1238,15 @@ When kbuild executes, the following steps are followed (roughly): to list the file in the Kbuild file. See "7.4 generic-y" for further info on syntax etc. +--- 6.11 Post-link pass + + CONFIG_BUILD_ARCH_POSTLINK can be selected in order to have + arch/?/Makefile.postlink invoked on vmlinux and module.ko + files after final link. + + For example, powerpc uses this to check relocations on the + linked vmlinux file. + === 7 Kbuild syntax for exported headers The kernel includes a set of headers that is exported to userspace. diff --git a/arch/Kconfig b/arch/Kconfig index fc3f9e1..3a36ea8 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -461,6 +461,13 @@ config CC_STACKPROTECTOR_STRONG endchoice +config BUILD_ARCH_POSTLINK + bool + help + Select this if the architecture wants to have a Makefile invoked + on modules and vmlinux after they are linked. The architecture + must provide arch/?/Makefile.postlink + config THIN_ARCHIVES bool help diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 1366a94..1acaa20 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -123,6 +123,9 @@ quiet_cmd_ld_ko_o = LD [M] $@ $(modules): %.ko :%.o %.mod.o FORCE $(call if_changed,ld_ko_o) +ifdef CONFIG_BUILD_ARCH_POSTLINK + $(Q)$(MAKE) -f $(srctree)/arch/$(SRCARCH)/Makefile.postlink $@ +endif targets += $(modules) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index f742c65..ec84b33 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -279,6 +279,10 @@ fi info LD vmlinux vmlinux_link "${kallsymso}" vmlinux +if [ -n "${CONFIG_BUILD_ARCH_POSTLINK}" ]; then + ${MAKE} -f ${srctree}/arch/${SRCARCH}/Makefile.postlink vmlinux +fi + if [ -n "${CONFIG_BUILDTIME_EXTABLE_SORT}" ]; then info SORTEX vmlinux sortextable vmlinux