linux下将C语言编译为汇编代码,需用-S参数,如下代码
void
fun(
int
a,
int
b)
{
/* 这个函数什么也不做 */
}
int main( void )
{
fun( 100 , 200 );
return 0 ;
}
{
/* 这个函数什么也不做 */
}
int main( void )
{
fun( 100 , 200 );
return 0 ;
}
编译命令为:
$ gcc -S s1.c
编译后的结果为:
1
.file
"
s1.c
"
2 .text
3 .globl fun
4 .type fun, @function
5 fun:
6 pushl % ebp
7 movl % esp, % ebp
8 popl % ebp
9 ret
10 .size fun, . - fun
11 .globl main
12 .type main, @function
13 main:
14 pushl % ebp
15 movl % esp, % ebp
16 subl $ 8 , % esp
17 movl $ 200 , 4 ( % esp)
18 movl $ 100 , ( % esp)
19 call fun
20 movl $ 0 , % eax
21 leave
22 ret
23 .size main, . - main
24 .ident " GCC: (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 "
25 .section .note.GNU - stack, "" ,@progbits
2 .text
3 .globl fun
4 .type fun, @function
5 fun:
6 pushl % ebp
7 movl % esp, % ebp
8 popl % ebp
9 ret
10 .size fun, . - fun
11 .globl main
12 .type main, @function
13 main:
14 pushl % ebp
15 movl % esp, % ebp
16 subl $ 8 , % esp
17 movl $ 200 , 4 ( % esp)
18 movl $ 100 , ( % esp)
19 call fun
20 movl $ 0 , % eax
21 leave
22 ret
23 .size main, . - main
24 .ident " GCC: (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 "
25 .section .note.GNU - stack, "" ,@progbits
最后
以上就是土豪钢笔最近收集整理的关于linux下C语言编译为汇编代码的全部内容,更多相关linux下C语言编译为汇编代码内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复