binutils Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
binutils/gprofng

Fix gprofng file offset generation for gmon.out

Correctly retrieves file offset for gmon.out map generation in gprofng.

This change fixes a bug in gprofng’s profiling map generation where the file offset for gmon.out was not being correctly determined. Previously, a hardcoded offset of 0 was used, leading to incorrect profiling data on some platforms, specifically Linux/x86-64 as indicated by a test failure. The fix retrieves the correct file offset from the filepos field of the core_text_sect structure, ensuring accurate profiling map generation.

In Details

The gen_gmon_map function in gprofng's gp-gmon.cc is responsible for creating a map file from the gmon.out profiling data. The commit corrects how the file offset is determined for the text section. Instead of defaulting to 0, it now uses core_text_sect->filepos, which is the correctly recorded file offset for that section, resolving a PR on Linux/x86-64.

For Context
gprofng
The next-generation version of the gprof profiling tool, designed to provide more detailed and accurate performance analysis information.
gmon.out
The default output file generated by the gprof profiling tool, containing raw profiling data such as call counts and execution times.
file offset
The position of a byte or block of data within a file, typically measured from the beginning of the file.
core_text_sect
Represents the text section (executable code) within a core dump or program's memory layout, including its virtual address, size, and file position.
Filed Under: profilinggprofngdebugging