免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2061 | 回复: 1
打印 上一主题 下一主题

一个进行系统调用的函数在编译时出这样的错 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-12-14 12:53 |只看该作者 |倒序浏览
#include <stdio.h>
#include <linux/unistd.h>
_syscall2(unsigned int,Buzzer,int,cmd,unsigned int,value)

int main(int argc,char *argv[])
{
        unsigned int nRes;
        if(argc==0)
        {
                nRes = Buzzer(0,0);
                printf("Buzzer is %s\n", nRes == 1 ? "opened":"closed");
        }
        else
        {
                switch(*argv[1])
                {
                case 'o':
                        nRes = Buzzer(1,1);
                        printf("Buzzer is %s\n", nRes == 1 ? "opened":"closed");
                        break;
                case 'c':
                        nRes = Buzzer(1,0);
                        printf("Buzzer is %s\n", nRes == 1 ? "opened":"closed");
                        break;
                default:
                        printf("Usage: Buzzer [c|o]\n");
                        return 0;
                }
        }
        return (int)nRes;
}


编译命令如下:
arm-linux-gcc  -o Buzzer Buzzer.c

出现这个错误:
/tmp/ccwH0a1u.s: Assembler messages:
/tmp/ccwH0a1u.s:21: Error: Cannot represent SWI relocation in this object file format

这是什么原因哦?

论坛徽章:
0
2 [报告]
发表于 2006-12-14 13:55 |只看该作者
问题已经解决,谢谢各位。
原因在于arm的软中断指令swi只能带立即数,所以在编译命令中加入-E参数就可以解决这个问题了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP