版权声明:本文为博主原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1344530
在
http://wiki.ok-labs.com/Microkernel
下载
arm-linux-gnueabi-4.2.4.tar.gz,sdk-xscale-3.0.tar.gz,Skyeye 1.2.1n和skyeye.conf,并按照tut-sdk-singlecell.pdf来操作, 并把
export PATH=$PATH:`pwd`/arm-unknown-linux-gnueabi/bin
加入到PATH环境变量中。
进入singlecell目录,执行make命令,得到如下错误:
make -C hello KERNEL=micro BUILD=debug
make[1]: 进入目录“/home/xuzhina/Downloads/singlecell/hello”
cp hello.xml.in build.micro-debug/bin/hello.xml
make[1]: arm-unknown-linux-gnueabi-gcc:命令未找到
arm-unknown-linux-gnueabi-ld -o build.micro-debug/bin/hello -Ttext=0x80000000 -L/home/xuzhina/Downloads/sdk/okl4/xscale/micro-debug/libs
/home/xuzhina/Downloads/sdk/okl4/xscale/micro-debug/libs/crt0.o build.micro-debug/src/hello.o
--start-group /home/xuzhina/Downloads/sdk/okl4/xscale/micro-debug/libs/libc.a
/home/xuzhina/Downloads/sdk/okl4/xscale/micro-debug/libs/libokl4.a --end-group
make[1]: arm-unknown-linux-gnueabi-ld:命令未找到
make[1]: *** [build.micro-debug/bin/hello] 错误 127
make[1]: 离开目录“/home/xuzhina/Downloads/singlecell/hello”
make: *** [hello/build.micro-debug/bin/hello.xml] 错误 2
很奇怪,怎么会找不到呢?执行一下
arm-unknown-linux-gnueabi
并按TAB键,出现这样的结果:
[xuzhina@localhost singlecell]$ arm-unknown-linux-gnueabi-
arm-unknown-linux-gnueabi-addr2line arm-unknown-linux-gnueabi-gprof
arm-unknown-linux-gnueabi-ar arm-unknown-linux-gnueabi-ld
arm-unknown-linux-gnueabi-as arm-unknown-linux-gnueabi-nm
arm-unknown-linux-gnueabi-c++ arm-unknown-linux-gnueabi-objcopy
arm-unknown-linux-gnueabi-c++filt arm-unknown-linux-gnueabi-objdump
arm-unknown-linux-gnueabi-cpp arm-unknown-linux-gnueabi-ranlib
arm-unknown-linux-gnueabi-g++ arm-unknown-linux-gnueabi-readelf
arm-unknown-linux-gnueabi-gcc arm-unknown-linux-gnueabi-size
arm-unknown-linux-gnueabi-gcc-4.2.4 arm-unknown-linux-gnueabi-strings
arm-unknown-linux-gnueabi-gccbug arm-unknown-linux-gnueabi-strip
arm-unknown-linux-gnueabi-gcov
也就是说,命令是可以找到,为什么找不到呢?
把上面的错误信息中一条命令拷贝出来执行一下,
arm-unknown-linux-gnueabi-ld -o build.micro-debug/bin/hello -Ttext=0x80000000 -L/home/xuzhina/Downloads/sdk/okl4/xscale/micro-debug/libs
/home/xuzhina/Downloads/sdk/okl4/xscale/micro-debug/libs/crt0.o build.micro-debug/src/hello.o
--start-group /home/xuzhina/Downloads/sdk/okl4/xscale/micro-debug/libs/libc.a
/home/xuzhina/Downloads/sdk/okl4/xscale/micro-debug/libs/libokl4.a --end-group
出现这样的错误信息:
bash: /home/xuzhina/Downloads/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-ld: /lib/ld-linux.so.2: bad ELF interpreter: 没有那个文件或目录
一般来说,程序执行,要先由加载器把它加载到内存里,创建了进程空间,才能够执行的。从上面错误,可以看到是没有加载器,所以无法解析这个可执行文件
那为什么其它程序可以执行,比如/bin/ls?
先看一下arm-unknown-linux-gnueabi-ld和/bin/ls的类型:
[xuzhina@localhost singlecell]$ file /home/xuzhina/Downloads/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-ld
/home/xuzhina/Downloads/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-ld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped
[xuzhina@localhost singlecell]$ file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0xec333a104e045327c5e3d0ca6dda16c610a210f3, stripped
可以看到,arm-unknown-linux-gnueabi-ld是32位的程序,/bin/ls是64位的程序。
但64位系统不是兼容运行32位程序吗?难道64位程序的加载器不一样。看一下两者的ldd结果。
[xuzhina@localhost singlecell]$ ldd /bin/ls
linux-vdso.so.1 => (0x00007fffbf1fe000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fe71af3b000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007fe71ad36000)
libacl.so.1 => /lib64/libacl.so.1 (0x00007fe71ab2c000)
libc.so.6 => /lib64/libc.so.6 (0x00007fe71a76b000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fe71a50a000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fe71a2e4000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fe71a0e0000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe71b178000)
libattr.so.1 => /lib64/libattr.so.1 (0x00007fe719edb000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fe719cbe000)
[xuzhina@localhost singlecell]$ ldd /home/xuzhina/Downloads/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-ld
不是动态可执行文件
[xuzhina@localhost singlecell]$ ls /lib/ld-linux.so.2
ls: 无法访问/lib/ld-linux.so.2: 没有那个文件或目录
也就是说,要64位系统能够运行32位程序,还得安装32位的加载器。
那么,ld-linux.so.2是在哪个软件包呢,由于我的系统是centos 7,所以,我从rpmfind.net知道ld-linux.so.2属于glibc.i686。
安装了glibc.i686之后,再重新make,得到下面的结果:
[xuzhina@localhost singlecell]$ make
make -C hello KERNEL=micro BUILD=debug
make[1]: 进入目录“/home/xuzhina/Downloads/singlecell/hello”
cp hello.xml.in build.micro-debug/bin/hello.xml
arm-unknown-linux-gnueabi-ld -o build.micro-debug/bin/hello -Ttext=0x80000000 -L/home/xuzhina/Downloads/sdk/okl4/xscale/micro-debug/libs /home/xuzhina/Downloads/sdk/okl4/xscale/micro-debug/libs/crt0.o build.micro-debug/src/hello.o --start-group /home/xuzhina/Downloads/sdk/okl4/xscale/micro-debug/libs/libc.a /home/xuzhina/Downloads/sdk/okl4/xscale/micro-debug/libs/libokl4.a /home/xuzhina/Downloads/arm-unknown-linux-gnueabi/bin/../lib/gcc/arm-unknown-linux-gnueabi/4.2.4/libgcc.a --end-group
make[1]: 离开目录“/home/xuzhina/Downloads/singlecell/hello”
问题解决。