rootfs中动态链接库的来源
来自于 交叉编译链
suws@ubuntu: ~ / ok6410/ system- new/ buildroot/ output$ sudo find . - name libc. so. 6 | xargs ls - l
lrwxrwxrwx 1 suws suws 12 May 30 2014 . / host/ arm- buildroot- linux- gnueabi/ sysroot/ lib/ libc. so. 6 -> libc- 2.18 . so
lrwxrwxrwx 1 root root 12 Apr 15 15 : 21 . / images/ rootfs/ lib/ libc. so. 6 -> libc- 2.18 . so
lrwxrwxrwx 1 suws suws 12 Apr 15 15 : 21 . / target/ lib/ libc. so. 6 -> libc- 2.18 . so
suws@ubuntu: ~ / ok6410/ system- new/ buildroot/ output$ sudo find . - name libc- 2.18 . so | xargs ls - l
- rwxr- xr- x 1 suws suws 1725220 May 30 2014 . / host/ arm- buildroot- linux- gnueabi/ sysroot/ lib/ libc- 2.18 . so
- rwxr- xr- x 1 root root 1271296 Apr 20 12 : 44 . / images/ rootfs/ lib/ libc- 2.18 . so
- rwxr- xr- x 1 suws suws 1271296 Apr 20 12 : 44 . / target/ lib/ libc- 2.18 . so
suws@ubuntu: ~ / ok6410/ system- new/ buildroot/ output$ nm . / target/ lib/ libc- 2.18 . so
nm: . / target/ lib/ libc- 2.18 . so: no symbols
suws@ubuntu: ~ / ok6410/ system- new/ buildroot/ output$ nm . / host/ arm- buildroot- linux- gnueabi/ sysroot/ lib/ libc- 2.18 . so | grep reboot
000 cc0f0 T reboot
suws@ubuntu: ~ / ok6410/ origin- offical/ arm- 2014.05 $ sudo find . - name libc- 2.18 . so | xargs ls - l
- rwxr- xr- x 1 suws suws 1748790 May 30 2014 . / arm- none- linux- gnueabi/ libc/ armv4t/ lib/ libc- 2.18 . so
- rwxr- xr- x 1 suws suws 1725220 May 30 2014 . / arm- none- linux- gnueabi/ libc/ lib/ libc- 2.18 . so
- rwxr- xr- x 1 suws suws 1398636 May 30 2014 . / arm- none- linux- gnueabi/ libc/ thumb2/ lib/ libc- 2.18 . so
看起来 buildroot 生成的rootfs/ lib 中的内容 应该是 源自于 的 ~ / ok6410/ origin- offical/ arm- 2014.05 / arm- none- linux- gnueabi/ libc/ lib/
在 target toolchain- external- custom 中
>> > toolchain- external- custom Extracting
>> > toolchain- external- custom Patching
>> > toolchain- external- custom Configuring
>> > toolchain- external- custom Building
>> > toolchain- external- custom Installing to staging directory
A>> > toolchain- external- custom Copying external toolchain sysroot to staging. . .
>> > toolchain- external- custom Installing gdbinit
>> > toolchain- external- custom Fixing libtool files
>> > toolchain- external- custom Installing to target
B>> > toolchain- external- custom Copying external toolchain libraries to target. . .
主要过程是
A : rsync / home/ suws/ ok6410/ origin- offical/ arm- 2014.05 / arm- none- linux- gnueabi/ libc/ 中的 etc lib sbin usr usr/ lib 到 STAGING_DIR
toolchain/ toolchain- external/ pkg- toolchain- external. mk 中的 TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS
toolchain/ helpers. mk 中的 copy_toolchain_sysroot
B : 拷贝 STAGING_DIR 中 的 ld* . so. * libgcc_s. so. * libatomic. so. * libc. so. * libcrypt. so. * libdl. so. * libm. so. * libnsl. so. * libresolv. so. * librt. so. * libutil. so. * libpthread. so. * libnss_files. so. * libnss_dns. so. * libmvec. so. * libanl. so. * libstdc++ . so. * 到 TARGET_DIR
toolchain/ toolchain- external/ pkg- toolchain- external. mk 中的 TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS
toolchain/ helpers. mk 中的 copy_toolchain_lib_root
rootfs 中 libc.so.6 strip 过程
- rwxr- xr- x 1 suws suws 1725220 May 30 2014 . / host/ arm- buildroot- linux- gnueabi/ sysroot/ lib/ libc- 2.18 . so
- rwxr- xr- x 1 root root 1271296 Apr 20 12 : 44 . / images/ rootfs/ lib/ libc- 2.18 . so
可以看到 . / images/ rootfs/ lib/ libc- 2.18 . so 的大小和 . / host/ arm- buildroot- linux- gnueabi/ sysroot/ lib/ libc- 2.18 . so 是不一样, 且 . / images/ rootfs/ lib/ libc- 2.18 . so 没有调试符号 , 所以应该经过了 strip
TODO
动态链接库功能探索
gcc 和 libc 是互相依赖的两个软件,它们合作的方式类似 Linux 系统的 "自举" 。
先在一个可以运行的带有老 libc 和 gcc 的系统上,用老 gcc 编译出一个新版本的 gcc + 老 libc
再用这个新 gcc 编译出一个新 gcc + 新 libc,再用这套东东编译整个新系统。
至于 x86上运行的的交叉arm的编译器 ( 会有几套glibc? )
# / lib/ libc. so. 6
GNU C Library ( Sourcery CodeBench Lite 2014.05 - 29 ) stable release version 2.18 , by Roland McGrath et al.
Copyright ( C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.8 .3 20140320 ( prerelease) .
Compiled on a Linux 3.13 .0 system on 2014 - 05 - 30.
$ ldd / bin/ busybox
not a dynamic executable
busybox 是 静态链接的, 那么 / bin/ busybox 二进制文件 中有 reboot函数的定义
该 reboot 函数的定义来自于 arm- none- linux- gnueabi- gcc工具链( 包括gcc和glibc)