Linux x86-64程序集的学习建议文件 [英] Advice for learning Linux x86-64 assembly & documentation

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

问题描述

有没有人有关于学习Linux x86-64程序集基础知识的文档?我不知道是否按原样学习,还是首先学习x86,稍后学习,但是像我有一个x86-64的计算机,而不是x86,我正在考虑学习x86-64; )



也许有人可以给我一些激励,并指导学习什么,如何以及使用什么文件。



请给我最好的文档标题,我编写一些Python,这是我第一次使用较低级别的语言,而且我已经准备好了。



感谢所有

解决方案

一般建议:



它不只是x86汇编器。每个汇编器有点不同,它们通常不兼容。我推荐NASM汇编器,因为它被广泛使用,易于安装,并支持64位程序集。



阅读一本关于x86汇编器的好书,以获得基础知识(寄存器,条件跳转,算术等)。当我开始时,我看到了兰德尔·海德的大会艺术。



http://asm.sourceforge.net 看起来像有一些很好的教程,你可能想要通过。但是,如果您在64位模式下进行组装,请小心C函数和系统调用的调用约定是不同的。



您将需要CPU参考手册。就我个人而言,我更喜欢AMD。您需要CPU手册的卷1和3。



64位具体建议



64位x86程序集几乎相同作为32位x86汇编,因为64位x86大多是向后兼容32位。您可以访问64位寄存器和其他一些功能,一些模糊的指令不再有效,其余的与32位相同。



然而,系统调用常规在64位Linux上完全不同于/ em>不同。根据您的内核,32位系统调用可能会或可能不可用。更糟糕的是,64位呼叫约定的记录不足。我只是通过检查glibc源代码的深度来计算出来。



为了节省你难以找到的麻烦,系统调用数字在Linux源代码 arch / x86 / include / asm / unistd_64.h 。系统调用号码在 rax 注册表中传递。参数在 rdi rsi rdx r10 r8 r9 。使用 syscall 指令调用该调用。 syscall 覆盖 rcx 注册表。退货在 rax 中。 (可以在这里找到一个简单的例子。)


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.

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.

Thanks all

解决方案

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.

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 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.

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.

64bit specific advice

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.

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.

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天全站免登陆