From patchwork Wed May 9 13:00:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10389387 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 E22C560153 for ; Wed, 9 May 2018 13:00:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3EC328F90 for ; Wed, 9 May 2018 13:00:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7E6528FC2; Wed, 9 May 2018 13:00:29 +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 60B8128FAE for ; Wed, 9 May 2018 13:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934955AbeEINA1 (ORCPT ); Wed, 9 May 2018 09:00:27 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34253 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934875AbeEINAY (ORCPT ); Wed, 9 May 2018 09:00:24 -0400 Received: by mail-pf0-f193.google.com with SMTP id a14so25617264pfi.1; Wed, 09 May 2018 06:00:24 -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=VDxas++A2Za4ndYrPo7i+8V2RK1x8OHkschcnFC6Q7eia0gslQE5KWyrSpVrcuDtQX 5O6JPT9V4jEwV5tXHtDdI3v0df9j0mpqPfo8Pn5E1J2FYL2lsNhoBibdi54xBTeaDE+C e5V47qhhGOB1T2WBPQEJmnzhTaJCdrUhh0uiZ4czg2nBJ68woUrkEx6DiyoNoCah68gg V5Sy8CRziuhCS10o5SMowc9VZqd92pnnUiCoSSppsWZpp+WfK4dji8J/ZKkoQQMEXYu1 tPu8bOTqP8Mll2MdNebYJ+VjtBog0h2NqnnclJhecNiz05n/CQarlTU5rXEHxGxS0ZQ9 rU/Q== 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=H6gbJY7QEBmmh9RCB4ZFoC7oD8+zsbmMVmlexwF/++XdXLE9T7Rnwm9dYgBH6cooID TMDH99OqIJYV9/kIcCAJ/jbXceN/sDbhgqWB3PjMcSx3QrXYr1a6nhL05sOXnJ5ef4mB aVDC3NcHpvnnzYl4Q3CPuZ953tHLAIaTnpAqk0wNCXHPFOMIDaafKMq396KHuabWFvbu o2g03swXdSG8Zib/b9nWygUX3YqwjBZpOhQRily2Q2xX7PX8+ocHNMDdKLv9V+YV0rQo saC4hUt8oFzhkCfiSztK/JoDFERbRk+sdx4JvwNJYia8SnDcVKvZBt8FJfub+8MIl60c Pq6A== X-Gm-Message-State: ALQs6tDN6W7JlMT2SmVPP+vk+WV5EXh1MzrPPEff3SDF9uAabaAGV6+Y FhOe3/tYdqdyjUjeZlTszigGFA== X-Google-Smtp-Source: AB8JxZrfembWEz0+Q4FKxlvnOf1QbQLpS4ZKHoTRP5CRUCXAnqaRsIVXx0MLVryHDhAHV3dPx8ftoQ== X-Received: by 2002:a65:5b4a:: with SMTP id y10-v6mr36241557pgr.243.1525870823834; Wed, 09 May 2018 06:00:23 -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 u4-v6sm4271184pgn.10.2018.05.09.06.00.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 06:00:22 -0700 (PDT) From: Nicholas Piggin To: Masahiro Yamada Cc: Nicholas Piggin , linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 3/4] kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if enabled Date: Wed, 9 May 2018 23:00:00 +1000 Message-Id: <20180509130001.24276-4-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180509130001.24276-1-npiggin@gmail.com> References: <20180509130001.24276-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