[Linux From Scratch 作一个自己的Linux操作系统发行版本]二、编译binutils

本文详细介绍了在Linux环境下从源代码构建binutils工具集的过程,包括确认构建环境、执行构建指令及验证安装步骤。binutils是GNU项目下的一组链接器、汇编器和其他二进制工具,对于Linux系统的开发和维护至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、确认构建环境

1. 确认$LFS变量

lfs:~$ echo $LFS
/mnt/lfs

2. 确认用户

lfs:~$ whoami
lfs

3. 确认进入home目录

lfs:~$ cd ~
lfs:~$ pwd
/home/lfs

二、执行构建指令

#!/bin/bash

tar -jxf $LFS/sources/binutils-2.27.tar.bz2
(
	cd binutils-2.27/
	mkdir -v build    
	cd build
	../configure --prefix=/tools \
	    --with-sysroot=$LFS \
	    --with-lib-path=/tools/lib \
	    --target=$LFS_TGT \
	    --disable-nls \
	    --disable-werror    
	make -j12

	case $(uname -m) in
	x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;;
	esac

	make install    
)
rm -fr binutils-2.27/

三、验证安装

lfs:~/binutils-2.27/build$ find $LFS/tools
/mnt/lfs/tools
/mnt/lfs/tools/share
/mnt/lfs/tools/share/info
/mnt/lfs/tools/share/info/as.info
/mnt/lfs/tools/share/info/binutils.info
/mnt/lfs/tools/share/info/gprof.info
/mnt/lfs/tools/share/info/bfd.info
/mnt/lfs/tools/share/info/ld.info
/mnt/lfs/tools/share/man
/mnt/lfs/tools/share/man/man1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-c++filt.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-as.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-nm.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-nlmconv.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-windmc.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-elfedit.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-gprof.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-objdump.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-windres.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-strip.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-objcopy.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-ar.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-ld.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-addr2line.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-dlltool.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-size.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-readelf.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-strings.1
/mnt/lfs/tools/share/man/man1/x86_64-lfs-linux-gnu-ranlib.1
/mnt/lfs/tools/lib
/mnt/lfs/tools/lib64
/mnt/lfs/tools/bin
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-objdump
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-strip
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-ar
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-addr2line
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-c++filt
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-ranlib
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-gprof
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-as
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-ld
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-nm
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-size
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-elfedit
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-strings
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-readelf
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-objcopy
/mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-ld.bfd
/mnt/lfs/tools/x86_64-lfs-linux-gnu
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.xr
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.xc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.xc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.xsc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.xs
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.xdc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.xw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.xu
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.xsw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.xdc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.xd
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.xu
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.x
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/i386linux.xu
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.xs
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.xdw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.xsc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.xw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.xbn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.x
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.xsc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.xu
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.xn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.xd
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/i386linux.x
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.x
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.xdw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.xsw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.xr
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.xs
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.xsw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.xc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.xbn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.xr
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.xr
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.xdw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.xw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.xbn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.x
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.xsc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.xd
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.xdc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.xbn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.xdc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.xdw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.xw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.xd
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.xbn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.xdw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.xc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.xu
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.xd
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.xn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.xs
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.xn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.xn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.xdc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.xsw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.xs
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.xc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.xr
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.xdc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.xw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.xs
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.xn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/i386linux.xbn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/i386linux.xr
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.xc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/i386linux.xn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.xsc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.xd
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_i386.xw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.x
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.xu
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_iamcu.xsw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.x
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_l1om.xdw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.xr
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.xbn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.xu
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_k1om.xn
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf32_x86_64.xsw
/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib/ldscripts/elf_x86_64.xsc
/mnt/lfs/tools/x86_64-lfs-linux-gnu/bin
/mnt/lfs/tools/x86_64-lfs-linux-gnu/bin/strip
/mnt/lfs/tools/x86_64-lfs-linux-gnu/bin/objdump
/mnt/lfs/tools/x86_64-lfs-linux-gnu/bin/readelf
/mnt/lfs/tools/x86_64-lfs-linux-gnu/bin/nm
/mnt/lfs/tools/x86_64-lfs-linux-gnu/bin/as
/mnt/lfs/tools/x86_64-lfs-linux-gnu/bin/ld
/mnt/lfs/tools/x86_64-lfs-linux-gnu/bin/ranlib
/mnt/lfs/tools/x86_64-lfs-linux-gnu/bin/objcopy
/mnt/lfs/tools/x86_64-lfs-linux-gnu/bin/ld.bfd
/mnt/lfs/tools/x86_64-lfs-linux-gnu/bin/ar

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值