From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48A9AC4320A for ; Thu, 19 Aug 2021 02:42:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24EBB60C40 for ; Thu, 19 Aug 2021 02:42:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235768AbhHSCm5 (ORCPT ); Wed, 18 Aug 2021 22:42:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235670AbhHSCm4 (ORCPT ); Wed, 18 Aug 2021 22:42:56 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1E01C061764 for ; Wed, 18 Aug 2021 19:42:20 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id r2so4445704pgl.10 for ; Wed, 18 Aug 2021 19:42:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kTQ3kRPj8CF2wk5bsK7dVYrKndPpuEnS1MQvOqgpp64=; b=Wz3kuq+TUag7kDt/E9j8i7P+9Bx+a6aG1BBw1BnUCzHroMbRqHRUr/cQn8D+IO2N31 bzc40Y2o7mBlA6ZRu5vhA/Pa7jhkjf82qaTe8IlDCHf8qDDp6q32lbmIaljMPJxeJmyG KAv1uDBX3Jd8Csj/rOS7GbocfpwMk8x8BaT0M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kTQ3kRPj8CF2wk5bsK7dVYrKndPpuEnS1MQvOqgpp64=; b=sBuity52zySClTrb3XdFCb3lrfmzOyH1jmjqW6IgauDfvfca+aoN7n902E3Gumn9gI 3ssutBvk1r1JBtDZn+J6617jNjnZeeXqqeZ60F6ND1ZxgB0kYIpM1K2PDqI7zWgrHi48 TDkhd8kN6A+l8e0YkFKQzIoe6yebQM8XK/NmyptJ2wBEkymMK/benV+ZwqzmV5NDkPJq 7Y07P9kkYaZuCGmx4kL/BVPmTzZ/dag2UQcFPnqlRRl/io713gMgCQUcexJUq+G8VkAg K0aGNdginuo8UroEl1BwTYOmybh1+f/MuosypEPwdzIFhcO9wPUnPOJziIsANPEPXcY2 E9Ew== X-Gm-Message-State: AOAM532O0CEfhQZnB6Bl5e+J6jYRKMJmhr8QjTQT0L9JJ6MfdWbjaDci ej8ET5J6v2//oYjve7q5JiEOeg== X-Google-Smtp-Source: ABdhPJzum0y4eTNHGP90rMiqwDF1/sXCjz+5QWRP2pZ3QU2uU9BcbSyELVQc1NkDmxDol0pCo7hqhw== X-Received: by 2002:a05:6a00:2309:b0:3e1:e727:ec68 with SMTP id h9-20020a056a00230900b003e1e727ec68mr12339527pfh.26.1629340940413; Wed, 18 Aug 2021 19:42:20 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c196sm1330861pga.92.2021.08.18.19.42.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 19:42:19 -0700 (PDT) Date: Wed, 18 Aug 2021 19:42:18 -0700 From: Kees Cook To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, Sami Tolvanen , linux-kernel@vger.kernel.org, Michal Marek , Nathan Chancellor , Nick Desaulniers , clang-built-linux@googlegroups.com Subject: Re: [PATCH 06/13] kbuild: merge vmlinux_link() between the ordinary link and Clang LTO Message-ID: <202108181940.896CA4311@keescook> References: <20210819005744.644908-1-masahiroy@kernel.org> <20210819005744.644908-7-masahiroy@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210819005744.644908-7-masahiroy@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 19, 2021 at 09:57:37AM +0900, Masahiro Yamada wrote: > When Clang LTO is enabled, vmlinux_link() reuses vmlinux.o instead of > linking ${KBUILD_VMLINUX_OBJS} and ${KBUILD_VMLINUX_LIBS} again. > > That is the only difference here, so merge the similar code. Oh excellent! I had tried to get this merged before and was not happy with anything I constructed. This is much cleaner. Nice! (I think I didn't realize there could be an empty --start-group/--end-group with no side-effects.) Reviewed-by: Kees Cook -Kees > > Signed-off-by: Masahiro Yamada > --- > > scripts/link-vmlinux.sh | 30 ++++++++++++++---------------- > 1 file changed, 14 insertions(+), 16 deletions(-) > > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh > index 36ef7b37fc5d..a6c4d0bce3ba 100755 > --- a/scripts/link-vmlinux.sh > +++ b/scripts/link-vmlinux.sh > @@ -154,12 +154,23 @@ vmlinux_link() > local objects > local strip_debug > local map_option > + local objs > + local libs > > info LD ${output} > > # skip output file argument > shift > > + if [ -n "${CONFIG_LTO_CLANG}" ]; then > + # Use vmlinux.o instead of performing the slow LTO link again. > + objs=vmlinux.o > + libs= > + else > + objs="${KBUILD_VMLINUX_OBJS}" > + libs="${KBUILD_VMLINUX_LIBS}" > + fi > + > # The kallsyms linking does not need debug symbols included. > if [ "$output" != "${output#.tmp_vmlinux.kallsyms}" ] ; then > strip_debug=-Wl,--strip-debug > @@ -170,22 +181,9 @@ vmlinux_link() > fi > > if [ "${SRCARCH}" != "um" ]; then > - if [ -n "${CONFIG_LTO_CLANG}" ]; then > - # Use vmlinux.o instead of performing the slow LTO > - # link again. > - objects="--whole-archive \ > - vmlinux.o \ > - --no-whole-archive \ > - ${@}" > - else > - objects="--whole-archive \ > - ${KBUILD_VMLINUX_OBJS} \ > - --no-whole-archive \ > - --start-group \ > - ${KBUILD_VMLINUX_LIBS} \ > - --end-group \ > - ${@}" > - fi > + objects="--whole-archive ${objs} --no-whole-archive \ > + --start-group ${libs} --end-group \ > + $@" > > ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \ > ${strip_debug#-Wl,} \ > -- > 2.30.2 > -- Kees Cook