C symbol table

C source code:

 

#include <stdio.h>

void sub(int x) 
{
}

void xiao() 
{
	static int x = 10;
	sub(x);
}

void yu()
{
	static int x = 20;
	sub(x);
}

int main(int argc, const char *argv[]) {
	return 0;
}

 

Run 'gcc' to compile it. Run 'nm -n' to give the following result:

 

 

...
0804a010 d x.1708
0804a014 d x.1704
...
 

Run 'objdump -S':

 

...
080483b9 <xiao>:
 80483b9:	55                   	push   %ebp
 80483ba:	89 e5                	mov    %esp,%ebp
 80483bc:	83 ec 04             	sub    $0x4,%esp
 80483bf:	a1 14 a0 04 08       	mov    0x804a014,%eax
 80483c4:	89 04 24             	mov    %eax,(%esp)
 80483c7:	e8 e8 ff ff ff       	call   80483b4 <sub>
 80483cc:	c9                   	leave  
 80483cd:	c3                   	ret    

080483ce <yu>:
 80483ce:	55                   	push   %ebp
 80483cf:	89 e5                	mov    %esp,%ebp
 80483d1:	83 ec 04             	sub    $0x4,%esp
 80483d4:	a1 10 a0 04 08       	mov    0x804a010,%eax
 80483d9:	89 04 24             	mov    %eax,(%esp)
 80483dc:	e8 d3 ff ff ff       	call   80483b4 <sub>
 80483e1:	c9                   	leave  
 80483e2:	c3                   	ret    
...

 We can see that xiao uses 0x804a014 and yu uses 0x804a010. Now let us run 'objdump -s':

 

...
Contents of section .data:
 804a008 00000000 00000000 14000000 0a000000  ................
...
 We can that xiao's x has value 10 and yu's x has value 20.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值