How is / usr / lib64 / libc.so created?

[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 ) )

Does anyone know how this material is generated?

+5
source share
2 answers

This is generated when compiling glibc using the Make utility.

In the glibc Makefile, there is a rule (started make install) that only echoes the necessary lines to some temporary file $@.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

And then this file will be renamed to libc.so

mv -f $@.new $@

Here is a comment from the Makefile that explains a bit:

# 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.

: libc.so.6 -, . , glibc - glibc - libc_nonshared.a. libc.so.6 libc_nonstared.a, script, 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

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. 
+7

glibc-devel / glibc-devel.i686.

-1

All Articles