Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 什么是'_全球分公司';以纳米为单位的平均输出?_C++_Name Mangling_Nm - Fatal编程技术网

C++ 什么是'_全球分公司';以纳米为单位的平均输出?

C++ 什么是'_全球分公司';以纳米为单位的平均输出?,c++,name-mangling,nm,C++,Name Mangling,Nm,当我试图解决静态链接中的一个问题时,我在符号名称前面遇到了几个\u GLOBAL\u sub\u I前缀。虽然我使用了nm--demangle(-C),但它是以这种形式出现的 我偶然发现了这个答案()。看看我的源代码,它看起来确实像一个全局静态变量的初始化 我想知道的是,我在哪里可以获得更多关于uuu sub_u和其他损坏名称的信息,如\uuuu cxxabiv1?为了防止链接损坏,我将在这里回答,尽管首先应该归功于谁找到了这些信息(参见对问题的评论) 如果我们看一下,我们会发现头定义了两个名称

当我试图解决静态链接中的一个问题时,我在符号名称前面遇到了几个
\u GLOBAL\u sub\u I
前缀。虽然我使用了
nm--demangle(-C)
,但它是以这种形式出现的

我偶然发现了这个答案()。看看我的源代码,它看起来确实像一个全局静态变量的初始化


我想知道的是,我在哪里可以获得更多关于uuu sub_u和其他损坏名称的信息,如
\uuuu cxxabiv1

为了防止链接损坏,我将在这里回答,尽管首先应该归功于谁找到了这些信息(参见对问题的评论)

如果我们看一下,我们会发现头定义了两个名称空间:
\uu gnu\ucxx
abi
。因此,这是我们正在寻找的标题,它是在2009年生成的,并且几乎相同,除了提到的只有
abi
名称空间

区别是表面的,定义了名称空间
\uuucxxabiv1
,然后设置
名称空间abi=\uuuucxxabiv1所以我们可以确定这个标题仍然是我们正在寻找的

标题中声明了以下内容:

typedef __cxa_cdtor_return_type (*__cxa_cdtor_type)(void *);

int __cxxabiv1::__cxa_atexit (void(*)(void *), void *, void *) throw ();
void __cxxabiv1::__cxa_bad_cast ();
void __cxxabiv1::__cxa_bad_typeid ();
std::type_info * __cxxabiv1::__cxa_current_exception_type ();
char * __cxxabiv1::__cxa_demangle (const char *__mangled_name, char *__output_buffer, size_t *__length, int *__status);
int __cxxabiv1::__cxa_finalize (void *);
void __cxxabiv1::__cxa_guard_abort (__guard *);
int __cxxabiv1::__cxa_guard_acquire (__guard *);
void __cxxabiv1::__cxa_guard_release (__guard *);
void __cxxabiv1::__cxa_pure_virtual (void);
__cxa_vec_ctor_return_type __cxxabiv1::__cxa_vec_cctor (void *dest_array, void *src_array, size_t element_count, size_t element_size, __cxa_cdtor_return_type(*constructor)(void *, void *), __cxa_cdtor_type destructor);
void __cxxabiv1::__cxa_vec_cleanup (void *__array_address, size_t __element_count, size_t __element_size, __cxa_cdtor_type destructor);
__cxa_vec_ctor_return_type __cxxabiv1::__cxa_vec_ctor (void *__array_address, size_t __element_count, size_t __element_size, __cxa_cdtor_type constructor, __cxa_cdtor_type destructor);
void __cxxabiv1::__cxa_vec_delete (void *__array_address, size_t __element_size, size_t __padding_size, __cxa_cdtor_type destructor);
void __cxxabiv1::__cxa_vec_delete2 (void *__array_address, size_t __element_size, size_t __padding_size, __cxa_cdtor_type destructor, void(*__dealloc)(void *));
void __cxxabiv1::__cxa_vec_delete3 (void *__array_address, size_t __element_size, size_t __padding_size, __cxa_cdtor_type destructor, void(*__dealloc)(void *, size_t));
void __cxxabiv1::__cxa_vec_dtor (void *__array_address, size_t __element_count, size_t __element_size, __cxa_cdtor_type destructor);
void * __cxxabiv1::__cxa_vec_new (size_t __element_count, size_t __element_size, size_t __padding_size, __cxa_cdtor_type constructor, __cxa_cdtor_type destructor);
void * __cxxabiv1::__cxa_vec_new2 (size_t __element_count, size_t __element_size, size_t __padding_size, __cxa_cdtor_type constructor, __cxa_cdtor_type destructor, void *(*__alloc)(size_t), void(*__dealloc)(void *));
void * __cxxabiv1::__cxa_vec_new3 (size_t __element_count, size_t __element_size, size_t __padding_size, __cxa_cdtor_type constructor, __cxa_cdtor_type destructor, void *(*__alloc)(size_t), void(*__dealloc)(void *, size_t));
void * __cxxabiv1::__dynamic_cast (const void *__src_ptr, const __class_type_info *__src_type, const __class_type_info *__dst_type, ptrdiff_t __src2dst);

class __cxxabiv1::__fundamental_type_info : public std::type_info;
class __enum_type_info : public std::type_info;
class __pointer_type_info : public __pbase_type_info;
class __class_type_info : public std::type_info;
class __pointer_to_member_type_info : public __pbase_type_info;
class __base_class_type_info;
class __si_class_type_info : public __class_type_info;
class __vmi_class_type_info : public __class_type_info;
标题还包括:

#include <bits/cxxabi_tweaks.h>
#include <cxxabi-forced.h>
#包括
#包括

所以看看它们可能会有用。

我在我的符号中得到了一个
\u GLOBAL\u sub\u I
前缀,我需要去掉它

然后发现这个::

这是什么
llvm.global\u ctors
\u global\u I\u a…
当I
\35; include
时发生的事情

如果你将>/Cult>头包含到C++翻译单元中,文件可能会使用<代码> STD::CIN/STD::CUT/…< /Cord>全局对象。但是,C++不能保证不同翻译单元之间静态对象之间的初始化顺序,因此,如果.cpP文件中的静态cto/dor使用STD::CUT,则在使用之前,该对象不一定会自动初始化。 为了使std::cout和friends在这些场景中正确工作,我们使用的STL声明了一个静态对象,该对象在包含
的每个翻译单元中创建。这个对象有一个静态构造函数和析构函数,在全局iostream对象可能在文件中使用之前初始化和销毁它们。在.ll文件中看到的代码对应于构造函数和析构函数注册代码


我将我的函数移到了一个没有
的翻译单元中,符号现在在没有
\u GLOBAL\u sub\u I\u

的情况下导出。对于cxxabiv1,解释如下:@Chris看起来是一个很好的资源,谢谢欢迎您,如果在这件事上还有什么我可以帮助你的,请告诉我。@ChrisBritt链接看起来不再那么重要了,我想URL已经改变了。请你提供一个新的,或者在线文档中要查找的标题好吗?@TheVee我很抱歉。老实说,我甚至不记得除了在两年前的一次评论中指出那个文档之外,我会说什么。我很可能只是想给出相关头文件的链接(里面确实有文档),但是如果它发生了变化,我真的不知道我还想说什么。)