OK6410A 开发板 (九) 4 buildroot-2021.02 OK6410A rootfs 中的动态链接库

rootfs中动态链接库的来源
来自于 交叉编译链
  • rootfs 中 libc.so.6 来源猜想
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
000cc0f0 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/ 

  • rootfs 中 libc.so.6 生成过程
在 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
动态链接库功能探索
  • 编译器与libc的关系
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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值