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=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,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 14B30C43461 for ; Wed, 31 Mar 2021 19:31:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E97F861075 for ; Wed, 31 Mar 2021 19:31:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235985AbhCaTag (ORCPT ); Wed, 31 Mar 2021 15:30:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235186AbhCaTa0 (ORCPT ); Wed, 31 Mar 2021 15:30:26 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6164EC061574 for ; Wed, 31 Mar 2021 12:30:26 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id i6so42753pgs.1 for ; Wed, 31 Mar 2021 12:30:26 -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=w3ch1ntrOHueZWUkcKNLTeORdSBJtecK/4DUp+1n9aE=; b=E3OLd99VpT4u9uxlgAdY8lp+qB3qAeNVbSXAbBIesm40tpDnv0YsgA1kLrgnXR1vYf LATRcE3Z9N5RL+x+ZPnGkC6Q3ph+DVjxsFm8+9qGK3XA4QipYg9biR49RE+y5WosO5hC R3/Xrb9xzjVIzdHZIssuqJ5siiMYMz16XEDN0= 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=w3ch1ntrOHueZWUkcKNLTeORdSBJtecK/4DUp+1n9aE=; b=Iv0By8qMT3RW2j/3pFEjfkjwunvRBVwbXN3h9B46xqhVGRJk4CmXdhctyVZzCTBj0W MGO6Jei7y+vbnHMs+myghuQstAmMKcCll5CkqPKiDrM+imCKk4d39qaEEAk72XfwUIGh dsQh8EVO2gY55J3a1e2e/uyiqj0awnfKHJFDQrIj3/oisNhUaQumnhrLMkc+hAY/yHKq BOEs/+E/i0kcG+ZqtmM/7WhGsHJUf4eWeZhqbtvoUhS5sB8naF/Z8rSJ0OqTQTHPIiid 0dAtVx/aix8OZUyhc95DY2Vj2VjTMwYCjpV1f1l9Q46XE4z6g1wo7sdqzRhNHUqq4wgK S42g== X-Gm-Message-State: AOAM531OKf1znHbynCmnJoCjVwo6t0ca6ctfp1V72inycHblloGqeDfZ /JbIO3CmY2p5H6LjsLifhljeaA== X-Google-Smtp-Source: ABdhPJyzFBVCThCNfq8Hn6/CzwwhqkWlUSNYPyroZXPxrTF/w1dzSr3rvrDj7ocbfB7nuoUukiUXng== X-Received: by 2002:a62:1c8f:0:b029:209:7eb2:748f with SMTP id c137-20020a621c8f0000b02902097eb2748fmr4444943pfc.79.1617219025781; Wed, 31 Mar 2021 12:30:25 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id r9sm3302345pgg.12.2021.03.31.12.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 12:30:25 -0700 (PDT) Date: Wed, 31 Mar 2021 12:30:24 -0700 From: Kees Cook To: Sean Christopherson Cc: Sami Tolvanen , Fangrui Song , Masahiro Yamada , Michal Marek , Nathan Chancellor , Nick Desaulniers , linux-kbuild , LKML , clang-built-linux Subject: Re: [PATCH] kbuild: Merge module sections if and only if CONFIG_LTO_CLANG is enabled Message-ID: <202103311228.D42822B@keescook> References: <20210322234438.502582-1-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 24, 2021 at 10:45:36PM +0000, Sean Christopherson wrote: > On Tue, Mar 23, 2021, Sami Tolvanen wrote: > > On Tue, Mar 23, 2021 at 9:36 AM Sean Christopherson wrote: > > > > > > On Tue, Mar 23, 2021, Sami Tolvanen wrote: > > > > On Mon, Mar 22, 2021 at 4:44 PM Sean Christopherson wrote: > > > > > > > > > > Merge module sections only when using Clang LTO. With gcc-10, merging > > > > > sections does not appear to update the symbol tables for the module, > > > > > e.g. 'readelf -s' shows the value that a symbol would have had, if > > > > > sections were not merged. > > > > > > > > I'm fine with limiting this to LTO only, but it would be helpful to > > > > understand which sections are actually getting merged here. > > > > > > It doesn't appear to matter which sections get merged, the tables only show the > > > correct data if there is no merging whatsoever, e.g. allowing merging for any > > > one of the four types (.bss, .data, .rodata and .text) results in breakage. > > > AFAICT, merging any sections causes the layout to change and throw off the > > > symbol tables. > > > > Thanks for the clarification. I can reproduce this issue with gcc + > > bfd if any of the sections are merged, but gcc + lld produces valid > > symbol tables. > > FWIW, clang + bfd also produces mangled tables, so it does appear to be bfd > specific. Are you able to open a bug against bfd for this? > > Perhaps someone more familiar with bfd can comment on whether this is > > a bug or a feature, and if there's a flag we can pass to bfd that > > would fix the issue. In the meanwhile, this patch looks like a > > reasonable workaround to me. > > > > Reviewed-by: Sami Tolvanen > > Tested-by: Sami Tolvanen Thanks, I'll get this sent to Linus. -- Kees Cook