微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

列出ld链接器可用的所有符号

我有一个由(linux)gcc 4.8.2与-fvisibility =隐藏链接一个共享库(我有两个版本,gcc之一与C代码和ifort与Fortran代码)编译的一个小的静态库。 静态库由一些内部函数组成,全部以“ST_LIB_”为前缀。

我想确保在静态库中声明的函数不能被连接到共享库的任何可执行文件/库使用。 什么是最好的命令在Linux上检查具有某些前缀的函数不能被任何外部库使用?

我努力了:

nm --dynamic shared_lib | grep -i "ST_LIB_" | wc -l nm --dynamic shared_lib | grep -i "ST_LIB_" | wc -l (输出0)

gcc – / usr / bin / ld错误:无法在/ usr / local / lib中find<library>,但ldconfig列出它,path添加到ld.so.conf

在Windows上的gcc:生成的“a.exe”文件消失

Linux上的链接错误:“undefined reference to”

getrusage在ru_utime.tv_usec和ru_utime.tv_sec中返回零

我如何编译我的C ++代码到PowerPC Big-Endian

readelf -d shared_lib | grep -i "ST_LIB_" | wc -l readelf -d shared_lib | grep -i "ST_LIB_" | wc -l (输出0)

nm -g shared_lib | grep -i "ST_LIB_" | wc -l nm -g shared_lib | grep -i "ST_LIB_" | wc -l (输出26或0取决于共享lib)

readelf -s shared_lib | grep -i "ST_LIB_" | wc -l readelf -s shared_lib | grep -i "ST_LIB_" | wc -l (输出26或0取决于共享lib)

readelf -Ws shared_lib | grep -i "ST_LIB_" | grep -i "HIDDEN" | wc -l readelf -Ws shared_lib | grep -i "ST_LIB_" | grep -i "HIDDEN" | wc -l (输出26或0取决于共享lib)

什么是gcc 4.1.3?

为什么与pthread链接导致分段错误

C链接阶段不会产生警告

C怎么能打印一个超大号码?

programname.exe在Windows 10中已停止工作对话框

nm --dynamic应该是你要找的选项,因为它显示的符号,你可以链接(从共享库)。 readelf --dyn-syms应显示相同的信息(不同的输出)。

使用nm ,请检查具有"T"属性的符号。 从手册页:

The symbol type. At least the following types are used; others are,as well,depending on the object file format. If lowercase,the symbol is usually local; if uppercase,the symbol is global (external). There are however a few lowercase symbols that are shown for special global symbols ("u","v" and "w"). [...] "T" "t" The symbol is in the text (code) section.

如果您希望100%确定,则可以随时编写一个与您的共享库链接的测试程序,并尝试使用其中一个ST_LIB_符号。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐