在 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
字节范围内的反汇编代码。