From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cluster-j.mailcontrol.com (cluster-j.mailcontrol.com [85.115.54.190]) by sourceware.org (Postfix) with ESMTPS id 880EA3858409 for ; Tue, 30 Nov 2021 07:17:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 880EA3858409 Received: (from mailcontrol@localhost) by rly15j.srv.mailcontrol.com (MailControl) with ESMTP id 1AU7HGUI021631 for libc-help@sourceware.org; Tue, 30 Nov 2021 07:17:16 GMT Received: from rly15j.srv.mailcontrol.com (localhost [127.0.0.1]) by localhost (envelope-sender Christian.Weiss@EMEA.NEC.COM) (MIMEDefang) with ESMTP id 1AU7H5pm017243 (TLS bits=256 verify=NO) for libc-help@sourceware.org; Tue, 30 Nov 2021 07:17:16 +0000 (GMT) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by rly15j.srv.mailcontrol.com (MailControl) id 1AU7H5qF017234 for ; Tue, 30 Nov 2021 07:17:05 GMT Received: from mail2.neceur.com ([195.47.207.4]) by rly15j-eth0.srv.mailcontrol.com (envelope-sender ) (MIMEDefang) with ESMTP id 1AU7H5Ks012129 (TLS bits=256 verify=NO) for ; Tue, 30 Nov 2021 07:17:05 +0000 (GMT) Received: from intmail1.neceur.com (intmail1.neceur.com [172.29.14.11]) by mail2.neceur.com (8.15.2/8.15.2/SUSE Linux 0.8) with ESMTP id 1AU7GTqH015569 for ; Tue, 30 Nov 2021 07:16:29 GMT Received: from av1.neceur.com (av1.neceur.com [172.29.14.21]) by intmail1.neceur.com (8.14.7/8.14.7) with ESMTP id 1AU7G2De018090 for ; Tue, 30 Nov 2021 07:16:02 GMT Received: from av1.neceur.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B250C18045 for ; Tue, 30 Nov 2021 07:16:52 +0000 (GMT) Received: from av1.neceur.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 94FC11803F for ; Tue, 30 Nov 2021 07:16:52 +0000 (GMT) Received: from EUX13SRV2.EU.NEC.COM (unknown [172.29.155.139]) by av1.neceur.com (Postfix) with ESMTPS for ; Tue, 30 Nov 2021 07:16:52 +0000 (GMT) Received: from EUX13SRV2.EU.NEC.COM (172.29.155.139) by EUX13SRV2.EU.NEC.COM (172.29.155.139) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 30 Nov 2021 07:16:52 +0000 Received: from EUX13SRV2.EU.NEC.COM ([172.29.155.139]) by EUX13SRV2.EU.NEC.COM ([172.29.155.139]) with mapi id 15.00.1497.023; Tue, 30 Nov 2021 07:16:52 +0000 From: Christian Weiss To: "libc-help@sourceware.org" CC: Felix Uhl Subject: call_site address of __cyg_profile_func Thread-Topic: call_site address of __cyg_profile_func Thread-Index: AdflujiZUFVOJrm8R9ylZDiK/x/bgg== Date: Tue, 30 Nov 2021 07:16:51 +0000 Message-ID: Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [172.29.147.132] MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1600-8.1.0.1054-22232.006 X-TMASE-Version: IMSVA-9.1.0.1600-8.1.1054-22232.006 X-TMASE-Result: 10--11.676500-10.000000 X-TMASE-MatchedRID: vUOe50KsTv/DVS5ju16y1/mQAr4UUK+SQHu/+3iXKvS8g9OnE+78jxRK pkoHNCx+kBulMq39Dyilc2LL333VMfioIsi7Sa0gWsKKuc6vT6w2TyBZbkpSdYcPdRGKPam3Scb lIYHQj76TIRoQhStHeFVN8laWo90MwJjn8yqLU6Lh7/6dSKdF26MOKnpzjnVI5e7dkYLOVmMNRo 0LQ6oADkDAEmiOG36BSEQN/D/3cG6l9VzHf0qr7qGtkEtDyHM5sK87pEX+43lqAKt8b+yA8a/S3 50mFD3cifLvZ50OfEaAgmaGG5WHQMAGbtCcgg/8dDwP5ItpCOwcSRF9JP5Ozi4jb1n1eNA354mb osKUuYfCKxdd3mKUa4oLoibgjVEX+Gz435tISEHimKcLRvsB1fBYRo06eVj38vzD3/0Zl0qqlkP d5cs2pNsoDJz5OAzc+KUzuemidPzq0SQ1Mgx5CDg2jfgv3Zp9UdfEKc10rU54nNRC+UXW5z7V1O rezJhfsKrmNJBIHWcOsNNBnlgRWn0tCKdnhB58r10pknZXGJrkA/7Kqi9Jmd+uVqwqDdyNxviq5 6ZjooAA34IKWIN3OEGLBN2PV2qgplGkMwNvWdNGz0W4Qd262+LRTlYn1BfS09moAKGMrRn7Ngnz BhsDTUPdrK+hjJ8JL+zeyPQh2SR+3BndfXUhXQ== X-TMASE-SNAP-Result: 1.811037.0001-0-1-12:0,22:0,34:0,39:0-0 X-MailControl-OutInfo: MTYzODI1NjYzNTpGUEtleTEucHJpdjoZTotmv20iTjPYWbe+S63I/mE/0ZG5j51x1Q/zLi67o6YDzzEEnZE3j9I2EQctuI9ZX+lR0yVjSlh5VX6Anw4/uPi/hoTSKClcHCpBS3YQydSGqGJi2Yc6Yc+qayfF1N1DQjmwxWRqYTR4mX8zKOGj92yuJbYTQfxfqZ/pQQLASs7xhR8lxgc85FZJxZ5JQWEGm066ijChwgf6OzwMy3NWHeLckYNQMeoFw9Ut92NankmJoL31RizX6vMenvsuCegTCCcDi3v6OxTxOSqtuiMD+OEvBKUtvlz0/Bwyb7ywxv8VUXDDesWEtoo+mUjb+Md+J5nef5zYSscougFES8jV X-Scanned-By: MailControl 44278.2116 (www.mailcontrol.com) on 195.47.207.4 X-Mailcontrol-Refers-To: 1AU7H5pm017243 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HTML_MESSAGE, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2021 07:17:20 -0000 Dear all, I have a problem understanding the second argument (call_site) of __cyg_pro= file_func_enter and __cyg_profile_func_exit. (https://gcc.gnu.org/onlinedoc= s/gcc-9.2.0/gcc/Instrumentation-Options.html#Instrumentation-Options) I have the following test program: void foo3() { } void foo4() { } int main (int argc, char *argv[]) { foo1(); foo2(); } which is compiled with gcc 9.2.0 using the options -static -finstrument-fun= ctions -fno-inline-functions. The binary is linked against an external libr= ary which prints out the arguments of the function hooks. Disassembling the binary with objdump -d reveals this part where the functi= ons are called: 402542: b8 00 00 00 00 mov $0x0,%eax 402547: e8 31 ff ff ff callq 40247d 40254c: b8 00 00 00 00 mov $0x0,%eax 402551: e8 50 ff ff ff callq 4024a6 402556: bb 00 00 00 00 mov $0x0,%ebx The debug output in the function hooks yields (disregarding the entry of ma= in) ENTER: 0x40247d @ 0x40254c ENTER: 0x4024a6 @ 0x402556 The first argument matches the symbol address as can be seen from the callq= argument. However, the second argument matches the lines after the call of= foo1 or foo2. I can see in the disassembly of e.g. foo1 that this because = of the offset 0x8 in the argument register: 402481: 48 8b 45 08 mov 0x8(%rbp),%rax 402485: 48 89 c6 mov %rax,%rsi 402488: bf 7d 24 40 00 mov $0x40247d,%edi 40248d: e8 4e 0a 00 00 callq 402ee0 <__cyg_profile_func_e= nter> I wonder why this is the case. What is the reason for using this offset? Especially, I want to match the addresses in the DWARF debug section of the= binary to the function calls. There, the line number is increased for the = addresses before the callq statement. This way, the DWARF addresses are shi= fted wrt. the call sites. Best regards, Christian Dr. Christian Weiss Benchmark Analyst Tel: +49 211 5369 126 NEC Deutschland GmbH Gesch=E4ftsf=FChrer Yuichi Kojima Handelsregister D=FCsseldorf HRB 57941; VAT ID DE129424743