当前位置: 首页 > news >正文

汇编获取二进制

文章目录

  • 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

http://www.mrgr.cn/news/98103.html

相关文章:

  • Linux基础14
  • 解决2080Ti使用节点ComfyUI-PuLID-Flux-Enhanced中遇到的问题
  • 2019年计算机真题
  • 小刚说C语言刷题——第22讲 二维数组
  • 【学习笔记】两个类之间的数据交互方式
  • 可配置多功能门芯片的12种用法推导——基于74LVC1G97芯片(附1G98、1G57、1G58、1G99用法)
  • 470用 Rand7() 实现 Rand10()
  • leetcode572 另一棵树的子树
  • 每天学一个 Linux 命令(14):cat
  • Linux进程概念
  • 【MQTT-协议原理】
  • 2025蓝桥杯算法竞赛深度突破:创新题型与高阶策略全解析
  • IIC通信协议
  • 基于 Maven 构建的 Thingsboard 3.8.1 项目结构
  • 部署NFS版StorageClass(存储类)
  • 文献总结:AAAI2025-UniV2X-End-to-end autonomous driving through V2X cooperation
  • SAP系统客户可回收包材库存管理
  • 强化学习系统在复杂推理模型中的应用——以AReaL系统为例
  • RPA VS AI Agent
  • 解决VS2022中scanf报错C4996