建议学习Linux的x86-64的装配和放大器;文件 [英] Advice for learning Linux x86-64 assembly & documentation

查看:229
本文介绍了建议学习Linux的x86-64的装配和放大器;文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有文件关于学习Linux的X86-64装配的基本面?我不知道是否要学习它原样,还是先学习X86,后来又学习它,但被我拥有的x86-64计算机,而不是86,我在想学习的x86-64代替; )

Does anyone have documentation pertaining to learning the fundamentals of Linux x86-64 assembly? I'm not sure whether or not to learn it as is, or to learn x86 first, and learn it later, but being as I have an x86-64 computer and not an x86, I was thinking of learning x86-64 instead ;)

也许有人可以给我一些鼓励,和方向,学习什么,如何,以怎样的文档。

Maybe someone could give me some incentive, and direction as to learning what, how, and with what documentation.

请给我你最被看好的文档标题,我code一点点的Python,这是我在一个较低的水平语言的第一次尝试,我多准备奉献给它。

Kindly give me your most favoured documentation titles, I code a little Python, this is my first attempt at a lower level language, and I'm more than ready to dedicate to it.

感谢所有

推荐答案

这不仅是x86汇编。每个汇编是一个有点不同,他们一般不相互兼容。我推荐的NASM汇编程序,因为它被广泛使用,安装方便,并支持64位程序集。

General advice:

It isn't just "x86 assembler". Each assembler is a bit different and they are not generally compatible with each other. I recommend the NASM assembler because it is widely used, easy to install, and supports 64bit assembly.

阅读x86汇编一本好书,去感受的基础知识(寄存器,条件跳转,算术等)。我通过兰德尔海德读大会的的的艺术当我开始了。

Read a good book on x86 assembler to get a feel for the basics (registers, conditional jumps, arithmetic, etc). I read Art of Assembly by Randall Hyde when I was starting out.

http://asm.sourceforge.net 看起来有,你可能会想工作的一些好的教程通过。但是,如果你在64位模式组装,谨防对于C函数和系统调用的调用约定是不同的。

http://asm.sourceforge.net looks like it has some good tutorials that you might want to work through. But if you are assembling in 64bit mode, beware that the calling convention for C functions and syscalls is different.

您将需要CPU参考手册。就个人而言,我preFER了AMD的。你想卷1和CPU手册3。其他卷可能会感兴趣的为好。

You will need the CPU reference manuals. Personally, I prefer the AMD ones. You want volumes 1 and 3 of the CPU manual. The other volumes might be of interest as well.

64 86装配是几乎相同的32位的x86组件中,由于64位的86主要是向后与32位兼容。您可以访问64位寄存器和其他一些功能,一些模糊的指令不再有效,其余的是相同的32位。

64bit x86 assembly is almost the same as 32bit x86 assembly, since 64bit x86 is mostly backwards compatible with 32bit. You get access to the 64bit registers and a few other features, some obscure instructions are no longer valid, and the rest is the same as 32bit.

但是,系统调用约定的完全的在64位Linux的不同。取决于你的内核,32位的系统调用可以是或可以不是可用的。更糟糕的是,64位调用约定不良记录。我只理解了它通过检查glibc的源$ C ​​$ C的深处。

However, the syscall convention is completely different on 64bit Linux. Depending on your kernel, the 32bit syscalls may or may not be available. What's worse is that the 64bit calling convention is poorly documented. I only figured it out by examining the depths of the glibc source code.

要救你找到这个硬盘的方式带来的麻烦,系统调用的数字是在Linux源$ C ​​$ C下弓/ 86 /有/ ASM / unistd_64.h 。系统调用号在 RAX 寄存器传递。该参数在 RDI RSI RDX R10 R8 R9 。该呼叫调用与系统调用指令。在系统调用覆盖 RCX 注册。返回是 RAX 。 (一个简单的例子可以这里找到。)

To save you the hassle of finding this out the hard way, The syscall numbers are in the Linux source code under arch/x86/include/asm/unistd_64.h. The syscall number is passed in the rax register. The parameters are in rdi, rsi, rdx, r10, r8, r9. The call is invoked with the syscall instruction. The syscall overwrites the rcx register. The return is in rax. (A brief example can be found here.)

这篇关于建议学习Linux的x86-64的装配和放大器;文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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