Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3150959ybt; Mon, 22 Jun 2020 16:40:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8FwYSaFfRDfKGPjTvwk5CfiDva1/nbZYDXm5JUK0Hng+rlewhgz/WiMC3e/9P2Y6c3psE X-Received: by 2002:aa7:ccc2:: with SMTP id y2mr18821621edt.97.1592869233328; Mon, 22 Jun 2020 16:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592869233; cv=none; d=google.com; s=arc-20160816; b=c0tt2ONepeTxhMQ/mDYdKprkzry8VQW92rwvjeTBb+XsV98RnFIP2OLQS0XCWjJgOT /y8R/n+KLWrtb3HlAsiRBPIQ5Vu4S72QH/t6/zV7kurA/0/NDDvNcSuYx60iW17Y7nMO +LQwWYqBhuJ+d92Uang6CswqewCLbX4smmbTigRDpJnHHVx84nJa6qDh2dXSW0XtrV6i CWN6JX2px5YYYAkO+giSW0RBHFgljGsreWM9fd3SFz3ha+vdbaLv9UybPc2rchWkvUBu uMJV082f2VyxOfMRkd/UrjwSGDvo+JN4yhKVSQDB874lLJBUjaedAQCGt2yECKZQ1xWt netA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=8ffW2wUqNPKCctA4KQ6FwdGe8r/TZEjq1PeDi/0NFK0=; b=lnhNyceb/4LHTUi8lOtETmI6RPJ44KNXS4kMzFY6bAaerJbluuyPPi66/frN/2rP3E SG5MFtC4ZLJl2Nr+lV5ryS9klwcU2o7gIFAn4a9hxO1WVpDR73kxQxliGbbb67Q9jjrY ZpXMkpJ8BnwQqktEmNgjeWWiX8gMdReubd39SUc6DxPHWaNgT9ZZxEz9MGizxfw+70pQ QY3UGQs7S+ksLN/XY4rwY2mlk4YoDCOt+gT09UMfauDYYCygExiidd0rtg+7W5O/0rko Ir2qyr7DnOnN/+WAlXBteNpsOIeoRe4lQM9MDjQ0yXxO7Lh3fdKbhts2vp0s1NcDDSUP LtBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GlEhc70t; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q10si10410182edn.10.2020.06.22.16.40.10; Mon, 22 Jun 2020 16:40:33 -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=@google.com header.s=20161025 header.b=GlEhc70t; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731189AbgFVXPm (ORCPT + 99 others); Mon, 22 Jun 2020 19:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730985AbgFVXPl (ORCPT ); Mon, 22 Jun 2020 19:15:41 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9983C061573 for ; Mon, 22 Jun 2020 16:15:40 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id f9so299778pfn.0 for ; Mon, 22 Jun 2020 16:15:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=8ffW2wUqNPKCctA4KQ6FwdGe8r/TZEjq1PeDi/0NFK0=; b=GlEhc70tdhL49iFtKY6F5A2HLSZ6Nn50tCeFu2kaMvTNZM35VupKPqb8ILvJBqcgzD g9AunA0OO8zrexaCntdxguDr9bb9Un+Y/zuuICMSarL/X4zO8tworfy0xAL6E68lXQPW RpQ+mlpTtMYKExX9fEzesbuuB49zTy9mq0r5OTvCRLepMbClRi8zR+3Fz7mcD7rhY2tK bLW1N3EU/cObSf88kIGVdWPoMubg6fJx9cwGSMgFiSIGD5b5o059pCNobF5G7LSQIpXC CTQO71Wqk32OnnAcOyU3u6p8P7lwWEOTG6hdZbuj+tuUC8WQkQyP4wDweRvCCk4U4Ct8 JJoQ== 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:content-transfer-encoding :in-reply-to; bh=8ffW2wUqNPKCctA4KQ6FwdGe8r/TZEjq1PeDi/0NFK0=; b=XGBKZo1QO3V1FWOqenFSavmJ2/hBUXkbHG5mVjh5cDIEqBg3hr1c8q7doBZVO1wUyN qH1bvRJuLfOJ7ob85y4O8idtLkJnB4Ur04SHpn6WOof/Fi7Yi+JrABt/Tk4Stp/MnfJx YhVJ/D3Hp/qhx2DKTXjyPTIzxzGnwqHK2KeRG9A7l7nLhlgE5cxFOy5ttLPbXynC8Fvt Ty/JQQJvU1zcgPtoZNbv12WrhMpXSNaYbIkG0fCu9lGnoE80yf6kaVnas/Jj4+R7NRaP u6Ivtds4AES0GBF9cOkRvI4pWSq1U6EFXSuhXALZW9LBwwB775qGRHLuJWCDyh4vHLe7 UDFw== X-Gm-Message-State: AOAM531IW9mEr4Ffhvzr+ugHWBwGsaeZr5nBq5e8D5oThyEpyARyxCgs lKRxCfUic4pjVrVb9NTjkMda+Q== X-Received: by 2002:a63:4c48:: with SMTP id m8mr15136063pgl.290.1592867740181; Mon, 22 Jun 2020 16:15:40 -0700 (PDT) Received: from google.com ([2620:15c:2ce:0:9efe:9f1:9267:2b27]) by smtp.gmail.com with ESMTPSA id 6sm14829509pfi.170.2020.06.22.16.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 16:15:39 -0700 (PDT) Date: Mon, 22 Jun 2020 16:15:36 -0700 From: =?utf-8?B?RsSBbmctcnXDrCBTw7JuZw==?= To: Nick Desaulniers Cc: Arnd Bergmann , clang-built-linux , Kees Cook , "# 3.4.x" , Jian Cai , Luis Lozano , Manoj Gupta , linux-arch , LKML Subject: Re: [PATCH] vmlinux.lds: consider .text.{hot|unlikely}.* part of .text too Message-ID: <20200622231536.7jcshis5mdn3vr54@google.com> References: <20200617210613.95432-1-ndesaulniers@google.com> <20200617212705.tq2q6bi446gydymo@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-06-22, Nick Desaulniers wrote: >On Wed, Jun 17, 2020 at 2:27 PM Fāng-ruì Sòng wrote: >> >> >> On 2020-06-17, Nick Desaulniers wrote: >> >ld.bfd's internal linker script considers .text.hot AND .text.hot.* to >> >be part of .text, as well as .text.unlikely and .text.unlikely.*. >> >> >ld.lld will produce .text.hot.*/.text.unlikely.* sections. >> >> Correction to this sentence. lld is not relevant here. >> >> -ffunction-sections combined with profile-guided optimization can >> produce .text.hot.* .text.unlikely.* sections. Newer clang may produce >> .text.hot. .text.unlikely. (without suffix, but with a trailing dot) >> when -fno-unique-section-names is specified, as an optimization to make >> .strtab smaller. > >Then why was the bug report reporting https://reviews.llvm.org/D79600 >as the result of a bisection, if LLD is not relevant? Was the >bisection wrong? https://reviews.llvm.org/D79600 is an LLVM codegen change, unrelated to LLD.. (As described in the patch, LLD's -z keep-text-section-prefix only recognizes ".text.exit.*", not ".text.exit") >The upstream report wasn't initially public, for no good reason. So I >didn't include it, but if we end up taking v1, this should have > >Link: https://bugs.chromium.org/p/chromium/issues/detail?id=1084760 Thanks for making it public. >The kernel doesn't use -fno-unique-section-names; is that another flag >that's added by CrOS' compiler wrapper? >https://source.chromium.org/chromiumos/chromiumos/codesearch/+/master:src/third_party/toolchain-utils/compiler_wrapper/config.go;l=110 >Looks like no. It doesn't use `-fno-unique-section-names` or >`-ffunction-sections`. -fno-unique-section-names is a very rare option. It is not supported by GCC (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95095 ). clang users use it very rarely, probably because not many people care about additional strings taken by section names ".text.hot.a" ".text.hot.b" ".text.hot.c" in the string table ".strtab" (clang since some point of 2018 uses .strtab instead of .shstrtab which enables more string sharing). > > > >> >> We've already seen that GCC can place main in .text.startup without >> -ffunction-sections. There may be other non -ffunction-sections cases >> for .text.hot.* or .text.unlikely.*. So it is definitely a good idea to >> be more specific even if we don't care about -ffunction-sections for >> now. >> >> >Make sure to group these together. Otherwise these orphan sections may >> >be placed outside of the the _stext/_etext boundaries. >> > >> >Cc: stable@vger.kernel.org >> >Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=add44f8d5c5c05e08b11e033127a744d61c26aee >> >Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=1de778ed23ce7492c523d5850c6c6dbb34152655 >> >Link: https://reviews.llvm.org/D79600 >> >Reported-by: Jian Cai >> >Debugged-by: Luis Lozano >> >Suggested-by: Fāng-ruì Sòng >> >Tested-by: Luis Lozano >> >Tested-by: Manoj Gupta >> >Signed-off-by: Nick Desaulniers >> >--- >> > include/asm-generic/vmlinux.lds.h | 4 +++- >> > 1 file changed, 3 insertions(+), 1 deletion(-) >> > >> >diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h >> >index d7c7c7f36c4a..fe5aaef169e3 100644 >> >--- a/include/asm-generic/vmlinux.lds.h >> >+++ b/include/asm-generic/vmlinux.lds.h >> >@@ -560,7 +560,9 @@ >> > */ >> > #define TEXT_TEXT \ >> > ALIGN_FUNCTION(); \ >> >- *(.text.hot TEXT_MAIN .text.fixup .text.unlikely) \ >> >+ *(.text.hot .text.hot.*) \ >> >+ *(TEXT_MAIN .text.fixup) \ >> >+ *(.text.unlikely .text.unlikely.*) \ >> > NOINSTR_TEXT \ >> > *(.text..refcount) \ >> > *(.ref.text) \ >> >-- >> >2.27.0.290.gba653c62da-goog >> > > > > >-- >Thanks, >~Nick Desaulniers