Where is __dso_handle defined?

来源  https://stackoverflow.com/questions/34308720/where-is-dso-handle-defined

__dso_handle is a "guard" that is used to identify dynamic shared objects during global destruction.

Realistically, you should stop reading here. If you're trying to defeat object identification by messing with __dso_handle, something is likely very wrong.

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).

Sometimes, it is defined manually.

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):

Often, it is defined in the stdlib:

Further reading:

__cxa_atexit and __dso_handle

https://lists.debian.org/debian-gcc/2003/07/msg00057.html

https://wiki.osdev.org/C++#GCC

crtbegin.c

/* Runtime support for C++ */

typedef void (*func_ptr) (void);

/* __dso_handle */
/* Itanium C++ ABI requires that each shared object (*.so) should have its
own __dso_handle, and when that shared object is unloaded, the __dso_handle
is an argument that is passed to __cxa_finalize. For a shared object,
__dso_handle is assigned itself, for the main executable, __dso_handle is 0
*/
#ifdef SHARED
void *__dso_handle = &__dso_handle;
#else
void *__dso_handle = ;
#endif #if 0
#ifdef SHARED extern void __cxa_finalize (void *) __attribute__((weak)); static void __attribute__((used))
__do_global_dtors_aux(void) {
static int completed; if (__builtin_expect (completed, ))
return; if (__cxa_finalize)
__cxa_finalize (__dso_handle); completed = ;
} __asm__ (".section .fini");
__asm__ (".align 8, 0x90");
__asm__ (".byte 0x0f, 0x1f, 0x00");
__asm__ ("call __do_global_dtors_aux");
#endif
#endif
/* The musl libc is responsible for init_array traversal so there is no
need to keep __do_global_ctors_aux
*/
#if 0
static void __attribute__((used))
__do_global_ctors_aux(void) {
static int completed; if (__builtin_expect (completed, ))
return; completed = ;
} __asm__ (".section .init");
__asm__ (".align 8, 0x90");
__asm__ (".byte 0x0f, 0x1f, 0x00");
__asm__ ("call __do_global_ctors_aux");
#endif
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus extern __attribute__((weak)) void *__dso_handle; #ifdef __cplusplus
}
#endif // __cplusplus

undefined reference to `__dso_handle'  ?

If this is your use case then merely add the command line option to your compile/link command line: -fno-use-cxa-atexit

=============== End

Where is __dso_handle defined?的更多相关文章

  1. unsupported dynamic reloc R_ARM_REL32 AND hidden symbol '__dso_handle' is not defined

    项目里编译codec src\makefiles\android\codec\Makefileline 25 原本用 4.6 不会报错-L/data/android/android-ndk/sourc ...

  2. No result defined for action com.lk.IndexAction and result success

    意图访问一个 /es/index.action 竟然出现: [SAE ] ERROR [05-11 13:54:32] [http-80-5] com.opensymphony.xwork2.util ...

  3. Apache报错信息之Invalid command 'Order', perhaps misspelled or defined by a module not included in the server config

    今天配置开启Apache虚拟主机时, 然后日志报错提示: Invalid command 'Order', perhaps misspelled or defined by a module not ...

  4. _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)

    原文地址::http://blog.csdn.net/xiaolongwang2010/article/details/7550505 相关网帖 1.错误找不到WinsdkVer.h----http: ...

  5. VC++ : error LNK2005: ... already defined in *.obj

    今天写代码遇到了这么一个链接错误:"已经在*.obj中定义". error LNK2005: "void __cdecl ReplaceWstringVar(class ...

  6. Target runtime com.genuitec.runtime.generic.jee60 is not defined

    转载自:http://jingyan.baidu.com/article/d7130635338e3f13fdf47518.html 用eclipse加载别人的工程,报错Target runtime ...

  7. TOMCAT-报错The BASEDIR environment variable is not defined correctly

    <span style="font-size:18px;">The BASEDIR environment variable is not defined correc ...

  8. MySql.Data.MySqlClient.MySqlException: Parameter ‘@maxid’ must be defined

    本文涉及到的mysql知识点: mysql中的if条件语句用法: IF(expr1,expr2,expr3) mysql使用变量(mysql中变量不用事前申明) mysql事务 testcase 为了 ...

  9. SQL SERVER中用户定义标量函数(scalar user defined function)的性能问题

    用户定义函数(UDF)分类  SQL SERVER中的用户定义函数(User Defined Functions 简称UDF)分为标量函数(Scalar-Valued Function)和表值函数(T ...

随机推荐

  1. token的解码及 判断值不为空的方法

    token 的解码要使用插件:jwt-decode 判断值不为空的方法: function isEmpty(value){ return ( value === undefined || value ...

  2. koa 项目实战(六)注册接口加密

    1.创建工具类 根目录/config/tools.js const bcrypt = require('bcryptjs'); const tools = { enbcrypt(password) { ...

  3. 影响mysql性能的因素

    一.服务器硬件. CPU不够快,内存不够多,磁盘IO太慢. 对于计算密集型的应用,CPU越可能去影响系统的性能,此时,CPU和内存将越成为系统的瓶颈. 当热数据大小远远超过系统可用内存大小时,IO资源 ...

  4. LC 216. Combination Sum III

    Find all possible combinations of k numbers that add up to a number n, given that only numbers from ...

  5. es6 单例

    class Singleton { constructor() { this.conn = this.connect(); } static getInstance() { if (!Singleto ...

  6. 用python实现简单EXCEL数据统计的实例

    用python实现简单EXCEL数据统计的实例 下面小编就为大家带来一篇用python实现简单EXCEL数据统计的实例.小编觉得挺不错的,现在就分享给大家,也给大家做个参考.一起跟随小编过来看看吧 任 ...

  7. Redis 集群部署

    一.下载所需软件包 redis wget http://download.redis.io/releases/redis-4.0.6.tar.gz ruby wget https://cache.ru ...

  8. 使用 DrMemory 详细教程

    Dr Memory 简介 Dr. Memory 是一个开源免费的内存检测工具,它能够及时发现内存相关的编程错误,比如未初始化访问.内存非法访问以及内存泄露等.它不仅能够在 Linux 下面工作,也能在 ...

  9. (转载)悟透JavaScript

    引子 编程世界里只存在两种基本元素,一个是数据,一个是代码.编程世界就是在数据和代码千丝万缕的纠缠中呈现出无限的生机和活力. 数据天生就是文静的,总想保持自己固有的本色:而代码却天生活泼,总想改变这个 ...

  10. nginx负载均衡高可用部署和代理配置

    nginx负载均衡高可用配置 服务器A:172.16.100.2 服务器B:172.16.100.3 首先先在两台服务器上分别安装好nginx和keepalived后,再进行下面的操作 配置keepa ...