找到全局变量 [英] finding global variables

查看:84
本文介绍了找到全局变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个非常大的C程序,包含数百个文件;我想

知道什么都是

程序中定义的全局变量。我该怎么做。


谢谢


I''ve a very large C program consisting of hundred of files; I want to
know what are all
the global variables defined in the program. how do i do this.

thanks

推荐答案

sinbad写道:
sinbad wrote:



我有一个非常庞大的C程序,包含数百个文件;我想

知道什么都是

程序中定义的全局变量。我该怎么做。


谢谢


I''ve a very large C program consisting of hundred of files; I want to
know what are all
the global variables defined in the program. how do i do this.

thanks



假设我有源代码全球跟随:


....

int myglob = 1;

....


如果对二进制文件执行''nm'',则输出结果为

Let''s say I have source code with the following global:

....
int myglob = 1;
....

If you perform ''nm'' on the binary, the output is


nm mybin | grep glob

080489e0 t __do_global_ctors_aux

08048510 t __do_global_dtors_aux

08049c60 D myglob
nm mybin | grep glob
080489e0 t __do_global_ctors_aux
08048510 t __do_global_dtors_aux
08049c60 D myglob





来自nm的手册页......


" D"符号位于初始化数据部分(保留全局数据)


希望有所帮助,

Missaka Wijekoon


From the man page for nm...

"D" The symbol is in the initialized data section (where globals are kept)

Hope that helps,
Missaka Wijekoon


这篇关于找到全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆