From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-2.4 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FSL_HELO_FAKE, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id AA6731F8C6 for ; Fri, 6 Aug 2021 07:21:47 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9355F384801C for ; Fri, 6 Aug 2021 07:21:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9355F384801C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628234506; bh=rOjSxsHHckz6/JZNpfjhpfmY3/UsX+ygwsQ6pgmLcig=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=QwYeOC63TulmoEteUOm80XLgmZj4m1Y+uB/RIMkTIyX4BPEWW4XaVrB+PtjcNfPus T5bkyTmcOnBS25WhutISL/F31ma5IoE8bDj3SNyquvfyh2pLFUSKdZnY7Eg8oz6KDL wmLc3eC0BH1S9aTZyvnI+BQryezXQlk4YuZBQKDk= Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id B321B384801C for ; Fri, 6 Aug 2021 07:21:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B321B384801C Received: by mail-pj1-x1035.google.com with SMTP id mz5-20020a17090b3785b0290176ecf64922so21195594pjb.3 for ; Fri, 06 Aug 2021 00:21:26 -0700 (PDT) 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=rOjSxsHHckz6/JZNpfjhpfmY3/UsX+ygwsQ6pgmLcig=; b=NpUEOy0rv5ZCj+VpwYMnYY920MWYlC7FfJqkfIYSdSTNjT7hgqwi8xxpEj7eQeROfU 6YMQxI4O84InMEf2gD+mGH41K7guJKOttET8ckKCYKNmZrh3u/NAMKxKaaoRs7mDaX6c vS3lEIgqSeHmFIsj7m5l9A4rewhkPAIyU0uOhJXSc88QaNRMLyc+lndjM47Qq5bKtsbv VdWqMAjcAiVpXU327pBT1jfR5WfdtBXD8dRMCnjJSzY7V5/4Pcf8WQUVTAlp7YJdikzm yaO69/qwCkbE8Kz4w5hUqUVH6ubYctqMqrL6N1+s6csjPIPRoL8Cy++oXhy0YAHRoJs3 uj6A== X-Gm-Message-State: AOAM531WWIozcPjhm6koxgi9t+gG4KckuBBn/4z24m+NW1kn/30fdPxn h6j4ysTGHNt//h0QU2k4bvyM99OmiHk0KA== X-Google-Smtp-Source: ABdhPJxlYZCVUZR1znAXu9K06lP82NLshwMzpJKxrs5ns+F84UyUFnZqE6ba3tUi77qkdyC3bmIupg== X-Received: by 2002:a17:90a:7384:: with SMTP id j4mr5370891pjg.153.1628234485725; Fri, 06 Aug 2021 00:21:25 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:6668:5d25:689f:8ff1]) by smtp.gmail.com with ESMTPSA id w9sm9064702pfg.151.2021.08.06.00.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Aug 2021 00:21:25 -0700 (PDT) Date: Fri, 6 Aug 2021 00:21:21 -0700 To: "H.J. Lu" Subject: Re: [PATCH v3] Use __executable_start as the lowest address for profiling [BZ #28153] Message-ID: <20210806072121.ses46tnfp2tirn2m@google.com> References: <20210805120904.3528530-1-hjl.tools@gmail.com> <20210806001609.x5q2zkhoo7xeaf3c@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210806001609.x5q2zkhoo7xeaf3c@google.com> X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Fangrui Song via Libc-alpha Reply-To: Fangrui Song Cc: libc-alpha@sourceware.org Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On 2021-08-05, Fangrui Song wrote: > >On 2021-08-05, H.J. Lu via Libc-alpha wrote: >>Glibc assumes that ENTRY_POINT is the lowest address for which we need >>to keep profiling records and BFD linker uses a linker script to place >>the input sections. >> >>Starting from GCC 4.6, the main function is placed in .text.startup >>section and starting from binutils 2.22, BFD linker with >> >>commit add44f8d5c5c05e08b11e033127a744d61c26aee >>Author: Alan Modra >>Date: Thu Nov 25 03:03:02 2010 +0000 >> >> * scripttempl/elf.sc: Group .text.exit, text.startup and .text.hot >> sections. >> >>places .text.startup section before .text section, which leave the main >>function out of profiling records. >> >>Starting from binutils 2.15, linker provides __executable_start to mark >>the lowest address of the executable. Use __executable_start as the >>lowest address to keep the main function in profiling records. This fixes >>[BZ #28153]. >> >>Tested on Linux/x86-64, Linux/x32 and Linux/i686 as well as with >>build-many-glibcs.py. >>--- >>csu/gmon-start.c | 10 +++++++++- >>gmon/tst-gmon-gprof.sh | 2 ++ >>gmon/tst-gmon-static-gprof.sh | 2 ++ >>3 files changed, 13 insertions(+), 1 deletion(-) > >LGTM [I had not subscribed the list until few days ago] Comment to v2: gold/ld.lld don't necessarily place .text.unlikely before other text sections. GNU ld's fixed section ordering may make certain optimization difficult. RISC architectures typically create range extension thunks to overcome the limitation of short range branches. Hot code can usually be moved to the middle to increase the chance that one range extension thunk can be shared by more code. 8MiB cold 2MiB hot 8MiB cold ( .text.sorted.* is a recent addition emulation link-time layout for improving instruction cache and TLB. An optimized case may require the sections to be interleaved with others.)