工具介面標準(TIS)可執行連結格式(ELF)規範-卷I-字串表(String Table)
工具介面標準(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.
就像例子中顯示的,一個字串表索引可能涉及分節中的任何位元組。一個字串可能不止一次出現;可能存在引用子字串的情況;以及一個單獨字串可能被引用多次。未引用的字串也是被允許的。