Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3132888ybt; Mon, 22 Jun 2020 16:07:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBs1FI1Xq+9XF3DijhppYvON2NmK4LnQzhg6mwm7ixrLkU4BR8Eizl6IvrMVND6YPY9Jnv X-Received: by 2002:a17:906:6686:: with SMTP id z6mr17193233ejo.258.1592867233042; Mon, 22 Jun 2020 16:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592867233; cv=none; d=google.com; s=arc-20160816; b=0a0UsLgZvij1feJYdmEtWctcd/4djNJa5rkQ5hjz55gPSBMPAshRsWfr473UQKoS49 YwqzGBJPMIhTNdUxnYoRqz4F8tcM4Ae4f+lvqi1XudHrat3PVHnbwb/ummD5a6lHzUpZ Sg1EuMvvQ0a4czUieAyQa04c8t69Ag3AnTXcjOX4rTQWECy0zTgxLEC+/hfZLS9gOBPg j3CA7HCbUgCAjwU3wtWMwA6eVD5+2YGn1EakLVh0bw1gXvvHVFZtSD0BAygyBLogKJud y9cq22/hh/TqCHJ5+Mw7vVzdISg8CGmH94i+oX04/BFuecCy7uyMEwdS8XEPu9MK8vGX +21g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=SzgCWMDg2RKJ2NhPQUi7yzswSotPjadK1/0BdT/7pNM=; b=KY9T2F4j6gmUQtfgfdCREZXEOK1pyTyitj2H8Gho87ZeLd2YvsX3JEvDzHVFnH3Cb7 akxgE6c/D+9oPs3CUxvOc+BYmTxaFUo6uywk5J/OzOrzSaH8AnekIMGZTkmrSRoyyyTZ 7Adnk9/TSxsoEUbqSMdUumureC/l1Op9q4/tQ/bD1V5jU8srTKtXJHqsA33LY4AJe+Ny woCsy6At/cb+cD6pIM5AuHtQt0y7Kk1xCBi5ju66m2oRIJojW2pcu+7fqjPNn6/iCT4d ZwHfo7c76DbwuKtkL0NxRRw/hID0nXDH7Gp5DqjrbOTz538pX2KaSn9xlCFrWn8C6de6 92Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CjobsTwj; 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 k6si10945057edv.190.2020.06.22.16.06.50; Mon, 22 Jun 2020 16:07:13 -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=CjobsTwj; 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 S1731444AbgFVXEW (ORCPT + 99 others); Mon, 22 Jun 2020 19:04:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731371AbgFVXEV (ORCPT ); Mon, 22 Jun 2020 19:04:21 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D36C1C061795 for ; Mon, 22 Jun 2020 16:04:20 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id j4so8250631plk.3 for ; Mon, 22 Jun 2020 16:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=SzgCWMDg2RKJ2NhPQUi7yzswSotPjadK1/0BdT/7pNM=; b=CjobsTwjEzfFB7mg3yto+C37iPxoADkBtXnwx5Zwh1qhWDXJI9D8xzTYannQoMeE59 wYG8uphNg+tfYmpQDrje8+ZiMkr9C6zDHh05LXr1dxnbGcD7rcatVqb208oPrAX1xxqB rMhirMwPU0VMi65dec2Qn/HinSWsI/vcDRVsMIGJs+5yaNri6IK5LoQwvGPcoK+2WLMn sqYEhxjSdosxf/hM9s6W6CVJJi/xnF0Je9pZD+TXn6ArUzc0GmkZz3Hco2I6Im31YEfK tis4ESU+TFUPNnp/+ik9M+TOUIBnySvS0k8SDIEYVkUGO+TUFQ8DH2mreAVwZRufQBL7 psPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=SzgCWMDg2RKJ2NhPQUi7yzswSotPjadK1/0BdT/7pNM=; b=p9j3kbyzt/c+S7+j4LrAxC0Ths/sF8IBW2TwgV8j2NoDry6Qbp/NJSp5viaQ0aTypy HAee+od4553f0ZV80FB9wp3oir1ysH00tAZkysaQCPhkgc7fZhgvAFcEOKFqUSvDgPbg rmwO6EkWrgl56JXgpXj3iq4oTkAGn8rdutD13rK8plRpaNPCcG54BHUo4FypPKLLrQYs Pjg14RUoVhUVn0oyQhGQOJ2hHF2EAKOXIyulkB2RJNuv2otDaBYXsvgknUUX+vhUUHIK 6lMvuBH3XPrN3KqJoOTRQnAkUYbAppQKgUfiQ5CU8NAVbArLrbGAfNGjdZzSi+jOxnUn anOw== X-Gm-Message-State: AOAM5336BNcZVz3Vple+f6Vqebn/fWK+DXV3vztROMGMK+KtGrH8j1JC KrrK6miMzAb6kSMiXJ7AG4nrUShpV0sGzrIhJcBI0g== X-Received: by 2002:a17:902:fe8b:: with SMTP id x11mr21225140plm.179.1592867060019; Mon, 22 Jun 2020 16:04:20 -0700 (PDT) MIME-Version: 1.0 References: <20200617210613.95432-1-ndesaulniers@google.com> <20200617212705.tq2q6bi446gydymo@google.com> In-Reply-To: <20200617212705.tq2q6bi446gydymo@google.com> From: Nick Desaulniers Date: Mon, 22 Jun 2020 16:04:07 -0700 Message-ID: Subject: Re: [PATCH] vmlinux.lds: consider .text.{hot|unlikely}.* part of .text too To: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Cc: Arnd Bergmann , clang-built-linux , Kees Cook , "# 3.4.x" , Jian Cai , Luis Lozano , Manoj Gupta , linux-arch , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 17, 2020 at 2:27 PM F=C4=81ng-ru=C3=AC S=C3=B2ng 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? 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=3D1084760 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/t= hird_party/toolchain-utils/compiler_wrapper/config.go;l=3D110 Looks like no. It doesn't use `-fno-unique-section-names` or `-ffunction-sections`. > > 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=3Dbinutils-gdb.git;a=3Dcommitdiff;h= =3Dadd44f8d5c5c05e08b11e033127a744d61c26aee > >Link: https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dcommitdiff;h= =3D1de778ed23ce7492c523d5850c6c6dbb34152655 > >Link: https://reviews.llvm.org/D79600 > >Reported-by: Jian Cai > >Debugged-by: Luis Lozano > >Suggested-by: F=C4=81ng-ru=C3=AC S=C3=B2ng > >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/vml= inux.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