https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64266
Bug ID: 64266
Summary: Can GCC produce local mergeable symbols for
*.__FUNCTION__ and *.__PRETTY_FUNCTION__ function.
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: jason at gcc dot gnu.org
Created attachment 34250
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34250&action=edit
test case
For the following testcase:
extern "C" {
extern int printf (char *, ...);
}
class a {
public:
void sub (int i)
{
printf ("__FUNCTION__ = %s\n", __FUNCTION__);
printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
}
void sub()
{
printf ("__FUNCTION__ = %s\n", __FUNCTION__);
}
};
int
main (void)
{
a ax;
ax.sub (0);
ax.sub ();
return 0;
}
Unlink clang, GCC produces a local symbol residing in .symtab and string values
are not in mergeable section:
$ g++ ~/Programming/testcases/pretty-function.c -o a.o
$ readelf -s a.o --wide | grep PRE
15: 0000000000400710 17 OBJECT LOCAL DEFAULT 14
_ZZN1a3subEiE19__PRETTY_FUNCTION__
$ readelf -p '.rodata' a.out
String dump of section '.rodata':
[ 10] __FUNCTION__ = %s
[ 23] __PRETTY_FUNCTION__ = %s
[ 3d] sub
[ 50] void a::sub(int)
[ 61] sub
and clang produces:
$ clang++ ~/Programming/testcases/pretty-function.c -o a.o
$ readelf -s a.out --wide | grep PRE
(nothing)
$ readelf -p '.rodata' a.o
String dump of section '.rodata':
[ 4] __FUNCTION__ = %s
[ 17] sub
[ 1b] __PRETTY_FUNCTION__ = %s
[ 35] void a::sub(int)
I'm wondering if we can also process such kind of optimization.
For Inkscape (compiled with -O2), there are following differences:
section portion size size compared
comparison
.rodata 15.69 % 2.41 MB 2523277 2291412 90.81
%
.strtab 13.06 % 2.00 MB 2099988 1933845 92.09
%
Where column 'size' is related to GCC and 'compared' is size generated by
clang.
Thanks,
Martin