共享so库中的nm符号输出t vs T [英] nm symbol output t vs T in a shared so library

查看:1929
本文介绍了共享so库中的nm符号输出t vs T的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在用户空间熔断器库中添加了新功能(fuse_lowlevel_notify_inval_directory). libfuse.so的编译和创建已完成,没有错误. 但是,当我的应用程序尝试使用此新功能时,链接器将引发错误:对`fuse_lowlevel_notify_inval_directory'的未定义引用 collect2:ld返回1个退出状态

I have added a new function (fuse_lowlevel_notify_inval_directory) in user space fuse library. The compilation and creation of libfuse.so is finished without error. But when my application tries to use this new function, the linker is throwing error: undefined reference to `fuse_lowlevel_notify_inval_directory' collect2: ld returned 1 exit status

当我检查nm

nm ../libfuse.so | grep inval
00000000000154ed T fuse_invalidate
**000000000001e142 t fuse_lowlevel_notify_inval_directory**
000000000001e26c T fuse_lowlevel_notify_inval_entry
000000000001e1cb T fuse_lowlevel_notify_inval_inode

T/t表示该符号出现在文本部分.如果为大写,则符号为全局(外部).我怀疑这是问题所在.新添加的函数显示的是小写的t,而其他旧函数的显示的是大写的T.我可能在做错什么了吗?

T/t means the symbol is present in text section. if uppercase, the symbol is global (external). I suspect this is the issue. The new added function is showing lowercase t while other older functions are having upper case T. Any idea about what I might be doing wrong?

推荐答案

对我可能做错的事情有任何想法吗?

Any idea about what I might be doing wrong?

t函数确实在库本地.这可能是由于多种原因造成的.最可能的是:

The t function is indeed local to the library. This could happen due to a number or reasons. The most likely ones are:

  1. 您声明了函数static,或者
  2. 您使用-fvisibility=hidden编译了库,并且 not 在函数上没有__attribute__((visibility("default"))),或者
  3. 您使用链接器版本脚本(即带有--version-script=libfoo.version标志的链接器)将此库链接起来,该脚本隐藏了所有函数(显式导出的函数除外),并且没有将函数添加到该列表中.

    请参阅示例,该示例使用--version-script来限制符号可见性
  1. You declared the function static, or
  2. You compiled the library with -fvisibility=hidden and did not have __attribute__((visibility("default"))) on the function, or
  3. You linked this library with a linker version script (i.e. with --version-script=libfoo.version flag) that hides all functions, except those which are explicitly exported, and you didn't add your function to that list.

    See this example of using --version-script to limit symbol visibility.

这篇关于共享so库中的nm符号输出t vs T的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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