Linux共享库中缺少功能 [英] Missing functions in Linux shared library

查看:72
本文介绍了Linux共享库中缺少功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在支持Linux程序,该程序允许用户编写自己的基于.so文件的插件,并在运行时使用dlopen()加载它们.有时,用户会忘记在包含必要函数定义的makefile中包括一个C ++文件.当插件管理器使用dlsym()从依赖于这些缺少的函数定义之一的插件中加载导出的函数时,我得到一个空函数地址.

I'm supporting a Linux program that allows users to write their own .so file based plugins that are loaded at runtime with dlopen(). Sometimes a user will forget to include a C++ file in the makefile that contains necessary function definitions. When the plugin manager uses dlsym() to load an exported function from the plugin that depends on one of these missing function definitions, I get a null function address.

我的问题:如何提前检测到此错误?我已经尝试过-z defs和-Wno-undef链接器标志,但是它们不会产生错误.我已经尝试过使用各种标志的nm,readelf和objdump命令,但是未定义的函数根本不会出现在符号表中.有什么建议么?谢谢!

My question: How can I detect this error ahead of time? I've tried the -z defs and -Wno-undef linker flags, but they don't generate an error. I've tried the nm, readelf, and objdump commands with various flags but the undefined functions don't show up in the symbol tables at all. Any suggestions? Thanks!

推荐答案

-未定义/ -z defs 文档:

未定义符号仍允许在共享库中使用.

Undefined symbols in shared libraries are still allowed.

使用另一个标志:-no-allow-shlib-undefined :

允许或禁止共享库中的未定义符号.这开关类似于-no-undefined ,除了它确定未定义符号位于共享库中时的行为而不是常规目标文件.它不会影响未定义的处理常规目标文件中的符号.

Allows or disallows undefined symbols in shared libraries. This switch is similar to --no-undefined except that it determines the behaviour when the undefined symbols are in a shared library rather than a regular object file. It does not affect how undefined symbols in regular object files are handled.

这篇关于Linux共享库中缺少功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆