Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp817851pxf; Thu, 1 Apr 2021 14:34:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHnS/xREit5Py/lSTm8XyYIhsQhEuAsmytuU5S/laPTZwbsATBHOMPwRt2Rqg8swY26YZo X-Received: by 2002:a05:6e02:152:: with SMTP id j18mr8449848ilr.302.1617312845450; Thu, 01 Apr 2021 14:34:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617312845; cv=none; d=google.com; s=arc-20160816; b=dSLKZLvm6KEsndsehIrXxz5iWlbhM+VVX8z40gzUS1FLKWX9bmSWOvHmNST+ZlChsu d4NYoicbJFGr1F1gudzAvQ18xAkxj1f4t5XawxC2kAgYtUczRng2IcfuuytWkIL0vIVF DDikpbQB7f19QjpOoueKSkSbQAGxphGaxyPNOBBNEIzJVdHiQyILdKpS9UnV75wUIftE l8ZOZdGE24hSmtr/2gZ+yWPMd9kOlM25U5wtR25yFNA3I4wT3xt+Nprl06dUhU/l6jGh MBNallwv2RXar/NGlbMhwz9PTp2c5p5t5eksqb2/0H4x4dFfLI4ef5IO3WmfFbWWr1L/ rCqA== 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=xUvZJIJIDadxvdRdsIrLgm58xD07+hDQPhDK3/jq060=; b=VTkbJYlKV8iKH0arh3uFit8JmIILdu7zo5vCpLRvNv2rmD5nCL2Yq0F4soODF6HRiC ZCJ+DyD5OThGG4qiGs/dnsobMabzjzVS+aggf94ACyHwd3Hw9JSnfXPV3JGIL/zwaozq 4QbycvTY1MNVzL3GaTFT1Lrl2rTmFMGP5VRO/AmhyLt2pkAT/ao4Bv78PH2smmAC73zG xKjsNjX0Ndj4EFXOAboT5tj7k3KY5B47UEo53iB3OxN8+5iN2o1AwD1fBSaUyoTu3cGF QZYhsoYKcRz7S7mzp5Mk5tztCPaIO13u2A0HEHfkPqbDT4cM6vM4oyIisflLeR5OZGGs 7nzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Pb4XR5Rn; 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 v6si6256278jas.90.2021.04.01.14.33.51; Thu, 01 Apr 2021 14:34:05 -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=Pb4XR5Rn; 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 S234366AbhDAVdY (ORCPT + 99 others); Thu, 1 Apr 2021 17:33:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233588AbhDAVdX (ORCPT ); Thu, 1 Apr 2021 17:33:23 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D85E9C0613E6 for ; Thu, 1 Apr 2021 14:33:23 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id x26so2397723pfn.0 for ; Thu, 01 Apr 2021 14:33:23 -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=xUvZJIJIDadxvdRdsIrLgm58xD07+hDQPhDK3/jq060=; b=Pb4XR5RnN4XMKGzkIgWEXnoYtI5TagectmXHpjbwn537UdwNgJo3v5MGsBRwkrWgsa y6gpKhupWAGktcfQ3o0VVgV3oftfdMP5Jn00nDFdExvtLoeGAUATsr/LZ2lDBiRVMOIJ rZgzXZH2bn1Hpubvk0B+mn4zoWR4+N9POAQF0= 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=xUvZJIJIDadxvdRdsIrLgm58xD07+hDQPhDK3/jq060=; b=hkLTys7rc89m1xxwAiQXyIzL9VqE8nghmhuAj1BYwjEhevMP0v9Ov3kyRItNQP81BH uB5sLh75lHbAYbRwBIhyP3f3WWFSHpnHiFBidh5NS2hIKPlhOy/8EsvNCKpQ4DHIk62z qEJWiTApfXS9emkHFT6MHZ6I/22CxF5Gc+CQ/ErpXKLbG2H6LrZvWbc1Cj+Up7nUMrmI 6ZaghH+Rw83p+/DKIMs1ahGb1VbpqPwKBbz064CAjJBRED91HZgIwiquWJmgwXCSEt3T HaxH4qoDmsHU7nY2Mix9sZ3ad68bvMJvVDAiQ66wmhnfmrMVi/YJdYOgk8HZyKwG7zd1 o0/w== X-Gm-Message-State: AOAM530zwQJdXzlfEksWTcoZWas1mRuc0Df19Wo1j4Sac49IA/AlFDZF U1RVDBsJM66EOsiZjjIagM1iIQ== X-Received: by 2002:a65:47ca:: with SMTP id f10mr9380550pgs.206.1617312803473; Thu, 01 Apr 2021 14:33:23 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q19sm6363000pff.91.2021.04.01.14.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 14:33:22 -0700 (PDT) Date: Thu, 1 Apr 2021 14:33:21 -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: <202104011433.48B4149E@keescook> References: <20210322234438.502582-1-seanjc@google.com> <202103311228.D42822B@keescook> 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 31, 2021 at 08:07:18PM +0000, Sean Christopherson wrote: > On Wed, Mar 31, 2021, Kees Cook wrote: > > 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? > > Yes? I'll ping you when I run into trouble ;-) Hm, I can't tell if any of these are duplicates: https://sourceware.org/bugzilla/buglist.cgi?bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=SUSPENDED&bug_status=WAITING&bug_status=REOPENED&component=ld&list_id=59962&product=binutils&query_format=advanced&short_desc=symbol&short_desc_type=allwordssubstr -- Kees Cook