求教:移植glibc到开发板 出现Illegal instruction错误

dunkboycaijia 2016-10-11 04:54:45
目前在做一个任务,升级开发板的glibc

编译环境使用的是Fedora-Live-Workstation-i686-23-10,基本信息如下
[user@localhost build]$ uname -a
Linux localhost.localdomain 4.2.3-300.fc23.i686 #1 SMP Mon Oct 5 16:26:47 UTC 2015 i686 i686 i386 GNU/Linux
[user@localhost build]$ gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-redhat-linux/5.1.1/lto-wrapper
目标:i686-redhat-linux
gcc 版本 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC)
[user@localhost build]$ ldd --version
ldd (GNU libc) 2.22

开发板基本信息
[root@X-Linux]:~ # uname -a
Linux X-Linux 2.6.29.6-140115DX. #3 Wed Oct 28 11:09:24 CST 2015 i586 GNU/Linux
[root@X-Linux]:~ # ldd --version
ldd (GNU libc) 2.10.1
$Copyright (C) 2009 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.
$Written by Roland McGrath and Ulrich Drepper.

编译内核
[user@localhost linux]$ cd linux-4.72
[user@localhost linux-4.7.2]$ make ARCR=x86 menuconfig
[user@localhost linux-4.7.2]$ make ARCH=x86 bzImage
编译内核头文件
[user@localhost linux-4.7.2]$ make INSTALL_HDR_PATH=/home/user/linux/headers/ headers_install
编译glibc
[user@localhost linux-4.7.2]$ cd ../build/
[user@localhost build]$ ../glibc-2.24/configure --prefix=/ --host=i486-linux --disable-profile --with-tls --without-selinux --enable-add-ons --enable-kernel=3.2.0 --with-headers=/home/user/linux/headers/include
[user@localhost build]$make
[user@localhost build]$make install_root=/home/user/linux/install

将/home/user/linux/install/lib下的所有动态库拷到开发板/lib 目录下
会有Illegal instruction

请教大神是怎么回事?

PS:之前使用Fedora11 编译glibc 2.10.1到2.15, 按此法可行。
是编译环境的而原因吗?
...全文
823 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
dunkboycaijia 2016-10-18
  • 打赏
  • 举报
回复
在网上看到这么一段 How can I compile on my fast ix86 machine a working libc for an older and slower ix86? After installing libc, programs abort with "Illegal Instruction". glibc and gcc might generate some instructions on your machine that aren't available on an older machine. You've got to tell glibc that you're configuring for e.g. i586 with adding i586 as your machine, for example: ../configure --prefix=/usr i586-pc-linux-gnu And you need to tell gcc to only generate i586 code, just add `-mcpu=i586' (just -m586 doesn't work) to your CFLAGS. Note that i486 is the oldest supported architecture since nptl needs atomic instructions and those were introduced with i486. 根据我的环境: 在configure之前加上 export CFLAGS="-g -O2 -march=i486" 然后在configure 配置里面加上i486-pc-linux-gnu 然后拷贝glibc库文件到开发板可以正常使用。
dunkboycaijia 2016-10-12
  • 打赏
  • 举报
回复
@gkcc 再请教系统版本太高具体指什么的版本? 开发板的kernel版本我升级到4.7.2了,但是不管升不升级,都会由上面错误。 其他的glibc2.24 INSTALL中有如下要求; *GCC 4.7 or higher is required. As of release time, GCC 5.3 is the newest compiler verified to work to build the GNU C Library. * GNU 'binutils' 2.22 or later.As of release time, GNU 'binutils' 2.25 is the newest verified to work to build the GNU C Library. Fedora11只 编译到glibc2,15就是因为之后版本,编译器binutils版本太低报错。 还有交叉编译具体要怎么弄啊? 刚接触好多都不太熟,还请指教。谢谢。
gkcc 2016-10-12
  • 打赏
  • 举报
回复
编译机的系统版本太高了,降回和开发板一直,或者用交叉编译

19,613

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧