[root@xx test]# cat /usr/lib64/libc.so
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) )
Run Code Online (Sandbox Code Playgroud)
谁知道这种东西是如何产生的?
使用Make实用程序编译glibc时会生成此错误.
make install在glibc的Makefile中有一条规则(由...开始),它只需将所需的行回显到一些临时文件中$@.new:
(echo '/* GNU ld script';\
echo ' Use the shared library, but some functions are only in';\
echo ' the static library, so try that secondarily. */';\
cat $<; \
echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
'$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
' AS_NEEDED (' $(slibdir)/$(rtld-installed-name) ') )' \
) > $@.new
Run Code Online (Sandbox Code Playgroud)
然后将此文件重命名为 libc.so
mv -f $@.new $@
Run Code Online (Sandbox Code Playgroud)
这是Makefile的注释,它解释了一下:
# What we install as libc.so for programs to link against is in fact a
# link script. It contains references for the various libraries we need.
# The libc.so object is not complete since some functions are only defined
# in libc_nonshared.a.
# We need to use absolute paths since otherwise local copies (if they exist)
# of the files are taken by the linker.
Run Code Online (Sandbox Code Playgroud)
我理解为:libc.so.6不完整,需要一些东西,不能存储在共享库中.所以,glibc开发人员将这个东西移到glibc的静态部分 - libc_nonshared.a.要强制始终联系两者的libc.so.6和libc_nonstared.a,他们创造了一个特殊链接脚本命令LD链接器同时使用时,它要求-lc(的libc)
什么是非共享部分?让我们检查:
$ objdump -t /usr/lib/libc_nonshared.a |grep " F "|grep -v __
00000000 g F .text 00000058 .hidden atexit
00000000 w F .text 00000050 .hidden stat
00000000 w F .text 00000050 .hidden fstat
00000000 w F .text 00000050 .hidden lstat
00000000 g F .text 00000050 .hidden stat64
00000000 g F .text 00000050 .hidden fstat64
00000000 g F .text 00000050 .hidden lstat64
00000000 g F .text 00000050 .hidden fstatat
00000000 g F .text 00000050 .hidden fstatat64
00000000 w F .text 00000058 .hidden mknod
00000000 g F .text 00000050 .hidden mknodat
00000000 l F .text 00000001 nop
Run Code Online (Sandbox Code Playgroud)
有atexit(),*stat*(),mknod等功能.为什么?真的不知道,但这是glibc的事实.
这里有一些长篇解释http://giraffe-data.com/~bryanh/giraffehome/d/note/proglib,我引用它的开头:
The stat() family of functions and mknod() are special. Their
interfaces are tied so tightly to the underlying operating system that
they change occasionally.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5024 次 |
| 最近记录: |