二进制helloworld
hello.c文件
include <stdio.h>
int main(){
printf("Hello World\n");
}
预处理————编译————汇编————链接
gcc -S hello.i -o hello.s -masm=intel -fno-asynchronous-unwind-tables
得到hello.i hello.s hello.o hello 四个文件
└─$ cat hello.s
.file "hello.c"
.intel_syntax noprefix
.text
.section .rodata
.LC0:
.string "Hello World"
.text
.globl main
.type main, @function
main:
push rbp
mov rbp, rsp
lea rax, .LC0[rip]
mov rdi, rax
call puts@PLT
mov eax, 0
pop rbp
ret
.size main, .-main
.ident "GCC: (Debian 14.2.0-19) 14.2.0"
.section .note.GNU-stack,"",@progbits
└─$ objdump -sd hello.o -M intel
hello.o: file format elf64-x86-64
Contents of section .text:
0000 554889e5 488d0500 00000048 89c7e800 UH..H......H....
0010 000000b8 00000000 5dc3 ........].
Contents of section .rodata:
0000 48656c6c 6f20576f 726c6400 Hello World.
Contents of section .comment:
0000 00474343 3a202844 65626961 6e203134 .GCC: (Debian 14
0010 2e322e30 2d313929 2031342e 322e3000 .2.0-19) 14.2.0.
Contents of section .eh_frame:
0000 14000000 00000000 017a5200 01781001 .........zR..x..
0010 1b0c0708 90010000 1c000000 1c000000 ................
0020 00000000 1a000000 00410e10 8602430d .........A....C.
0030 06550c07 08000000 .U......
Disassembly of section .text:
0000000000000000
0: 55 push rbp
1: 48 89 e5 mov rbp,rsp
4: 48 8d 05 00 00 00 00 lea rax,[rip+0x0] # b <main+0xb>
b: 48 89 c7 mov rdi,rax
e: e8 00 00 00 00 call 13 <main+0x13>
13: b8 00 00 00 00 mov eax,0x0
18: 5d pop rbp
19: c3 ret
浙公网安备 33010602011771号