Question about duplicate C++ functions generated with GNU 3.4.1

Jon Watson j-watson@airvananet.com
Mon Nov 22 21:11:00 GMT 2004


Hi -

We recently switched to GCC 3.4.1 (built for PowerPC EABI). As we have started to recompile our code and bring up our products we noticed some odd behavior. Specifically, it appears that GCC has created two functionally identical copies of C++ object constructors that are referenced by different symbols...

For example, we have a class, BufferPool, which defines a default constructor BufferPool::BufferPool() and an overloaded constructor BufferPool::BufferPool( ... ), which accepts several arguments. When we look at the symbols and at the assembly listing we see there are two (unique) symbols (at different addresses) for each constructor that refer to the same C++ code... 

The symbols look like this (as dumped from the object file with nm):

Symbols for BufferPool::BufferPool():
00002c78 T _ZN10BufferPoolC2Ev	./..\..\..\..\..\..\..\..\..\airvana\sw\ne\src\net\BufferPool\src\BufferPool.cpp:91
00002c88 T _ZN10BufferPoolC1Ev     ./..\..\..\..\..\..\..\..\..\airvana\sw\ne\src\net\BufferPool\src\BufferPool.cpp:91

Symbols for BufferPool::BufferPool(...):
00002c98 T _ZN10BufferPoolC2EPNS_13MemDescriptorES1_PNS_16NumBufDescriptorEjtPc ./..\..\..\..\..\..\..\..\..\airvana\sw\ne\src\net\BufferPool\src\BufferPool.cpp:119
0000336c T _ZN10BufferPoolC1EPNS_13MemDescriptorES1_PNS_16NumBufDescriptorEjtPc ./..\..\..\..\..\..\..\..\..\airvana\sw\ne\src\net\BufferPool\src\BufferPool.cpp:119

When we disassembled the object file and reviewed the contents of both versions of the function we verified they are identical and do the same thing (both would function correctly)... This behavior doesn't appear to be creating an execution problem, but it has caused some confusion when setting breakpoints and stepping through code. Also, it seems to add bloat to the objects for no purpose.

My questions are:

1) Why is GCC generating two identical copies of the same constructor/function generated with different symbol names?

2) Is there a way to prevent this? (I looked at the GCC manuals and nothing jumped out at me...) 

Thanks in advance for any help you can offer...

Jon Watson
Airvana, Inc



More information about the Gcc-help mailing list