主题 : lighttpd移植到ARM运行提示Illegal instruction错误 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 1330
精华: 0
发帖: 39
金钱: 390 两
威望: 139 点
综合积分: 78 分
注册时间: 2008-08-18
最后登录: 2011-02-07
楼主  发表于: 2009-11-25 19:26

 lighttpd移植到ARM运行提示Illegal instruction错误

采用的工具链是CodeSourcery出品的arm-none-linux-gnueabi系列。
gcc版本号4.4.1
lighttpd的版本号是1.4.25
pcre库版本号是8.0
移植过程出现的问题悉数解决,lighttpd的配置参数如下:
复制代码
  1. ./configure --host=arm-none-linux-gnueabi --prefix=/usr --without-zlib --without-bzip2

运行情况如下:
复制代码
  1. lighttpd

提示(server.c.581) No configuration available. Try using -f option.
然后执行
复制代码
  1. lighttpd -f /etc/lighttpd/lighttpd.conf

提示illegal instruction。
其实除了不加任何参数或者只加-h参数外,其他情况下都会出现illegal instruction错误。不知何故?
级别: 新手上路
UID: 1330
精华: 0
发帖: 39
金钱: 390 两
威望: 139 点
综合积分: 78 分
注册时间: 2008-08-18
最后登录: 2011-02-07
1楼  发表于: 2009-11-25 19:29
PS
lighttpd所依赖到libpcre已经复制到了/lib目录中了。lighttpd的配置文件如下,已经在PC机上验证没问题了。

复制代码
  1. 问题已解决,不是配置文件的原因,为避免大家大屏幕翻页,就把配置文件删除了。
[ 此帖被athurg在2009-11-26 11:29重新编辑 ]
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
2楼  发表于: 2009-11-25 21:53
在gcc的命令行上加上"-march=armv4t"试试
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 1330
精华: 0
发帖: 39
金钱: 390 两
威望: 139 点
综合积分: 78 分
注册时间: 2008-08-18
最后登录: 2011-02-07
3楼  发表于: 2009-11-26 11:35
应该就是你分析到到问题,按照你到提示,我在编译前设置了环境变量CFLAGS:
复制代码
  1. export CFLAGS=-march=armv4t

问题得到了解决。另外关于库搜索路径的问题,我已经通过gcc -print-search-dirs得到了答案。昨天之所以没成功,是因为我到libpcre文件名是libpcre.so.0.0.1,改成libpcre.so就可以了。不过奇怪的是运行到时候却又要改成libpcre.so.0.1

不过我总觉得这里通过设置CFLAGS的方式有点欠“优雅”,不知是否有更好的方式。  另外既然我设置了-host=arm-none-linux-gnueabi,为什么还要在gcc那里添加一个-march=armv4t啊,这样岂不是重复?我总不至于用arm-none-linux-gnueabi来编译-march=i686的吧!
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
4楼  发表于: 2009-11-26 11:45
ARM指令集之间没有向后兼容性,而S3C2440A的ARM920t核(属于armv4t指令集)已经很老了,现在默认的ARM编译器大多针对的是armv5或更新的ARM核。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 1330
精华: 0
发帖: 39
金钱: 390 两
威望: 139 点
综合积分: 78 分
注册时间: 2008-08-18
最后登录: 2011-02-07
5楼  发表于: 2009-11-26 14:46
嗯,确实。刚看了看CodeSourcery文档中也说到这个问题。sourcery默认是march=armv5te。

现在正在看他的文档,关于sysroot这一节即链接库路径设置的这部分,不知到是我没看明白还是怎么回事,实践起来总是不对。

按照文档中的说法,在编译到时候添加(sysroot即是目标板的根文件系统的路径)
复制代码
  1. -Wl,-rpath=sysroot/lib:sysroot/usr/lib \
  2. -Wl,--dynamic-linker=sysroot/lib/ld-linux.so.3

然后编译的时候,工具链会在目标板根文件系统下的lib和/usr/lib处寻找动态链接库。

就以这里的lighttpd依赖pcre为例,我在目标板的lib下有libpcre,然后在编译的时候添加上面的选项(我是把它加载CFLAGS环境变量中的),但是编译的时候还是提示找不到合适的libpcre。
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
6楼  发表于: 2009-11-27 09:26

 回 5楼(athurg) 的帖子

所有-Wl后面的参数都是传递给ld的,你最好再仔细看看ld的man描述:(注意--rpath和--sysroot是两个独立的不同参数)

-rpath dir
    Add a directory to the runtime library search path. This is used when linking an ELF executable with shared objects. All -rpath arguments are concatenated and passed to the runtime linker, which uses them to locate shared objects at runtime. The -rpath option is also used when locating shared objects which are needed by shared objects explicitly included in the link; see the description of the -rpath-link option. If -rpath is not used when linking an ELF executable, the contents of the environment variable "LD_RUN_PATH" will be used if it is defined.

    The -rpath option may also be used on SunOS. By default, on SunOS, the linker will form a runtime search patch out of all the -L options it is given. If a -rpath option is used, the runtime search path will be formed exclusively using the -rpath options, ignoring the -L options. This can be useful when using gcc, which adds many -L options which may be on NFS mounted file systems.

    For compatibility with other ELF linkers, if the -R option is followed by a directory name, rather than a file name, it is treated as the -rpath option.


--sysroot=directory
    Use directory as the location of the sysroot, overriding the configure-time default. This option is only supported by linkers that were configured using --with-sysroot.
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 70306
精华: 0
发帖: 14
金钱: 70 两
威望: 14 点
综合积分: 28 分
注册时间: 2012-05-18
最后登录: 2017-09-13
7楼  发表于: 2012-05-22 17:18

 回 楼主(athurg) 的帖子

你好,我也想把lighttpd,能指导一下吗?