Too many constructor characters

When compiling this:

template <typename T> struct ConstArray { ///MEMBERS T* data_; T* end_; ///Constructors ConstArray(T* data, T* end) : data_(data), end_(end) {} }; template struct ConstArray<const char>; 

gives me ( nm -C *.o ):

 0000000000000000 W ConstArray<char const>::ConstArray(char const*, char const*) 0000000000000000 W ConstArray<char const>::ConstArray(char const*, char const*) 0000000000000000 n ConstArray<char const>::ConstArray(char const*, char const*) 

It seems that I get three characters (2 W + 1 n (I don't know what it is)) for each constructor defined. The functions seem to give me only one as expected. Can someone explain why this is or point me to an explanation?

+5
source share
1 answer

Perhaps I see why these characters appear in nm output, but I canโ€™t say whether it should / should not and what exactly n means. Maybe if someone is familiar with this, he can post the full answer.

If you do objdump -t ./obj.o , you will see a character table. With the exception of 2 constructors and many other characters, I see

 00000000 l .group 00000000 _ZN10ConstArrayIKcEC5EPS0_S2_ 

there. The flag is only l , which means that it is local, not debug, so I see it in nm as the third character.

If I do nm -g ./obj.o to see only external characters, I see only 2 W constructors, and when I do nm -a ./obj.o , I see all the characters as well as those marked in objdump -x like debug . And I also see there some debugging symbols that are n flagged in nm -a output.

So I donโ€™t know what n means, but the third character is somehow related to the .group section of the elf file. Which is responsible for grouping characters together.

0
source

Source: https://habr.com/ru/post/1232093/


All Articles