简体   繁体   English

运行x86可执行文件时出现错误“ 16434非法硬件指令./a.out”

[英]Error “16434 illegal hardware instruction ./a.out” when running x86 executable

I'm learning the basics of x86 via this free book . 我正在通过这本免费书籍学习x86的基础知识。

Keep in mind this is specific to macOS x86 compared to Linux x86. 请记住,与Linux x86相比,这特定于macOS x86。

Its made for GNU Linux, so I have to change some of the code which is probably where I went wrong. 它是为GNU Linux设计的,因此我必须更改一些代码,这可能是我出错的地方。 I took this code snippet: 我使用了以下代码片段:

.section .data
 .section .text
 .globl _start
_start:
movl $1, %eax
movl $0, %ebx
int $0x80

After a bit of googling about x86 on macOS I turned that bit of code into this: 在macOS上对x86进行了一些搜索之后,我将这段代码变成了:

    .data
    .text
    .globl _main
_main:
    movl $1, %eax
    movl $0, %ebx
    int $0x80

I compiled this using gcc test.s which compiles it into a.out . 我使用gcc test.s文件编译为a.out When trying to run it using ./a.out I get the error [1] 17301 illegal hardware instruction ./a.out . 尝试使用./a.out运行它时,出现错误[1] 17301 illegal hardware instruction ./a.out

Any help is appreciated, thanks! 任何帮助表示赞赏,谢谢!

@Jester helped me out. @杰斯特帮助了我。 You can view the comment on my question, but basically call convention is different for macOS. 您可以查看有关我的问题的评论,但是对于macOS,基本上调用约定是不同的。 I found this resource which helped me out. 我发现这个资源这让我出去。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 c 中连接两个字符串时出现非法硬件指令错误 - illegal hardware instruction error when concatenating two strings in c GStreamer非法硬件指令 - GStreamer illegal hardware instruction 在gfortran mac中运行openMP时出现非法指令错误 - Illegal instruction error when running openMP in gfortran mac 进行顺序 C 调用时,在 MacOS 上的 x86 程序集中出现堆栈对齐错误? - Getting stack alignment error in x86 Assembly on MacOS when making sequential C calls? Mayavi在MacOS 10.12上因“非法硬件指令”而崩溃 - Mayavi crashes with “Illegal hardware instruction” on MacOS 10.12 尝试在OS X中使用virtualenv启动Python时出现“非法指令:4” - “Illegal instruction: 4” when trying to start Python with virtualenv in OS X NASM:x86到PPC-表达式语法错误 - NASM: x86 to PPC - expression syntax error 在 macOS 上使用 Xcode 作为 root 运行应用程序时出现非法指令 (ud2) - Illegal instruction (ud2) when running application with Xcode as root on macOS Laravel 工匠迁移错误:“zsh:非法硬件指令 php 工匠迁移” - Laravel artisan migrate error: “zsh: illegal hardware instruction php artisan migrate” “zsh:非法硬件指令 python”当 Tensorflow 在 macbook pro M1 上 - “zsh: illegal hardware instruction python” when Tensorflow on macbook pro M1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM