Handling pgoff in perf elf mmap/mmap2 elf info

Ulf Hermann ulf.hermann@qt.io
Wed Sep 19 12:24:00 GMT 2018

> We suspect perf to offset its recording-addresses of mmapped
> dsos/executables starting with a specific section, such that they denote
> their pointers with this pg_offset parameter. (e.g. skipping a library's
> header and setting pgoff to the headersize). Although we are not 100%
> sure about this information.

According to my understanding, the pgoff is not perf's invention. Rather, the libary loader for the target application does not mmap() the full ELF file, but only the parts it's interested in. Those partial mappings are then reported through perf. We then try to recreate the memory mapping with perfparser, but run into problems because dwfl_report_elf() doesn't let us do partial mappings. You can only map complete files with that function. There probably is some way to manually map the relevant sections using other functions in libdw and libelf, but I haven't figured out how to do this, yet. If there is a simple trick I'm missing, I'd be happy to hear about it. 

And, yes, a function that works like dwfl_report_elf, but takes a pgoff and length as additional parameters is sorely missing from the API.

best regards,

More information about the Elfutils-devel mailing list