https://sourceware.org/bugzilla/show_bug.cgi?id=33151
Bug ID: 33151
Summary: Weak functions are not displayed
Product: binutils
Version: 2.45
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gprofng
Assignee: vladimir.mezentsev at oracle dot com
Reporter: dabordukov at gmail dot com
Target Milestone: ---
Created attachment 16175
--> https://sourceware.org/bugzilla/attachment.cgi?id=16175&action=edit
patch for the bug
gprofng ignores functions that are compiled as weak symbols. This heavily
affects C++ class methods that are always compiled by g++ and clang++ as weak
symbols. In this case gprofng just shows <static>@ADDRESS(<FILENAME>)
The bug has been introduced in the commit 470a0288a818.
The proposed patch removes the check for WEAK symbols and gprofng processes
them as before.
Here is a sample:
% cat main.cc
#include <iostream>
class Counter{
public:
unsigned long int Count(unsigned int n) {
unsigned long int acc = 0;
while(n--) {
acc += n;
}
return acc;
}
};
int main() {
Counter c;
std::cout << c.Count(500000000) << std::endl;
}
The 'Counter::Count' symbol is WEAK indeed:
% readelf -sCW main | grep Count
6: 00000000000011c4 52 FUNC WEAK DEFAULT 13
Counter::Count(unsigned int)
Unmodified binutils-2_45-branch does not resolve addresses:
% /opt/binutils-2.45-orig/bin/gprofng-display-text -functions test.1.er
Functions sorted by metric: Exclusive Total CPU Time
Excl. Total Incl. Total Name
CPU CPU
sec. % sec. %
0.080 100.00 0.080 100.00 <Total>
0.080 100.00 0.080 100.00 <static>@0x11c3 (<main>)
0. 0. 0.080 100.00 <static>@0x27635 (<libc.so.6>)
0. 0. 0.080 100.00 __libc_start_main
0. 0. 0.080 100.00 main
With the patch applied the addresses are resolved to function names:
% /opt/binutils-2.45-fix/bin/gprofng-display-text -functions test.1.er
(gprofng-display-text) Functions sorted by metric: Exclusive Total CPU Time
Excl. Total Incl. Total Name
CPU CPU
sec. % sec. %
0.080 100.00 0.080 100.00 <Total>
0.080 100.00 0.080 100.00 Counter::Count(unsigned int)
0. 0. 0.080 100.00 <static>@0x27635 (<libc.so.6>)
0. 0. 0.080 100.00 __libc_start_main
0. 0. 0.080 100.00 main
--
You are receiving this mail because:
You are on the CC list for the bug.