Let's say I have a very basic class:
// lib.h
class A
{
public:
A();
void nop();
};
// lib.cpp
#include "lib.h"
A::A() {}
void A::nop() {}
, which I compile into a shared library:
g++ lib.cpp -shared -o lib.so -fPIC
When I look at the exported symbols from the code section of the library, I see three of them:
$ nm lib.so | grep ' T '
00000000000010f6 T _ZN1A3nopEv
00000000000010ea T _ZN1AC1Ev
00000000000010ea T _ZN1AC2Ev
$ nm lib.so | grep ' T ' | cut -d ' ' -f3 | xargs c++filt
A::nop()
A::A()
A::A()
Why is the constructor exported twice? I've tested on Linux with both gcc and clang and the result is the same.
P.S.: I'm not trying to solve a real problem, this is just a peculiarity I noticed.