From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by sourceware.org (Postfix) with ESMTPS id 452643851C31 for ; Fri, 6 Aug 2021 00:16:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 452643851C31 Received: by mail-pj1-x1033.google.com with SMTP id t7-20020a17090a5d87b029017807007f23so15804364pji.5 for ; Thu, 05 Aug 2021 17:16:15 -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=+OxAriTt9Zg7YeMmWjg9hqwBVj3TpF22l70XlDwOKt8=; b=eSUOewpgAsk/bMvGqPkeQcHO/S9matV4ZQm0uiA38LlDKgZQD6OcXXzMOW0j0JQRB9 1h++PZ7dhGC3joaCBAc1FDx1VhI9pwXmN5o2tB8zPZ1FIGuTtHj5mT6tgKE8UdJPX9hf eK77bPTadK9TXOjmEdRU+cgv8w86jRj7YWO2YVA8bNT2f75blFY5yslzrATy3KOesHSK I4krgjon3GzcX1Qjoqbgx5SgSWxFDGOcJQk05YMCDjKRX6TIMnGwOOeH1OrORc3IOQuh AKr80eDVyg1sbUq8KiI1z2H/PsC6zIoMMiVo5yqPur2y5roiogN4V2ymvdMa9QTcrQkd ZPfw== X-Gm-Message-State: AOAM533hSGmce/cfM4WNYcWQP5AeRsji3RPKrL4dDwrOELm90ZH86k6a EElBsBqFk2YuRRLy/iq9hmi3xA== X-Google-Smtp-Source: ABdhPJwWVAoqwkyaT095nZd+9dhOW/Ko+D2znXzXuUs12ftfOGcT7UFsaXe2sgSMDhgE9l2K18l5fA== X-Received: by 2002:a05:6a00:16d6:b029:32a:ffe9:76a with SMTP id l22-20020a056a0016d6b029032affe9076amr7861321pfc.60.1628208974211; Thu, 05 Aug 2021 17:16:14 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:6668:5d25:689f:8ff1]) by smtp.gmail.com with ESMTPSA id y139sm8102189pfb.107.2021.08.05.17.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Aug 2021 17:16:13 -0700 (PDT) Date: Thu, 5 Aug 2021 17:16:09 -0700 From: Fangrui Song To: "H.J. Lu" Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v3] Use __executable_start as the lowest address for profiling [BZ #28153] Message-ID: <20210806001609.x5q2zkhoo7xeaf3c@google.com> References: <20210805120904.3528530-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210805120904.3528530-1-hjl.tools@gmail.com> X-Spam-Status: No, score=-17.3 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, FSL_HELO_FAKE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Fri, 06 Aug 2021 00:16:17 -0000 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