我在Debian上拆解了一个自己写的非常简单的C++程序。它涉及一些std::string
操作。在反汇编代码中,我可以看到许多引用如下所示:
<void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag)>
我相信这是一些模板函数创建的具体字符串构造函数,用于初始化字符串。然而,反汇编的代码似乎并没有提供模板函数定义的确切位置的线索。
我查了/usr/include/c++/10/string
,没找到什么。我还问了ChatGPT,它说它是在libstdc++-10-dev
中定义的,我发出apt-get source libstdc++-10-dev
来获取它建议的源代码,但我只找到了下面这样的东西,这不是我真正想要的(例如,在debian/libcc1-0.symbols
中,我可以看到四行,只有那些字符串,但没有函数体):
18 results - 4 files
debian/libcc1-0.symbols:
8 (optional=abi_c++17)_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE17_M_realloc_insertIJS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_@Base 8
9: (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag@Base 8
10: (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag@Base 8
11 (optional=abi_c++11)_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EED1Ev@Base 10
debian/libstdc++6.symbols.32bit.cxx11:
116 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_capacityEj@GLIBCXX_3.4.21 5.2
117: (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructEjc@GLIBCXX_3.4.21 5.2
118 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_set_lengthEj@GLIBCXX_3.4.21 5.2
119 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE14_M_replace_auxEjjjc@GLIBCXX_3.4.21 5.2
120: (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE18_M_construct_aux_2Ejc@GLIBCXX_3.4.21 5.2
121 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE2atEj@GLIBCXX_3.4.21 5.2
170 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE11_M_capacityEj@GLIBCXX_3.4.21 5.2
171: (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE12_M_constructEjw@GLIBCXX_3.4.21 5.2
172 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE13_M_set_lengthEj@GLIBCXX_3.4.21 5.2
173 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE14_M_replace_auxEjjjw@GLIBCXX_3.4.21 5.2
174: (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE18_M_construct_aux_2Ejw@GLIBCXX_3.4.21 5.2
175 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE2atEj@GLIBCXX_3.4.21 5.2
debian/libstdc++6.symbols.64bit.cxx11:
116 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_capacityEm@GLIBCXX_3.4.21 5.2
117: (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructEmc@GLIBCXX_3.4.21 5.2
118 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_set_lengthEm@GLIBCXX_3.4.21 5.2
119 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE14_M_replace_auxEmmmc@GLIBCXX_3.4.21 5.2
120: (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE18_M_construct_aux_2Emc@GLIBCXX_3.4.21 5.2
121 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE2atEm@GLIBCXX_3.4.21 5.2
170 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE11_M_capacityEm@GLIBCXX_3.4.21 5.2
171: (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE12_M_constructEmw@GLIBCXX_3.4.21 5.2
172 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE13_M_set_lengthEm@GLIBCXX_3.4.21 5.2
173 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE14_M_replace_auxEmmmw@GLIBCXX_3.4.21 5.2
174: (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE18_M_construct_aux_2Emw@GLIBCXX_3.4.21 5.2
175 (optional=abi_c++11)_ZNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE2atEm@GLIBCXX_3.4.21 5.2
所以问题是:
1.像:_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag)
这样的函数真的存在吗?
1.如果是这样,我在哪里可以找到他们?
1.如果没有,我怎么知道是哪些模板生成的?
1条答案
按热度按时间oaxa6hgo1#
即使我晚了一点,我也会尽量回答你的问题。
您所展示的helper函数是以下函数的特殊化,在
basic_string.h
文件中声明:它的实现可以在
basic_string.tcc
文件中找到: