__dso_handle 在哪里定义? [英] Where is __dso_handle defined?
问题描述
我在尝试编译我的程序时遇到一个未解决的符号错误,它抱怨它找不到 __dso_handle
.这个函数一般定义在哪个库中?
I have an unresolved symbol error when trying to compile my program which complains that it cannot find __dso_handle
. Which library is this function usually defined in?
nm on libstdc++.so.6
的以下结果是否意味着它包含该内容?
Does the following result from nm on libstdc++.so.6
mean it contains that?
我试图链接它,但仍然出现错误.
I tried to link against it but the error still occurs.
nm libstdc++.so.6 | grep dso
00000000002fc480 d __dso_handle
推荐答案
__dso_handle
是一个守卫",即 用于在全局销毁时识别动态共享对象.
__dso_handle
is a "guard" that is used to identify dynamic shared objects during global destruction.
实际上,您应该停止阅读这里.如果你试图通过弄乱 __dso_handle
来破坏对象识别,那么很可能是大错特错.
Realistically, you should stop reading here. If you're trying to defeat object identification by messing with __dso_handle
, something is likely very wrong.
但是,既然您问它是在哪里定义的:答案很复杂.要显示其定义的位置(对于 GCC),请在 C++ 文件中使用 iostream
,然后执行 extern int __dso_handle;
.由于类型冲突,这应该会显示声明的位置(请参阅 此论坛主题 获取来源).
However, since you asked where it is defined: the answer is complex. To surface the location of its definition (for GCC), use iostream
in a C++ file, and, after that, do extern int __dso_handle;
. That should surface the location of the declaration due to a type conflict (see this forum thread for a source).
有时,它是手动定义的.
有时,它由编译器安装的运行时"定义/提供(实际上,CRT 通常只是一堆二进制标头/入口点管理代码,以及一些出口防护/处理程序).在 GCC 中(不确定其他编译器是否支持这一点;如果支持,它将在他们的源代码中):
Sometimes, it is defined/supplied by the "runtime" installed by the compiler (in practice, the CRT is usually just a bunch of binary header/entry-point-management code, and some exit guards/handlers). In GCC (not sure if other compilers support this; if so, it'll be in their sources):
- Main definition
- Testing
__dso_handle
replacement/tracker example 1 - Testing
__dso_handle
replacement/tracker example 2
通常,它是在标准库中定义的:
Often, it is defined in the stdlib:
进一步阅读:
- Subtle bugs caused by
__dso_handle
being unreachable in some compilers
这篇关于__dso_handle 在哪里定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!