How does linker find shared library without SONAME

我的梦境 提交于 2019-12-06 06:04:56

问题


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?

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


回答1:


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

-soname=name

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.



来源:https://stackoverflow.com/questions/4071962/how-does-linker-find-shared-library-without-soname

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!