工具接口标准(TIS)可执行链接格式(ELF)规范版本 1.2
翻译以中英对照方式,英语水品有限,如有翻译不当的地方,请谅解。
String Table
字符串表
This section describes the default string table. String table sections hold null-terminated character sequences, commonly called strings. The object file uses these strings to represent symbol and section names. One references a string as an index into the string table section. The first byte, which is index zero, is defined to hold a null character. Likewise, a string table's last byte is defined to hold a null character, ensuring null termination for all strings. A string whose index is zero specifies either no name or a null name, depending on the context. An empty string table section is permitted; its section header's sh_size member would contain zero. Non-zero indexes are invalid for an empty string table.
本分节描述默认的字符串表。字符串表分节包含一终结符结束的字符序列,通常被称为字符串。对象文件使用这些字符串来表示符号和分节名。对字符串的引用通过索引来定位到字符串表节中。索引为0的第一个字节被定义为终结符。同样,字符串表的最后一个字节也被定义为终结符,确保所有字符串都能够被终结。索引为0的字符串表示没有名字或名字为空,依赖于内容一个空字符串表分节是被允许的;其分节头中的sh_size成员为0。对于空字符串表,非0索引是无效的
A section header's sh_name member holds an index into the section header string table section, as designated by the e_shstrndx member of the ELF header. The following figures show a string table with 25 bytes and the strings associated with various indexes.
一个分节头的sh_name成员包含一个位于分节头字符串表分节中的索引,分节头字符串表分节是ELF头中e_shstrndx成员指定的分节。接下来的图表示了一个25字节的字符串表以及关联了不同索引的字符串。
Index | +0 | +1 | +2 | +3 | +4 | +5 | +6 | +7 | +8 | +9 |
0 | \0 | n | a | m | e | . | \0 | V | a | r |
10 | i | a | b | l | e | \0 | a | b | l | e |
20 | \0 | \0 | x | x | \0 |
|
|
|
|
|
Figure 1-14. String Table Indexes
图1-14.符号表索引
索引(Index) | 字符串(String) |
0 | none |
1 | name |
7 | Variable |
11 | able |
16 | able |
24 | null string |
As the example shows, a string table index may refer to any byte in the section. A string may appear more than once; references to substrings may exist; and a single string may be referenced multiple times. Unreferenced strings also are allowed.
就像例子中显示的,一个字符串表索引可能涉及分节中的任何字节。一个字符串可能不止一次出现;可能存在引用子字符串的情况;以及一个单独字符串可能被引用多次。未引用的字符串也是被允许的。