编辑并运行代码,使结果是后四位学号
t1.c:
#include <stdio.h>
int g = 1321;
static int s;
int main()
{
int a = 1;
static int c = 3;
int b = 2;
c = mysum(a,b);
printf("sum = %d
",c);
return 1;
}
t2.c:
extern int g;
int mysum(int x ,int y)
{
return x+y+g;
}
运行截图:
什么是objdump
objdump命令是Linux下的反汇编目标文件或者可执行文件的命令,它以一种可阅读的格式让你更多地了解二进制文件可能带有的附加信息。
5篇博客链接和微信读书上的图书链接,并给出你认为最好的讲解资源的链接或图书名及章节
https://blog.csdn.net/q2519008/article/details/82349869(个人认为最好,详细说明了objdump的各个参数命令,还举例说明,介绍常用符号表字段)
https://blog.csdn.net/freeplayer/article/details/45133721
http://lnmp.ailinux.net/objdump
https://blog.csdn.net/qq_41683305/article/details/105375214
http://blog.chinaunix.net/uid-9525959-id-2001838.html
用objdump分析第1步中的可执行文件和目标文件
可执行文件:objdump -d t
在分析中可以看到程序的文件头(包含代码段、数据段和BSS段的大小)、代码段、数据段以及BSS段:
main:
mysum:
对t.o进行反汇编:
在完成编译进行链接的时候,链接器就会将所有内容的地址链接起来,从而让程序被打散在内存各个部分的段能够又拼接在一起。