欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > 汇编获取二进制

汇编获取二进制

2025/4/22 18:48:01 来源:https://blog.csdn.net/wwq921220/article/details/147162863  浏览:    关键词:汇编获取二进制

文章目录

  • AT&T
    • asm
  • Intel


AT&T

  • mov_test.s
mov $0,%r8d
  • gcc -c mov_test.s 输出 mov_test.o,
  • objdump -D mov_test.o 查看 mov_test.o:

mov_test.o:     file format elf64-x86-64Disassembly of section .text:0000000000000000 <.text>:0:   41 b8 00 00 00 00       mov    $0x0,%r8d
  • mov_.S
mov %r8d,0
nop
  • 执行命令: gcc -c mov_.S 会输出 mov_.o 文件:
  • objdump -D mov_.o :
mov_.o:     文件格式 elf64-x86-64Disassembly of section .text:0000000000000000 <.text>:0:   44 89 04 25 00 00 00    mov    %r8d,0x07:   00 8:   90                      nop
  • main.c:
void main() {
}
  • 执行命令: gcc -S main.c 输出文件 main.s
  • main.s:
       .file   "main.c".text.globl  main.type   main, @function
main:
.LFB0:.cfi_startprocpushq   %rbp.cfi_def_cfa_offset 16.cfi_offset 6, -16movq    %rsp, %rbp.cfi_def_cfa_register 6noppopq    %rbp.cfi_def_cfa 7, 8ret.cfi_endproc
.LFE0:.size   main, .-main.ident  "GCC: (Uos 8.3.0.3-3+rebuild) 8.3.0".section        .note.GNU-stack,"",@progbits
  • doubao.s:
section .textglobal _start_start:;0 存入 r8d 寄存器mov r8d, 0; 退出程序mov eax, 1xor ebx, ebxint 0x80    

asm

  • asm_test.c:
#include <stdio.h>int main() {int num = 10;__asm__ ("movl %1, %%eax\n\t""movl %%eax, %0\n\t": "=m" (num): "r" (num): "%eax");printf("The value of num is: %d\n", num);return 0;
}

Intel

  • Intel 语法 mov_test.s 应改为
mov  r8d,0
  • asm_test.c , 指定使用 Intel 语法,需要执行 gcc -masm=intel -S asm_test.c

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词