[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gprof/21189] New: gprof doesn't work with code built with PIE
From: |
doko at debian dot org |
Subject: |
[Bug gprof/21189] New: gprof doesn't work with code built with PIE |
Date: |
Tue, 21 Feb 2017 10:14:21 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=21189
Bug ID: 21189
Summary: gprof doesn't work with code built with PIE
Product: binutils
Version: 2.28
Status: NEW
Severity: normal
Priority: P2
Component: gprof
Assignee: unassigned at sourceware dot org
Reporter: doko at debian dot org
Target Milestone: ---
[forwarded from https://bugs.debian.org/854704]
"""
Since --enabled-default-pie was enabled in Debian for GCC 6, gprof no longer
works. I run a simple program compiled with default flags and gprof's output is
empty.
$ cat infloop.c
int main() {
for(long i = 0; i < 1000000000; i ++) {}
return 0;
}
$ gcc infloop.c -o infloop -pg
$ time ./infloop
real 0m2.067s
user 0m2.064s
sys 0m0.004s
$ gprof ./infloop | grep main
$
However, when I compile the same program with any earlier version of gcc, such
as gcc 5.4.1, or with the option -no-pie to disable PIE, it works.
$ gcc-5 infloop.c -o infloop -pg
$ rm gmon.out
$ time ./infloop
real 0m2.041s
user 0m2.036s
sys 0m0.000s
$ gprof ./infloop | grep main
101.41 2.06 2.06 main
$ gcc -no-pie infloop.c -o infloop -pg
$ rm gmon.out
$ time ./infloop
real 0m2.019s
user 0m2.016s
sys 0m0.000s
$ gprof ./infloop | grep main
101.41 2.03 2.03 main
$
This is the case for more complex programs too: gprof simply outputs nothing
other than the help-text. It looks like gcc is correctly generating the
gmon.out file, since it gets quite large and contains non-zero values.
Since GCC 6 moved to --enable-default-pie, all executables are of type DYN (not
EXEC), like shared libraries, and may be loaded at any base address. I suspect
this is breaking gprof's symbol lookup functionality. For instance, 0 is now a
valid address within the DYN ELF file. A good workaround for now is -no-pie,
but it would be great to get this fixed since Debian GCC now defaults to PIE.
"""
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug gprof/21189] New: gprof doesn't work with code built with PIE,
doko at debian dot org <=