- 1、本文档共10页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
作者: Badcoffee
Email: blog.oliver@
2004年10月
原文出处: /yayong
这是作者在学习X86汇编过程中的学习笔记,难免有错误和疏漏之处,欢迎指正。
1. 编译环境
?? OS: Axianux 1.0?? Compiler: gcc 3..2.3
?? Linker: Solaris Link Editors 5.x?? Debug Tool: gdb?? Editor: vi!--[if !supportLineBreakNewLine]--!--[endif]--
2. 最简C代码分析!--[if !supportLineBreakNewLine]--!--[endif]--
为简化问题,来分析一下最简的c代码生成的汇编代码:??? # vi test1.c? ??? int main()??? {?? ?? ? return 0;??? }?? ???? 编译该程序,产生二进制文件:??? # gcc -o start start.c
# file start??? ?
start: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped???? start是一个ELF格式32位小端(Little Endian)的可执行文件,动态链接并且符号表没有去除。这正是Unix/Linux平台典型的可执行文件格式。
???? 用gdb反汇编可以观察生成的汇编代码:
[wqf@15h166 attack]$ gdb start
GNU gdb Asianux (6.0post-017.1AX)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions.
Type show copying to see the conditions.
There is absolutely no warranty for GDB.?Type show warranty for details.r
This GDB was configured as i386-asianux-linux-gnu...(no debugging symbols found)...Using host libthread_db library /lib/tls/libthread_db.so.1.
(gdb) disassemble main牋牋牋牋?--- 反汇编main函数
Dump of assembler code for function main:
0main+0:??? push?? %ebp?? ---ebp寄存器内容压栈,即保存main函数的上级调用函数的栈基地址
0main+1:??? mov??? %esp,%ebp ?--- esp值赋给ebp,设置main函数的栈基址
0main+3:??? sub??? $0x8,%esp? ---通过ESP-8来分配8字节堆栈空间
0main+6:??? and??? $0xfffffff0,%esp ---使栈地址16字节对齐
0main+9:??? mov??? $0x0,%eax? ---? 无意义
0x0804831e main+14:?? sub??? %eax,%esp? ---? 无意义
0main+16:?? mov??? $0x0,%eax? ?--- 设置函数返回值0
0main+21:?? leave???? ---将ebp值赋给esp,pop先前栈内的上级函数栈的基地址给ebp,恢复原栈基址.!--[if !supportLineBreakNewLine]--!--[endif]--
0main+22:?? ret?? --- main函数返回,回到上级调用.
0main+23:?? nop
End of assembler dump.
注:这里得到的汇编语言语法格式
您可能关注的文档
- 第23届高层会论文集前言与目录.pdf
- CRM模块命名说明和数据库设计文档.doc
- CS3000 操作手册解析.doc
- CSharp编码命名规则教案.doc
- Csharp应用程序开发第六讲.ppt
- 第24节 Flash设备驱动.ppt
- CSpace 2.0 安装与配置管理手册.pdf
- CSS3及js超酷iPhone样式科学计算器插件.pdf
- 第25讲 使用VBA制作人事管理系统.pdf
- 第30讲 操作系统接口知识.doc
- GB/T 39560.10-2024电子电气产品中某些物质的测定 第10部分:气相色谱-质谱法(GC-MS)测定聚合物和电子件中的多环芳烃(PAHs).pdf
- 中国国家标准 GB/T 39560.10-2024电子电气产品中某些物质的测定 第10部分:气相色谱-质谱法(GC-MS)测定聚合物和电子件中的多环芳烃(PAHs).pdf
- 《GB/T 39560.10-2024电子电气产品中某些物质的测定 第10部分:气相色谱-质谱法(GC-MS)测定聚合物和电子件中的多环芳烃(PAHs)》.pdf
- GB/T 39560.302-2024电子电气产品中某些物质的测定 第3-2部分:燃烧-离子色谱法(C-IC)筛选聚合物和电子件中的氟、氯和溴.pdf
- 中国国家标准 GB/T 39560.2-2024电子电气产品中某些物质的测定 第2部分:拆解、拆分和机械制样.pdf
- 中国国家标准 GB/T 39560.302-2024电子电气产品中某些物质的测定 第3-2部分:燃烧-离子色谱法(C-IC)筛选聚合物和电子件中的氟、氯和溴.pdf
- GB/T 39560.2-2024电子电气产品中某些物质的测定 第2部分:拆解、拆分和机械制样.pdf
- 《GB/T 39560.2-2024电子电气产品中某些物质的测定 第2部分:拆解、拆分和机械制样》.pdf
- 《GB/T 39560.303-2024电子电气产品中某些物质的测定 第3-3部分:配有热裂解/热脱附的气相色谱-质谱法(Py/TD-GC-MS)筛选聚合物中的多溴联苯、多溴二苯醚和邻苯二甲酸酯》.pdf
- 中国国家标准 GB/T 39560.303-2024电子电气产品中某些物质的测定 第3-3部分:配有热裂解/热脱附的气相色谱-质谱法(Py/TD-GC-MS)筛选聚合物中的多溴联苯、多溴二苯醚和邻苯二甲酸酯.pdf
最近下载
- 人教版(2019)选择性必修第三册Unit 2 Healthy Lifestyle Reading for Writing 课件(内镶嵌视频).pptx VIP
- 国企混改合作协议范本.docx
- 体检系统操作培训.ppt VIP
- 东华云解决方案.docx VIP
- 奥铃4J28TC国五SCR系统电控原理图.pdf VIP
- INOVANCE汇川-SV600N系列伺服调试手册-中文.PDF
- 2019年大众宝来Bora原厂维修手册电路图.pdf
- 大猫英语分级阅读 六级1 Arthur's Fantastic Party课件.ppt
- 2024人教版新教材初中英语七年级上册新课程解读课件.pptx
- 四校八大名校卷 上海市复兴高级中学2021-2022学年高二下学期3月考试英语试题 逐题详解.docx VIP
文档评论(0)