在 CentOS 系統下,你可以使用 GNU Assembler (GAS) 來進行反匯編操作
binutils
軟件包,它包含了 GAS 和其他一些有用的工具。如果沒有安裝,可以使用以下命令安裝:sudo yum install binutils
example.asm
,并添加一些匯編代碼。例如:.section .data
msg:
.string "Hello, World!\n"
.section .text
.globl _start
_start:
mov $1, %rax # syscall number for sys_write
mov $1, %rdi # file descriptor 1 is stdout
lea msg(%rip), %rsi # load the address of msg into rsi
mov $13, %rdx # message length
syscall # make the syscall
mov $60, %rax # syscall number for sys_exit
xor %rdi, %rdi # return 0 status
syscall # make the syscall
as -o example.o example.asm
ld -o example example.o
objdump
工具進行反匯編:objdump -d example
這將顯示 example
可執行文件的反匯編代碼。
如果你想查看特定函數的匯編代碼,可以使用以下命令:
objdump -d example -j .text --start-address=_start --stop-address=_start+100
這將顯示從 _start
標志開始,到 _start+100
字節范圍內的反匯編代碼。