为什么在系统调用NASM 32位输出编译而波帕不在64位编译? [英] Why does syscall compile in NASM 32 bit output while popa does not compile in 64 bit?

查看:469
本文介绍了为什么在系统调用NASM 32位输出编译而波帕不在64位编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的<一个href=\"http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf\"相对=nofollow>英特尔手动说:


  • 系统调用指令是兼容模式(32位)
  • 无效
  • 波帕是64位模式
  • 无效
  • the syscall instruction is invalid for compatibility mode (32-bit)
  • popa is invalid for 64-bit mode

那么,有一个原因,NASM:

So is there a reason why NASM:


  • 给出一个编译错误在64位模式下不支持指令如果我使用波帕 -f ELF64

  • 不给给一个编译错误,如果我使用系统调用 -f ELF32 。如果我运行可执行文件,我得到如预期非法指令(核心转储)。

  • gives a compilation error instruction not supported in 64-bit mode if I use popa with -f elf64
  • does not give give a compilation error if I use syscall with -f elf32. If I run the executable I get Illegal instruction (core dumped) as expected.

为什么要区别对待这两个个案?

Why treat those two cases differently?

(应该是不可知的操作系统)。

Tested with NASM version 2.10.09 on Ubuntu 14.04 (should be OS agnostic).

推荐答案

由于该系统调用指令存在(的作品)了。历史上,英特尔使用了 SYSENTER 指令,但是当AMD想出的64位扩展,他们用自己的系统调用所以当英特尔接手扩展,他们也开始支持系统调用,但只在64位模式。

Because the syscall instruction exists (and works) on AMD processors in 32 bit mode too. Historically, Intel used the sysenter instruction, but when AMD came up with the 64 bit extension, they used their own syscall and so when Intel took over the extensions, they also started supporting syscall, but only in 64 bit mode.

这篇关于为什么在系统调用NASM 32位输出编译而波帕不在64位编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆