Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp654979pxf; Wed, 31 Mar 2021 12:32:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsBYCHSuX4UupYuN0HLPeLckwZDittnK0dGTKtfDDCnxbIKY5Sv0QencNAckzvr/Hd6o0E X-Received: by 2002:a50:fa42:: with SMTP id c2mr5790899edq.159.1617219165598; Wed, 31 Mar 2021 12:32:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617219165; cv=none; d=google.com; s=arc-20160816; b=sGWJ9eHuCGgsJJYYDiDkBRNs7Wk0fN2m56/v7hbPilNN6qPaU6MIu5PYrP6qHiE8bw 4OpU5qzBGf3wDrKG8Ukc6S0mp2pPbBuytIygjfT4631k0q4gV0q0SWYJW+Sm9wjtnhFJ ycg3jN5FYf8ggSg8cbqts67DfPbBwYaosWOkRVLHdlM01MLqsclY5p9mGkkVhNfy1J/c L5mosvFBAgLJwJ7FLKlyALSyr+YiTKpMH5wBeI56ycKsd03gaoUsjgGau3Bo4F+YswJ6 sgua5DnPgbi1zVGeENCZ/YAd8TIdxEADFDmf2O8l7Ygo3zmBmVSDbpCHSf4Yp6WS70S0 GfLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=w3ch1ntrOHueZWUkcKNLTeORdSBJtecK/4DUp+1n9aE=; b=NgYO1hen0sSFXGfQzZxGLitJGhKuGil7pPP02m47+ekLRwg9iWaWE/wiTtrPr/cNqY HbgQzmhg0LbQuAeRm6k3EZ6OSGg8qUBLQEW03HoVGY1eb75f47OQ7V1bDkgy9QJEKfIy e+q3pu6yO+DYtEjL8xtE99jR4+VRmiTG8g95Zql0k+3A3DeCwEJ0mZm3vwYZVSurmzgR nOCca1J2qQIr8zgaeeUY0wSQx/HksU9mZDwzuc5kVzAGvreUKvB0C2QY8PiGEGj06rTF l4IKg3AspVFklzxWejgvK4U3RDI6hZOajsHp5Uxe3s38uRP1Hh5XuQPsfrM+1w5nYoNW USUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E3OLd99V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 39si2553644edq.111.2021.03.31.12.32.21; Wed, 31 Mar 2021 12:32:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E3OLd99V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235876AbhCaTae (ORCPT + 99 others); Wed, 31 Mar 2021 15:30:34 -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-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