readelf显示的符号表各列的含义是什么?

发布于 2024-09-06 02:12:44 字数 47 浏览 2 评论 0原文

有人可以使用 readelf 解释符号表中显示的列吗?

Could someone explain the columns shown of the symbol table using readelf?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

但可醉心 2024-09-13 02:12:44

请考虑以下情况:

符号表 .symtab 包含 1203 个条目:

 Num:    Value  Size Type    Bind   Vis      Ndx Name
 310: a0008120     0 NOTYPE  GLOBAL DEFAULT  ABS _gp  
 734: a0000010    32 OBJECT  GLOBAL DEFAULT   77 v 
 818: 9d000018   496 FUNC    GLOBAL DEFAULT   71 main 
 849: a0000124     4 OBJECT  GLOBAL DEFAULT   78 phrase 
 955: a0000000     9 OBJECT  GLOBAL DEFAULT   77 peppers  
1020: a000023c   192 OBJECT  GLOBAL DEFAULT   80 bins
  • Num: = 符号编号
  • Value = 符号的地址
  • Size = 符号的大小
  • Type = 符号类型:Func = 函数、对象文件 (源文件名),Section = 内存部分,Notype = 无类型绝对符号或未定义
  • Bind = GLOBAL 绑定表示该符号在文件外部可见。 LOCAL 绑定仅在文件中可见。 WEAK 就像全局一样,该符号可以被覆盖。
  • Vis = 符号可以是默认的、受保护的、隐藏的或内部的。
  • Ndx = 符号所在的节号。ABS 表示绝对:不调整任何节地址的重定位
  • Name = 符号名称

Consider the following:

Symbol table .symtab contains 1203 entries:

 Num:    Value  Size Type    Bind   Vis      Ndx Name
 310: a0008120     0 NOTYPE  GLOBAL DEFAULT  ABS _gp  
 734: a0000010    32 OBJECT  GLOBAL DEFAULT   77 v 
 818: 9d000018   496 FUNC    GLOBAL DEFAULT   71 main 
 849: a0000124     4 OBJECT  GLOBAL DEFAULT   78 phrase 
 955: a0000000     9 OBJECT  GLOBAL DEFAULT   77 peppers  
1020: a000023c   192 OBJECT  GLOBAL DEFAULT   80 bins
  • Num: = The symbol number
  • Value = The address of the Symbol
  • Size = The size of the symbol
  • Type = symbol type: Func = Function, Object, File (source file name), Section = memory section, Notype = untyped absolute symbol or undefined
  • Bind = GLOBAL binding means the symbol is visible outside the file. LOCAL binding is visible only in the file. WEAK is like global, the symbol can be overridden.
  • Vis = Symbols can be default, protected, hidden or internal.
  • Ndx = The section number the symbol is in. ABS means absolute: not adjusted to any section address's relocation
  • Name = symbol name
耳钉梦 2024-09-13 02:12:44

我认为 Ndx 字段显示定义该符号的节号。

执行 readelf -a,并找出给定符号的地址对应于哪个部分。

我敢打赌该部分的部分编号将出现在 Ndx 字段中。

I think Ndx field shows the section number where that symbol is defined.

Do a readelf -a <file>, and find out which section the address corresponds to for a given symbol.

I bet the section number of that section will appear in Ndx field.

红玫瑰 2024-09-13 02:12:44

好吧,这个问题很老了,但是如果你正在寻找 readelf symboltable 和 NDX,那么老好的 Google 会给出它;

以下是我发现的内容:

使用avr-gcc 编译的 C 代码:

int XYZ = 123;
int ABC;

分析生成的 elf 文件时

readelf --symbols KoreOS.elf

当使用您获取的输出

Num:    Value  Size Type    Bind   Vis      Ndx Name
...
148: 0080200b     2 OBJECT  GLOBAL DEFAULT    2 XYZ
...
258: 00803878     2 OBJECT  GLOBAL DEFAULT    3 ABC
...

:我使用 NDX 列作为变量是否已初始化的提示。但我在任何地方都没有找到任何文档,所以我只是猜测。

问候,
多米尼克

Ok this question is old, but good old Google yields it if you are looking for readelf symboltable and NDX;

Here is what I found out:

The C code compiled with avr-gcc:

int XYZ = 123;
int ABC;

when the generated elf file is analyzed using

readelf --symbols KoreOS.elf

you get as output:

Num:    Value  Size Type    Bind   Vis      Ndx Name
...
148: 0080200b     2 OBJECT  GLOBAL DEFAULT    2 XYZ
...
258: 00803878     2 OBJECT  GLOBAL DEFAULT    3 ABC
...

I use the NDX column as hint if the variable is initialized or not. But I found no documentation anywhere so I'm just guessing.

greetings,
Dominik

打小就很酷 2024-09-13 02:12:44

您可以:

man readelf

或者查看这些教程:

You can either:

man readelf

or look at these tutorials:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文