【发布时间】:2023-03-29 15:23:02
【问题描述】:
我有以下 C 程序
#include <stdio.h>
static int aa = 10;
void func(){
static int aa = 9;
printf("%d\n",aa);
}
int main()
{
func();
return 0;
}
输出为 9。
当使用 nm 命令查看输出时,我得到了这个
0000000000601038 d aa
000000000060103c d aa.2286
0000000000601040 B __bss_start
0000000000601040 b completed.7585
0000000000601028 D __data_start
0000000000601028 W data_start
0000000000400460 t deregister_tm_clones
00000000004004e0 t __do_global_dtors_aux
0000000000600e18 t __do_global_dtors_aux_fini_array_entry
0000000000601030 D __dso_handle
0000000000600e28 d _DYNAMIC
0000000000601040 D _edata
0000000000601048 B _end
00000000004005d4 T _fini
在前两行中表示两个变量都在数据段中,但第二行中的 2286 是什么。说明什么?
【问题讨论】: