本文介绍了查找其汇编指令没有调试导致非法指令错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行,我用汇编写的一个程序,我得到非法指令错误。有没有办法知道哪些指令导致错误,无需调试就是因为我的机器上运行没有调试器或任何研究与开发体系。换句话说,我编在一台机器和另一​​运行。我不能,我编译,因为它们不支持SSE4.2机器上测试我的程序。我上运行的程序的机器确实支持SSE4.2指令仍然

While running a program I've written in assembly, I get Illegal instruction error. Is there a way to know which instruction is causing the error, without debugging that is, because the machine I'm running on does not have a debugger or any developement system. In other words, I compile in one machine and run on another. I cannot test my program on the machine I'm compiling because they don't support SSE4.2. The machine I'm running the program on does support SSE4.2 instructions nevertheless.

我想这也许是因为我需要通过向其传递 -msse4.2 标记。或者你认为它不是这个原因?不知道如何告诉YASM认识到SSE4.2指令?

I think it maybe because I need to tell the assembler (YASM) to recognize the SSE4.2 instructions, just like we do with gcc by passing it the -msse4.2 flag. Or do you think its not the reason? Any idea how to tell YASM to recognize SSE4.2 instructions?

也许我应该陷阱信号,然后去code中的SA_SIGINFO,看看有什么样的非法操作的该程序一样。

Maybe I should trap the SIGILL signal and then decode the SA_SIGINFO to see what kind of illegal operation the program does.

推荐答案

其实往往你得到一个非法指令错误,不是因为你的程序包含一个非法操作code,但因为在你的程序(错误例如,一个缓冲区溢出),让您的程序跳转与简单的数据或code,但不是在运code开始的随机地址。

Actually often you get an illegal instruction error not because your program contain an illegal opcode but because there is a bug in your program (e.g., a buffer overflow) that makes your program jumps in a random address with plain data or in code but not in the start of the opcode.

这篇关于查找其汇编指令没有调试导致非法指令错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 21:22