https://sourceware.org/bugzilla/show_bug.cgi?id=35008

            Bug ID: 35008
           Summary: gprof fails to resolve source lines from compressed
                    separate debug files
           Product: binutils
           Version: 2.47
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gprof
          Assignee: unassigned at sourceware dot org
          Reporter: lee at mtftm dot com
  Target Milestone: ---

In Binutils 2.47, gprof -l -C cannot resolve source locations from compressed
separate debug files. Both zlib and zlib-gnu are affected; embedded debug
information and uncompressed separate files work correctly.

Using an ELF built from upstream gprof/testsuite/tst-gmon.c, unpatched gprof
reports:

```text
<unknown>:0: (f1:0x401000) 2000 executions
<unknown>:0: (f2:0x401010) 1000 executions
<unknown>:0: (f3:0x401020) 1 executions
```

Moving BFD_DECOMPRESS before bfd_check_format() in open_separated_debug_file()
restores the expected output for the same input (source-directory prefix
omitted):

```text
tst-gmon.c:25: (f1:0x401000) 2000 executions
tst-gmon.c:31: (f2:0x401010) 1000 executions
tst-gmon.c:40: (f3:0x401020) 1 executions
```

BFD initializes section information during format checking, so setting the flag
afterward is too late. The proposed ordering matches core_init(), as
established by the related main-executable fix in
[PR24520](https://sourceware.org/bugzilla/show_bug.cgi?id=24520).

Validation: macOS 27.2 arm64, Apple clang 21.0.0, gprof targeting
x86_64-linux-gnu, using synthetic gmon records. All six combinations of
embedded/separate debug information and none/zlib/zlib-gnu compression produce
correct results with the fix.

AI assistance was used for diagnosis, the candidate fix and this report.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to