From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44349 invoked by alias); 17 Oct 2018 22:26:43 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 44337 invoked by uid 89); 17 Oct 2018 22:26:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.1 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=UD:ro, here!, Program, 42PM X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 Oct 2018 22:26:40 +0000 Received: from librem.wildebeest.org (deer0x01.wildebeest.org [172.31.17.131]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 160353000AFF; Thu, 18 Oct 2018 00:26:37 +0200 (CEST) Received: by librem.wildebeest.org (Postfix, from userid 1000) id BEF5413FCED; Thu, 18 Oct 2018 00:26:37 +0200 (CEST) Date: Wed, 17 Oct 2018 22:26:00 -0000 From: Mark Wielaard To: Milian Wolff Cc: elfutils-devel@sourceware.org, Ulf Hermann , Christoph Sterz Subject: Re: Handling pgoff in perf elf mmap/mmap2 elf info Message-ID: <20181017222637.GD8237@wildebeest.org> References: <1539637492.4578.20.camel@klomp.org> <1910884.XDs4ZEXKnv@agathebauer> <2018186.sfouUOiKkn@agathebauer> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2018186.sfouUOiKkn@agathebauer> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2018-q4/txt/msg00051.txt.bz2 Hi Milian, On Wed, Oct 17, 2018 at 04:52:42PM +0200, Milian Wolff wrote: > On Montag, 15. Oktober 2018 23:06:07 CEST Milian Wolff wrote: > > On Montag, 15. Oktober 2018 23:04:52 CEST Mark Wielaard wrote: > > > On Mon, 2018-10-15 at 22:38 +0200, Milian Wolff wrote: > > > > here's one example of mmap events recorded by perf: > > > > > > > > 0x7fac5ec0b000 to 0x7fac5ed9a000, len = 0x18f000, offset > > > > = 0 r--p /usr/lib/libstdc++.so.6.0.25 > > > > 0x7fac5ec94000 to 0x7fac5ed8a000, len = 0xf6000, offset > > > > = 0x89000 ---p /usr/lib/libstdc++.so.6.0.25 > > > > 0x7fac5ec94000 to 0x7fac5ed4c000, len = 0xb8000, offset > > > > = 0x89000 r-xp /usr/lib/libstdc++.so.6.0.25 > > > > 0x7fac5ed4c000 to 0x7fac5ed89000, len = 0x3d000, offset > > > > = 0x141000 r--p /usr/lib/libstdc++.so.6.0.25 > > > > 0x7fac5ed8a000 to 0x7fac5ed97000, len = 0xd000, offset > > > > = 0x17e000 rw-p /usr/lib/libstdc++.so.6.0.25 > > > > > > Could you also post the matching phdr output for the file? > > > eu-readelf -l /usr/lib/libstdc++.so.6.0.25 should show it. > > > That way we can see how the PT_LOAD segments map to the mmap events. > > > > Sure: > > > > $ eu-readelf -l /usr/lib/libstdc++.so.6.0.25 > > Program Headers: > > Type Offset VirtAddr PhysAddr FileSiz > > MemSiz Flg Align > > LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x088fa8 > > 0x088fa8 R 0x1000 > > LOAD 0x089000 0x0000000000089000 0x0000000000089000 0x0b7ae1 > > 0x0b7ae1 R E 0x1000 > > LOAD 0x141000 0x0000000000141000 0x0000000000141000 0x03cfe0 > > 0x03cfe0 R 0x1000 > > LOAD 0x17e8e0 0x000000000017f8e0 0x000000000017f8e0 0x00b8b8 > > 0x00ed60 RW 0x1000 > > DYNAMIC 0x1873a8 0x00000000001883a8 0x00000000001883a8 0x0001e0 > > 0x0001e0 RW 0x8 > > NOTE 0x0002a8 0x00000000000002a8 0x00000000000002a8 0x000024 > > 0x000024 R 0x4 > > NOTE 0x17dfc0 0x000000000017dfc0 0x000000000017dfc0 0x000020 > > 0x000020 R 0x8 > > TLS 0x17e8e0 0x000000000017f8e0 0x000000000017f8e0 0x000000 > > 0x000020 R 0x8 > > GNU_EH_FRAME 0x149558 0x0000000000149558 0x0000000000149558 0x007f04 > > 0x007f04 R 0x4 > > GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 > > 0x000000 RW 0x10 > > GNU_RELRO 0x17e8e0 0x000000000017f8e0 0x000000000017f8e0 0x00b720 > > 0x00b720 R 0x1 > > > > Section to Segment mapping: > > Segment Sections... > > 00 [RO: .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version > > .gnu.version_d .gnu.version_r .rela.dyn] > > 01 [RO: .init .text .fini] > > 02 [RO: .rodata .eh_frame_hdr .eh_frame .gcc_except_table > > .note.gnu.property] > > 03 [RELRO: .tbss .init_array .fini_array .data.rel.ro .dynamic .got] > > .got.plt .data .bss > > 04 [RELRO: .dynamic] > > 05 [RO: .note.gnu.build-id] > > 06 [RO: .note.gnu.property] > > 07 [RELRO: .tbss] > > 08 [RO: .eh_frame_hdr] > > 09 > > 10 [RELRO: .tbss .init_array .fini_array .data.rel.ro .dynamic .got] > > So, Mark - any chance you could have a look at the above and give us your > feedback? Sorry, I haven't yet looked at this deeply. But some quick comments. The mmap events do seem to correspond to the PT_LOAD segments. At least the offsets are. Why the second on is mmapped twice I don't know. The difference in length for the last 3 seems to be that the mmaps are aligned up (0x1000, 4K, page size) > When I compare the actual mmap events with the LOAD segments, there are some > similarities, but also some discrepancies. Note how the mmap sizes always > differ from the FileSiz header value. And the offsets also sometimes mismatch, > e.g. for the last segment / mmap event we get 0x17f8e0 in the header, but > 0x17e000 in the mmap event...: > > LOAD 0x17e8e0 0x000000000017f8e0 0x000000000017f8e0 0x00b8b8 > 0x00ed60 RW 0x1000 > > 0x7fac5ed8a000 to 0x7fac5ed97000, len = 0xd000, offset = 0x17e000 > rw-p /usr/lib/libstdc++.so.6.0.25 > > I'm pretty confused here! I think the differences can be explained by the fact that mmap will use aligned offsets and length. In theory libdwfl just needs to see one mmap even and should then be able to use the phdrs PT_LOAD headers to see how the whole file is mmapped into memory. Maybe something goes wrong there. And reporting multiple events for the same file might confuse things. Cheers, Mark