第4节 编译binutils 64位 pass1
现在用lfs用户所在的系统的gcc做出/tools/bin/x86_64-lfs-linux-gnu-{ld,ar,as,readelf,ranlib,objcopy}等,还有 /tools/lib/libibery.a 。
命令如下:
tar xvfj ../binutils-2.21.1a.tar.bz2
mkdir binutils-build-p1-x86_64
cd binutils-build-p1-x86_64
../binutils-2.21.1/configure \
--target=$LFS_TGT --prefix=/tools \
--disable-nls --disable-werror --libdir=/tools/lib64
查看config.log,看到以下内容:
configure:4268: checking whether we are cross compiling
configure:4270: result: no
CC='gcc'
CC_FOR_BUILD='$(CC)'
GCC_FOR_TARGET='x86_64-lfs-linux-gnu-gcc'
说明成功配置成非交叉编译,也成功指定了--target 。
make LIB_PATH=/tools/lib64 2>&1|tee out.make
make install DESTDIR=$(pwd)/img 2>&1|tee out.install
mv img/tools/lib/* img/tools/lib64
rm -rf img/tools/lib
cp -rfv img/tools/* /tools/
cd ..
通过DESTDIR=,将编译结果先安装到img目录下,而不是直接安装到/tools里,使得有机会对lib的目录进行调整,然后再拼装到/tools目录下。
下面查验生成的ld:
file /tools/bin/$LFS_TGT-ld
/tools/bin/x86_64-lfs-linux-gnu-ld: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
说明它是一个64位的elf可执行文件。
ldd /tools/bin/$LFS_TGT-ld
linux-vdso.so.1 => (0x00007fff6f058000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fc2a6a92000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fc2a688e000)