Summary: | gprof doesn't work with code built with PIE | ||
---|---|---|---|
Product: | binutils | Reporter: | Matthias Klose <doko> |
Component: | gprof | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | CC: | hjl.tools, leo, nickc |
Priority: | P2 | ||
Version: | 2.28 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: |
Description
Matthias Klose
2017-02-21 10:14:21 UTC
Hi Matthias,
> Since --enabled-default-pie was enabled in Debian for GCC 6, gprof no longer
> works.
I think that this might be a glibc bug. Specifically in their implementation of mcount() for PIE environments.
Running "gprof -d infloop | grep main" shows that main starts at address 0x860:
[get_src_info] 0x860 -> infloop.c:1 (main)
[core_create_function_syms] 15 main 0x860
And that it covers 0x2f bytes:
[symtab_finalize] 0x860-0x88f main
But, the data in the gmon.out file us using much higher addresses:
[hist_read_rec] n_lowpc 0x4004e0 n_highpc 0x400718 ncnt 144
[assign_samples] bin_low_pc=0x40063a, bin_high_pc=0x40063e, bin_count=18
[assign_samples] bin_low_pc=0x40063e, bin_high_pc=0x400642, bin_count=38
[assign_samples] bin_low_pc=0x400646, bin_high_pc=0x40064a, bin_count=82
[assign_samples] total_time 138.000000
Of course I may be wrong - I am not an expert on gprof - but it does look to me like the contents of the gmon.out file are wrong.
Alternatively maybe gprof needs a way compute a starting address bias for PIE executables.
Cheers
Nick
The load address of PIE is determined at run-time and changes for each run. But the format of gmon.out doesn't support the changing load address. (In reply to H.J. Lu from comment #2) > The load address of PIE is determined at run-time and changes for > each run. But the format of gmon.out doesn't support the changing load > address. All the more reason then for mcount() to adjust its output in order to allow for the run-time address bias. I was affected by this problem. So (maybe) I'll figure something out. Please kick me if you have any new information. Rgs. (In reply to Leo Yuriev from comment #4) > I was affected by this problem. So (maybe) I'll figure something out. > Please kick me if you have any new information. > > Rgs. Looking into the source code, I found that this problem has been fixed for a long time ;) Please close this bug as dublicate of Bug 22284. |