- Mastering Assembly Programming
- Alexey Lyashko
- 215字
- 2021-08-20 10:23:33
The Linux Assembly template (32-bit)
On Linux, although files on disc are divided into sections, executables in memory are divided into code and data segments. The following is our template for the ELF 32-bit executable for Linux:
; File: src/template_lin.asm
; Just as in the Windows template - we tell the assembler which type
; of output we expect.
; In this case it is 32-bit executable ELF
format ELF executable
; Tell the assembler where the entry point is
entry _start
; On *nix based systems, when in memory, the space is arranged into
; segments, rather than in sections, therefore, we define
; two segments:
; Code segment (executable segment)
segment readable executable
; Here is our entry point
_start:
; Set return value to 0
xor ebx, ebx
mov eax, ebx
; Set eax to 1 - 32-bit Linux SYS_exit system call number
inc eax
; Call kernel
int 0x80
; Data segment
segment readable writeable
db 0
; As you see, there is no import/export segment here. The structure
; of an ELF executable/object file will be covered in more detail
; in chapters 8 and 9
As was mentioned in the preceding code, these two templates will be used as a starting point for any code we will write in this book.
推薦閱讀
- JBoss Weld CDI for Java Platform
- Photoshop智能手機APP UI設計之道
- Vue.js 3.x從入門到精通(視頻教學版)
- VMware vSphere 6.7虛擬化架構實戰指南
- Android 7編程入門經典:使用Android Studio 2(第4版)
- 實戰Java高并發程序設計(第3版)
- Python機器學習編程與實戰
- jQuery開發基礎教程
- Visual Studio Code 權威指南
- Kotlin極簡教程
- Web App Testing Using Knockout.JS
- 貫通Tomcat開發
- 零基礎C#學習筆記
- Java Web開發教程:基于Struts2+Hibernate+Spring
- 和孩子一起學編程:用Scratch玩Minecraft我的世界