链接器如何在没有SONAME的情况下找到共享库 [英] How does linker find shared library without SONAME

查看:269
本文介绍了链接器如何在没有SONAME的情况下找到共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我创建一个没有SONAME的共享库就像这样

if I create a shared library without a SONAME like this

gcc -shared libfoo.o -o libfoo.so

并链接到它,
链接器如何找到我的共享库?

and link against it, how does the linker find my shared library?

是否链接器将文件名 libfoo.so 视为默认的SONAME?

Is the filename libfoo.so considered as default SONAME by the linker?

推荐答案

我认为你是对的。这里是什么ld手册页说:

I think you're right. Here what ld man pages say:


-soname = name

-soname=name

创建一个ELF共享对象,将内部DT_SONAME字段设置为指定的名称。当一个可执行文件与一个具有DT_SONAME字段的
共享对象链接时,那么当可执行文件运行时,动态链接器将尝试加载由DT_SONAME字段指定的共享对象
,而不是使用该文件给链接器的名称。

When creating an ELF shared object, set the internal DT_SONAME field to the specified name. When an executable is linked with a shared object which has a DT_SONAME field, then when the executable is run the dynamic linker will attempt to load the shared object specified by the DT_SONAME field rather than the using the file name given to the linker.

这篇关于链接器如何在没有SONAME的情况下找到共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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