ELF可执行文件中.dynamic .dynsym和.dynstr之间的区别 [英] Difference between .dynamic .dynsym and .dynstr in an ELF executable

查看:399
本文介绍了ELF可执行文件中.dynamic .dynsym和.dynstr之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的初步知识是:


  • .dynamic 包含以下库:可执行文件需要加载

  • .dynsym 包含外部符号,如 setsockopt@GLIBC_2.0

  • .dynstr 包含函数要求的字符串

  • .dynamic contains libraries that the executable needs to load
  • .dynsym contains external symbols such as setsockopt@GLIBC_2.0
  • .dynstr contains strings of function requirements

总体而言,对于这些部分如何共同创建二进制文件-尤其是 .dynsym ,我有些困惑。 dynstr 。所以我的问题有两个。我上面的陈述正确吗?如果是这样,这三个部分如何协同工作以创建二进制文件?

Overall, I am a bit confused as to how these sections work together to create a binary - specifically .dynsym and .dynstr. So my question is two-fold. Are my statements above correct? If so, how do these three sections work together to create a binary?

推荐答案


我的语句是吗?

Are my statements above correct?

.dynsym 部分包含一组固定长度 Elf32_Sym Elf64_Sym 的记录。

The .dynsym section contains a set of fixed-length records of type Elf32_Sym or Elf64_Sym.

固定的长度条目,它们本身无法描述二进制文件输出或导入的任意长度符号(字符串)。

Since these are fixed length entries, they can not by themselves describe arbitrary length symbols (strings) that the binary exports or imports.

因此,这些条目不包含字符串。相反,它们在 .dynstr (在 .st_name 字段中)中包含一个偏移量,并且在此偏移量处找到符号名称。

Therefore these entries don't contain the strings. Instead, they contain an offset into .dynstr (in the .st_name field), and the symbol name is found at this offset.

因此, .dynsym 包含setsockopt @ GLIBC_2是不正确的.0和 .dynstr 包含函数要求的字符串(无论最后一条语句表示什么)。

So it's not true that ".dynsym contains setsockopt@GLIBC_2.0" and that ".dynstr contains strings of function requirements" (whatever that last statement means).

.dynsym 包含 Elf32_Sym Elf64_sym 导入的符号 setsockopt ,并在 .dynstr <中引用 setsockopt 字符串的偏移量/ code>部分。

The .dynsym contains an Elf32_Sym or an Elf64_sym describing an imported symbol setsockopt, and referencing the offset of "setsockopt" string in the .dynstr section.

同样, .dynamic 包含可执行文件需要加载的库是错误的-该节不包含任何库。

Likewise, ".dynamic contains libraries that the executable needs to load" is false -- the section doesn't contain any libraries.

它包含固定长度的 Elf64_Dyn Elf32_Dyn ,其中一些(例如带有 .d_tag == DT_NEEDED DT_RPATH )可以引用stri ngs .dynstr 的偏移量。动态加载程序以某种方式解释这些条目-对于 DT_NEEDED 为必须加载另一个库,对于 DT_RPATH 例如必须搜索这些用冒号分隔的路径等等。

It contains fixed length entries of Elf64_Dyn or Elf32_Dyn, some of which (such as ones with .d_tag == DT_NEEDED or DT_RPATH) may reference strings from .dynstr via their offsets. The dynamic loader interprets these entries in certain way -- for DT_NEEDED as "must load this other library", for DT_RPATH as "must search these colon-separated paths", etc.

这篇关于ELF可执行文件中.dynamic .dynsym和.dynstr之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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