为什么/lib32/libc.so.6具有两个"fopen"?符号在里面吗? [英] why /lib32/libc.so.6 has two "fopen" symbol in it?

查看:191
本文介绍了为什么/lib32/libc.so.6具有两个"fopen"?符号在里面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

nm -D /lib32/libc.so.6 | grep '\<fopen\>'
0005d0c0 T fopen
00109750 T fopen

readelf -s  /lib32/libc.so.6 | egrep '0005d0c0|00109750'
181: 0005d0c0    50 FUNC    GLOBAL DEFAULT   12 fopen@@GLIBC_2.1
182: 00109750   136 FUNC    GLOBAL DEFAULT   12 fopen@GLIBC_2.0
679: 0005d0c0    50 FUNC    GLOBAL DEFAULT   12 _IO_fopen@@GLIBC_2.1
680: 00109750   136 FUNC    GLOBAL DEFAULT   12 _IO_fopen@GLIBC_2.0

这是我的问题:

  1. 为什么/lib32/libc.so.6中有两个fopen符号?应该禁止在同一目标文件中使用相同的符号,对吗?

  1. why /lib32/libc.so.6 has two fopen symbol in it ? identical symbol in same target file should be forbidden ,right?

为什么readelf -s转储了fopen @@ GLIBC_2.1和fopen@GLIBC_2.0而不是fopen?

why readelf -s dump out fopen@@GLIBC_2.1 and fopen@GLIBC_2.0 instead of fopen?

谢谢

推荐答案

实际上,同一符号的多个定义很好,并且可以以多种方式发生.其中之一(此处不是这种情况)是弱符号.

Actually multiple definitions of the same symbol are fine and can happen in a number of ways. One of them (which isn't the case here) are weak symbols.

这里发生的事情是glibc动态链接器支持符号版本控制,而glibc使用它.它从glibc 2.1导出fopen版本,并从glibc 2.0导出具有不同接口的向后兼容版本.

What happens here is that glibc dynamic linker supports symbol versioning and glibc uses that. It exports a version of fopen from glibc 2.1 and a backward compatible version from glibc 2.0 with difference interfaces.

在动态链接时,应用程序可以选择特定版本或默认版本.

At dynamic link time the application can chose a specific version or a default one.

这篇关于为什么/lib32/libc.so.6具有两个"fopen"?符号在里面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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