From patchwork Fri Apr 20 07:34:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10351973 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 58C86602B7 for ; Fri, 20 Apr 2018 07:34:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 476512823D for ; Fri, 20 Apr 2018 07:34:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BF73286A1; Fri, 20 Apr 2018 07:34:45 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 CBD5A2823D for ; Fri, 20 Apr 2018 07:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753987AbeDTHeo (ORCPT ); Fri, 20 Apr 2018 03:34:44 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:35383 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753980AbeDTHem (ORCPT ); Fri, 20 Apr 2018 03:34:42 -0400 Received: by mail-pl0-f67.google.com with SMTP id w21-v6so4780715plq.2; Fri, 20 Apr 2018 00:34:42 -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=Gw0UjFLcTUpg8hQVAv/zAKgNhbsY1GJyxLZKuzP31Fo=; b=aUlJGVTtEix/uGglamL1huxFiXHTsA8Pwk3dQz0haAOF8PsTC3cihjFlKI3m7lWoSz Y1ISrZfbbdZN/PbOmywknPsv7RBy/zQPBVJEuhr1tfsxyvGk74F4pzhI6xSuOueT8FBn /nbhaItSG5N4hHBZ/abINg7d0fi9eXAUZXKmvFgzFXZsWr87KoKsbukElv6ukjXfGBMj qFimMMkYlatNyb+xQiYU93URS9p2clp+NEeyfWaLyBr+/B1VhacxiLaMCNvz7dxgEbai e3PZnmfug4JGijt0IxHxpx1lHBEY+BAmgu6dwOkAooNk9PTw5fmuRZKuYZqoLsYSUpkj qpHg== 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=Gw0UjFLcTUpg8hQVAv/zAKgNhbsY1GJyxLZKuzP31Fo=; b=D1XD3+qpDDbLsbNPb7oUw5FHAl66mLcGGKVfb/Q9NjX+yV27HWURM9clbvKqbFVK8G MayTozrd4dO/InjPD5IMIRfk1DCxmyRFngIQ3UpgDrtoE0k1go8knnQZVzf9054qyYq/ AXzmZX4usu69t5jO70mxsa6q7zSz2cNyaWTrlx9wdWEipYnjpZrzt6tYyl0kCkx57B+p Qj4b5ytuTEtK1aLofE3I8awL8Wg4VXn631eF6aHXCq/P3/YOFCoi2vF1huWwGzFlO+Gc A2ZF7xkaQckMOMpDcQI7OS9AlmIDRwOuyiwNjcsRlEcwgpl48iZkaRkRjaDsgGqt3mVb EKUg== X-Gm-Message-State: ALQs6tBXgm/vIC1F68W4DnWk9n7+5kGp2a9fv2KKPo+WnjvRZf5UUbFW 3vNe6sRy3sxxjU5DbKJMS5Wr7g== X-Google-Smtp-Source: AIpwx4+XsUqzP675PZdSW9KgbVWMDmYzi34m18fNk4XpmPsUzbyP//4WeQ0mmegd4YLedjRHFFrJ1Q== X-Received: by 2002:a17:902:a58a:: with SMTP id az10-v6mr185763plb.210.1524209682311; Fri, 20 Apr 2018 00:34:42 -0700 (PDT) Received: from roar.au.ibm.com (59-102-70-78.tpgi.com.au. [59.102.70.78]) by smtp.gmail.com with ESMTPSA id v15sm12568724pfa.116.2018.04.20.00.34.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 00:34:41 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Cc: Nicholas Piggin , linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, Christophe Leroy , Nicolas Pitre Subject: [PATCH 3/4] kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if enabled Date: Fri, 20 Apr 2018 17:34:13 +1000 Message-Id: <20180420073414.23169-4-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180420073414.23169-1-npiggin@gmail.com> References: <20180420073414.23169-1-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 Architectures that are capable can select HAVE_LD_DEAD_CODE_DATA_ELIMINATION to enable selection of that option (as an EXPERT kernel option). Signed-off-by: Nicholas Piggin --- arch/Kconfig | 15 --------------- init/Kconfig | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 8e0d665c8d53..3234b73d4626 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -596,21 +596,6 @@ config CC_STACKPROTECTOR_AUTO endchoice -config LD_DEAD_CODE_DATA_ELIMINATION - bool - help - Select this if the architecture wants to do dead code and - data elimination with the linker by compiling with - -ffunction-sections -fdata-sections and linking with - --gc-sections. - - This requires that the arch annotates or otherwise protects - its external entry points from being discarded. Linker scripts - must also merge .text.*, .data.*, and .bss.* correctly into - output sections. Care must be taken not to pull in unrelated - sections (e.g., '.text.init'). Typically '.' in section names - is used to distinguish them from label names / C identifiers. - config HAVE_ARCH_WITHIN_STACK_FRAMES bool help diff --git a/init/Kconfig b/init/Kconfig index f013afc74b11..1706d963766b 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1038,6 +1038,33 @@ config CC_OPTIMIZE_FOR_SIZE endchoice +config HAVE_LD_DEAD_CODE_DATA_ELIMINATION + bool + help + This requires that the arch annotates or otherwise protects + its external entry points from being discarded. Linker scripts + must also merge .text.*, .data.*, and .bss.* correctly into + output sections. Care must be taken not to pull in unrelated + sections (e.g., '.text.init'). Typically '.' in section names + is used to distinguish them from label names / C identifiers. + +config LD_DEAD_CODE_DATA_ELIMINATION + bool "Dead code and data elimination (EXPERIMENTAL)" + depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION + depends on EXPERT + help + Select this if the architecture wants to do dead code and + data elimination with the linker by compiling with + -ffunction-sections -fdata-sections, and linking with + --gc-sections. + + This can reduce on disk and in-memory size of the kernel + code and static data, particularly for small configs and + on small systems. This has the possibility of introducing + silently broken kernel if the required annotations are not + present. This option is not well tested yet, so use at your + own risk. + config SYSCTL bool