工具接口标准(TIS)可执行链接格式(ELF)规范-卷III-操作系统特性-程序加载和动态链接(三)

来源:互联网 发布:开场动画制作软件 编辑:程序博客网 时间:2024/04/30 04:32
本文是对Tool Interface Standard (TIS) Executable and Linking Format (ELF) Specification Version 1.2的翻译
工具接口标准(TIS)可执行链接格式(ELF)规范版本 1.2

翻译以中英对照方式,英语水平有限,如有翻译不当的地方,请谅解。


DynamicSection

动态分节

If an object file participates in dynamic linking, its program header table will have an element of type PT_DYNAMIC. This "segment" contains the .dynamic section. A special symbol, _DYNAMIC, labels the section, which contains an array of the following structures.
假如一个对象文件错与动态链接,它的程序投标会有一个类型为PT_DYNAMIC的元素。这个“分段”包含.dynamic分节。一个特殊符号_DYNAMIC,标记这个分节,该分节包含以下结构
Figure2-6. Dynamic Structure

图2-6.动态结构

typedef struct {

Elf32_Sword d_tag;

union {

Elf32_Word d_val;

Elf32_Addr d_ptr;

} d_un;

} Elf32_Dyn;

extern Elf32_Dyn _DYNAMIC[];

 

For each object with this type,d_tag controls the interpretation of d_un.

对每个有此类型的对象,d_tag控制d_un的解释。

d_val

These Elf32_Word objects represent integer values with various interpretations.

这些Elf32_Word对象表达了不同的解释的整型值

d_ptr

These Elf32_Addr objects represent program virtual addresses. 

As mentioned previously, a file's virtual addresses might not match the memory virtual addresses during execution. 

When interpreting addresses contained in the dynamic structure, the dynamic linker computes actual addresses, 

based on the original file value and the memory base address. For consistency, 

files do not contain relocation entries to "correct" addresses in the dynamic structure.

这些Elf32_Addr对象表达程序虚拟地址。就像前面提到的,在执行过程中,一个文件的虚拟地址可能不会匹配内存虚拟地址。

当解释地址包含在动态结构中时,动态链接器计算实际地址,基于原始文件值和内存基地址。为了一致性,文件不包含重定位入口来“修正”在动态结构中的地址。

The following table summarizes the tag requirements for executable and shared object files. If a tag is marked "mandatory," then the dynamic linking array for a TIS ELF conforming file must have an entry of that type. Likewise, "optional" means an entry for the tag may appear but is not required.
以下表概述了可执行和共享对象文件的标记需求。假如一个标志标记为“强制”,那么一个符合TIS ELF的文件的动态链接器数组必须有一个这样的入口。同样,“可选”意味着一个标记入口可能出现但不是必须的。

Figure2-7. Dynamic Array Tags, d_tag

图2-7。动态数组标记,d_tag

图2-7。动态数组标记,d_tag

 

ame)

值(Value)

d_un

可执行(Executable)

共享对象(Shared Object)

DT_NULL
DT_NEEDED
DT_PLTRELS
DT_PLTGOT
DT_HASH
DT_STRTAB
DT_SYMTAB
DT_RELA
DT_RELASZ
DT_RELAENT
DT_STRSZ
DT_SYMENT
DT_INIT
DT_FINI
DT_SONAME
DT_RPATH
DT_SYMBOLI
DT_REL
DT_RELSZ
DT_RELENT
DT_PLTREL
DT_DEBUG
DT_TEXTREL
DT_JMPREL
DT_BIND_NO
DT_LOPROC
DT_HIPROC0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
0x70000000
0x7fffffffIgnored
d_val
d_val
d_ptr
d_ptr
d_ptr
d_ptr
d_ptr
d_val
d_val
d_val
d_val
d_ptr
d_ptr
d_val
d_val
ignored
d_ptr
d_val
d_val
d_val
d_ptr
ignored
d_ptr
ignored
unspecified
unspecified强制
可选
可选
可选
强制
强制
强制
强制
强制
强制
强制
强制
可选
可选
忽略
可选
忽略
强制
强制
强制
可选
可选
可选
可选
可选
未指定
未指定强制
可选
可选
可选
强制
强制
强制
可选
可选
可选
强制
强制
可选
可选
可选
忽略
可选
可选
可选
可选
可选
忽略
可选
可选
可选
未指定
未指定


DT_NULL

An entry with a DT_NULL tag marks the end of the _DYNAMIC array.
一个DT_NULL标签的入口标记了_DYNAMIC数组的结束入口。

DT_NEEDED

This element holds the string table offset of a null-terminated string, giving the name of a needed library. 

The offset is an index into the table recorded in the DT_STRTAB entry. 

 See "Shared Object Dependencies'' for more information about these names. 

The dynamic array may contain multiple entries with this type. 

These entries' relative order is significant, though their relation to entries of other types is not.

这个元素包含一个终结符字符串在字符串表中的偏移,给出了一个需要的动态库的名字。

这个偏移是一个到DT_STRTAB入口表记录的索引。看“共享对象依赖”获取更多关于这些名字的信息。

动态数组可能包含多个此类型入口。这些入口相对顺序是重要的,虽然他们相对于其他类型入口并不是。

DT_PLTRELSZ

This element holds the total size, in bytes, of the relocation entries

associated with the procedure linkage table. If an entry of type DT_JMPREL is present, a DT_PLTRELSZ must accompany it.

这个元素包含与过程链接表相关的重定位入口的总大小(字节)。假如一个类型为DT_JMPREL的入口出现,DT_PLTRELSZ必须伴随着同时出现。

DT_PLTGOT

This element holds an address associated with the procedure linkage table and/or the global offset table.

这个元素包含关联过程链接表和/或全局偏移表的地址。

DT_HASH

This element holds the address of the symbol hash table, described in "Hash Table". 

This hash table refers to the symbol table referenced by the DT_SYMTAB element.

这个元素包含符号哈希表的地址,在“哈希表”部分描述。这个哈希表涉及DT_SYMTAB元素引用的符号表。

DT_STRTAB

This element holds the address of the string table, described in Chapter 1. Symbol names, library names, and other strings reside in this table.

这个元素包含字符串表的地址,在章节一描述。符号名,动态库名和其它字符串位于这个表中。

DT_SYMTAB

This element holds the address of the symbol table, described in Chapter 1, with Elf32_Symentries for the 32-bit class of files.

这个元素包含符号表地址,在章节一描述,32位文件类别的符号使用Elf32_Symentries描述。

DT_RELA

This element holds the address of a relocation table, described in
Chapter 1. Entries in the table have explicit addends, such as Elf32_Rela for the 32-bit file class. 

An object file may have multiple relocation sections. When building the relocation table for an executable or shared object file, 

the link editor catenates those sections to form a single table. Although the sections remain independent in the object file,

 the dynamic linker sees a single table. When the dynamic linker creates the process image for an executable file or 

adds a shared object to the process image, it reads the relocation table and performs the associated actions.

 If this element is present, the dynamic structure must also have DT_RELASZ and DT_RELAENT elements. 

When relocation is "mandatory" for a file, either DT_RELA or DT_REL may occur (both are permitted but not required).
这个元素包含重定位表的地址,在章节一描述。在这个表中的入口有一个明确的加数,比如Elf32_Rela用于32位文件类别。

一个对象文件可能有多个重定位分节。当为一个可执行或共享对象文件创建重定位表时,链接编辑器连接这些分节形成一个单一的表。

虽然这些分节仍然在对象文件中独立,但动态链接器只看到一个单一的表。

当动态链接器为一个可执行文件创建进程映像或者天剑一个共享对象到进程映像时,它读取重定位表并执行关联动作。

假如这个元素存在,动态结构必须包含DT_RELASZ和DT_RELAENT元素。当重定位对文件时“强制”,DT_RELA或DT_REL

DT_RELASZ

This element holds the total size, in bytes, of the DT_RELA relocation table.

这个元素包含DT_RELA重定位表的总大小(字节)。

DT_RELAENT

This element holds the size, in bytes, of the DT_RELA relocation entry.

这个元素包含DT_RELA每个重定位入口的大小(字节)。

DT_STRSZ

This element holds the size, in bytes, of the string table.

这个元素包含字符串表的大小(字节)。

DT_SYMENT

This element holds the size, in bytes, of a symbol table entry.

这个元素包含一个符号表入口的大小(字节)。

DT_INIT

This element holds the address of the initialization function, discussed in "Initialization and Termination Functions" below.

这个元素包含初始化函数的地址,下面将在“初始化和结束函数”讨论。

DT_FINI

This element holds the address of the termination function, discussed in "Initialization and Termination Functions" below.

这个元素包含结束函数的地址,下面将在“初始化和结束函数”讨论。

DT_SONAME

This element holds the string table offset of a null-terminated string, giving the name of the shared object.

 The offset is an index into the table recorded in the DT_STRTAB entry. See "Shared Object Dependencies" below for more information about these names.

这个元素包含一个含终结符的字符串在字符串表中的偏移,该字符串给出了这个共享对象的名字。

这个偏移是一个到DT_STRTAB入口表记录的索引。看“共享对象依赖”获取更多关于这些名字的信息。

DT_RPATH

This element holds the string table offset of a null-terminated search library search path string, 

discussed in "Shared Object Dependencies". The offset is an index into the table recorded in the DT_STRTAB entry.

这个元素包含一个含终结符的动态库搜索路径字符串在字符串表中的偏移,在“共享对象依赖”部分讨论。这个偏移是一个到DT_STRTAB入口表记录的索引。

DT_SYMBOLIC

This element's presence in a shared object library alters the dynamic linker's symbol resolution algorithm 

for references within the library. Instead of starting a symbol search with the executable file, 

the dynamic linker starts from the shared object itself. If the shared object fails to supply the referenced symbol,

 the dynamic linker then searches the executable file and other shared objects as usual.

这个元素在共享对象库中的存在为库中的引用改变了动态链接器的符号解析算法。

替代从可执行文件开始符号搜索,动态链接器开始从共享对象自身开始搜索。假如共享对象提供引用符号失败,

动态链接器才会像通常一样从可执行文件盒其它共享对象中搜索。

DT_REL

This element is similar to DT_RELA, except its table has implicit addends, such as Elf32_Rel for the 32-bit file class. If this element is present, the dynamic structure must also have DT_RELSZ and DT_RELENT elements.

这个元素和DT_RELA相似,除了它的表有内部的加数外,比如Elf32_Rel用于32位文件分类。

DT_RELSZ

This element holds the total size, in bytes, of the DT_REL relocation table.

这个元素包含用字节表示的DT_REL重定位表大小。

DT_RELENT

This element holds the size, in bytes, of the DT_REL relocation entry.

这个元素包含一字节表示DT_REL重定位入口的大小。

DT_PLTREL

This member specifies the type of relocation entry to which the procedure linkage table refers.

 The d_val member holds DT_REL or DT_RELA, as appropriate. All relocations in a procedure linkage table must use the same relocation.
这个成员给过程链接表的引用指定了重定位入口的类型。d_val成员视情况而定包含DT_REL或DT_RELA。

所有的重定位在过程链接表中必须使用相同的转换。

DT_DEBUG

This member is used for debugging. Its contents are not specified in this document.

这个成员是用于调试的。它的内容在此文档中未被指定。

DT_TEXTREL

This member's absence signifies that no relocation entry should cause a modification to a non-writable segment, 

as specified by the segment permissions in the program header table.

 If this member is present, one or more relocation entries might request modifications to a non-writable segment, 

and the dynamic linker can prepare accordingly.

这个成员的缺失表示没有重定位条目会导致一个对一个不可写分段的修改,像在程序头表中分段权限指定的一样。

假如这个成员存在,一个或多个重定位条目可能请求对一个不可写分段的修改,并且动态链接器能做相应的准备。

DT_JMPREL

If present, this entries d_ptr member holds the address of relocation entries associated solely with the procedure linkage table. 

Separating these relocation entries lets the dynamic linker ignore them during process initialization, if lazy binding is enabled.

 If this entry is present, the related entries of types DT_PLTRELSZ and DT_PLTREL must also be present.

当出现,这个条目d_ptr成员包含单独关联过程链接表的重定位条目地址。假如延迟绑定被允许,

分开这些重定位条目使动态链接器在处理初始化时候忽略它们。假如这个条目存在,相关的DT_PLTRELSZ类型的条目必须也存在。

DT_BIND_NOW

If present in a shared object or executable, this entry instructs the dynamic linker to process all relocations

 for the object containing this entry before transferring control to the program. 

The presence of this entry takes precedence over a directive to use lazy binding for this object when specified 

through the environment or via dlopen(BA_LIB).

假如此成员存在于共享对象或可执行程序中,它命令动态链接器处理在转换控制到程序之前,

为包含此条目的对象处理所有的重定位。这个条目的存在优先于通过环境变量或者dlopen对这个对象直接使用延迟绑定。

DT_LOPROC through DT_HIPROC

Values in this inclusive range are reserved for processor-specific semantics. If meanings are specified, the processor supplement explains them.

在这个范围内的值为处理器特定语法保留。假如意思被指定,处理补充部分将进行解释。

Except for the DT_NULL element at the end of the array, and the relative order of DT_NEEDED elements, entries may appear in any order. Tag values not appearing in the table are reserved.
除了DT_NULL元素在数组末尾,以及DT_NEEDED元素的顺序是相关的,其它条目的顺序可以任意出现。没有出现在表中的标记值是保留的。

0 0