最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Cygwin下用arm-xscale-linux-gnueabi交叉编译Linux内核在配置时出错:/bin/sh: scripts/basic/fixdep: cannot execute binary file

Cygwin crifan 5913浏览 0评论

【问题】

折腾:

【记录】Cygwin下用arm-xscale-linux-gnueabi交叉编译Linux内核

期间,解决了:

【已解决】Cygwin下配置Linux内核出错:Makefile:419: *** mixed implicit and normal rules. Stop.

后,又出现错误:

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ make whgs_defconfig
  HOSTCC  scripts/basic/fixdep
scripts/basic/fixdep.c: In function ‘parse_config_file’:
scripts/basic/fixdep.c:242:4: warning: array subscript has type ‘char’ [-Wchar-subscripts]
scripts/basic/fixdep.c: In function ‘parse_dep_file’:
scripts/basic/fixdep.c:319:4: warning: array subscript has type ‘char’ [-Wchar-subscripts]
scripts/basic/fixdep.c: In function ‘traps’:
scripts/basic/fixdep.c:371:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
scripts/basic/fixdep.c:373:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
/bin/sh: scripts/basic/fixdep: cannot execute binary file
make[1]: *** [scripts/basic/fixdep] Error 126
make: *** [scripts_basic] Error 2

如图:

bin sh scripts basic fixdep cannot execute binary file

【解决过程】

1.去看了看对应的那个文件:

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ ls scripts/basic/fixdep
fixdep      fixdep.c    fixdep.exe

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ ls scripts/basic/fixdep* -lha
-rwxr-xr-x 1 CLi Domänen-Benutzer 9.2K Nov  7  2012 scripts/basic/fixdep*
-rw-r--r-- 1 CLi Domänen-Benutzer 9.4K Oct 17  2012 scripts/basic/fixdep.c
-rwxr-xr-x 1 CLi Domänen-Benutzer  61K Aug 22 16:44 scripts/basic/fixdep.exe*

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ users

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ whoami
CLi

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ file scripts/basic/fixdep
scripts/basic/fixdep: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ file scripts/basic/fixdep.exe
scripts/basic/fixdep.exe: PE32 executable (console) Intel 80386, for MS Windows

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$

好像是:

scripts/basic/fixdep.exe:是cygwin下面可以执行的;

而:

scripts/basic/fixdep :是在Linux下才可以执行

 

2.这人:

Cross-compiling Linux kernel for ARM on Windows using Sourcery Toolchain

遇到类似问题。

然后参考别人说法,试试再次添加ARCH和CROSS_COMPILE,看看是否有效,结果问题依旧:

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ make whgs_defconfig ARCH=arm CROSS_COMPILE=arm-xscale-linux-gnueabi-
  HOSTCC  scripts/basic/fixdep
scripts/basic/fixdep.c: In function ‘parse_config_file’:
scripts/basic/fixdep.c:242:4: warning: array subscript has type ‘char’ [-Wchar-subscripts]
scripts/basic/fixdep.c: In function ‘parse_dep_file’:
scripts/basic/fixdep.c:319:4: warning: array subscript has type ‘char’ [-Wchar-subscripts]
scripts/basic/fixdep.c: In function ‘traps’:
scripts/basic/fixdep.c:371:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
scripts/basic/fixdep.c:373:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
/bin/sh: scripts/basic/fixdep: cannot execute binary file
make[1]: *** [scripts/basic/fixdep] Error 126
make: *** [scripts_basic] Error 2

3.去试了试,此处:

scripts/basic/fixdep

没法在cygwin下运行:

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ scripts/basic/fixdep
bash: scripts/basic/fixdep: cannot execute binary file

然后试试exe能否运行,然后是可以的:

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ scripts/basic/fixdep.exe
Usage: fixdep <depfile> <target> <cmdline>

所以,可以想办法,用fixdep.exe 代替此处的fixdep

或者是把两者改名:

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ mv scripts/basic/fixdep.exe scripts/basic/fixdep.exe_backup

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ mv scripts/basic/fixdep scripts/basic/fixdep_backup

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ cp scripts/basic/fixdep.exe_backup scripts/basic/fixdep

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ ls scripts/basic/fixdep* -lha
-rwxr-xr-x 1 CLi Domänen-Benutzer  61K Aug 22 17:08 scripts/basic/fixdep*
-rw-r--r-- 1 CLi Domänen-Benutzer 9.4K Oct 17  2012 scripts/basic/fixdep.c
-rwxr-xr-x 1 CLi Domänen-Benutzer  61K Aug 22 17:03 scripts/basic/fixdep.exe_backup*
-rwxr-xr-x 1 CLi Domänen-Benutzer 9.2K Nov  7  2012 scripts/basic/fixdep_backup*

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ file scripts/basic/fixdep
scripts/basic/fixdep: PE32 executable (console) Intel 80386, for MS Windows

然后再去配置看看,或许就可以了。

结果的确可以了,至少此处暂时解决此问题了:

CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1
$ make whgs_defconfig
  HOSTCC  scripts/basic/fixdep
scripts/basic/fixdep.c: In function ‘parse_config_file’:
scripts/basic/fixdep.c:242:4: warning: array subscript has type ‘char’ [-Wchar-subscripts]
scripts/basic/fixdep.c: In function ‘parse_dep_file’:
scripts/basic/fixdep.c:319:4: warning: array subscript has type ‘char’ [-Wchar-subscripts]
scripts/basic/fixdep.c: In function ‘traps’:
scripts/basic/fixdep.c:371:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
scripts/basic/fixdep.c:373:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  HOSTCC  scripts/basic/docproc

如图:

fixdep can run now after rename

 

【总结】

cygwin下,去交叉编译linux内核,去配置时,出现错误:

/bin/sh: scripts/basic/fixdep: cannot execute binary file

的原因是:

Host的gcc,此处为cygwin中的gcc,编译fixdep.c出两个文件:

scripts/basic/fixdep: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped

scripts/basic/fixdep.exe: PE32 executable (console) Intel 80386, for MS Windows

很明显,此处fixdep是无法再cygwin下运行的。

由于fixdep.exe可以在cygwin下运行,所以,

解决办法是:

把fixdep.exe,改名为fixdep,就可以暂时解决此问题了。

个人觉得,此解决办法不够好,不够彻底。

也许以后(自己或别人)能找到更好的办法。

转载请注明:在路上 » 【已解决】Cygwin下用arm-xscale-linux-gnueabi交叉编译Linux内核在配置时出错:/bin/sh: scripts/basic/fixdep: cannot execute binary file

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.237 seconds, using 22.17MB memory