工具接口标准(TIS)可执行链接格式(ELF)规范-卷III-附录A-Intel架构和System V Release 4依赖(一)

本文是对Tool Interface Standard (TIS) Executable and Linking Format (ELF) Specification Version 1.2的翻译
工具接口标准(TIS)可执行链接格式(ELF)规范版本 1.2

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


Introduction

介绍

This appendix describes the ELFfeatures and functions that are both Intel Architecture and

System V Release 4 dependent.

   本附录描述了Intel架构和System V Release 4同时依赖的ELF特性和函数。

 

Sections

分节

SpecialSections

特殊分节

Various sections hold program andcontrol information. Sections in the list below are used by

the system and have the indicatedtypes and attributes.

   各种不同的分节包含程序和控制信息。以下列表中的分节被系统使用,并拥有指明的类型和属性。

FigureA-1.  Special Sections

图A-1.特殊分节

名字(Name)

类型(Type)

属性(Attribute)

.got

SHT_PROGBITS

SHF_ALLOC + SHF_WRITE

.plt

SHT_PROGBITS

SHF_ALLOC + SHF_EXECINSTR

 

.got

This section holds the global offset table. See "Global Offset Table'' below for more information.

这个分节包含全局偏移表。看下面的“全局偏移表”获取更多信息。

.plt

This section holds the procedure linkage table. See "Procedure Linkage Table'' Chapter 2 for more information.

这个分节包含过程链接表。看章节2“过程链接表”获取更多信息。

 

Symbol Table

符号表

SymbolValues

符号值

If an executable file contains areference to a function defined in one of its associated shared objects, thesymbol table section for that file will contain an entry for that symbol. Thest_shndx member of that symbol table entry contains SHN_UNDEF. This signals tothe dynamic linker that the symbol definition for that function is notcontained in the executable file itself. If that symbol has been allocated aprocedure linkage table entry in the executable file, and the st_value memberfor that symbol table entry is non-zero, the value will contain the virtualaddress of the first instruction of that procedure linkage table entry.Otherwise, the st_value member contains zero. This procedure linkage tableentry address is used by the dynamic linker in resolving references to theaddress of the function. See "Function Addresses'' below for details.

   假如一个可执行文件包含一个定义在它的一个相关联共享对象中的函数引用,该共享对象文件符号表分节包含该符号的入口。该符号表入口的成员st_shndx值为SHN_UNDEF。这告知动态链接器,该函数的符号定义没有包含在可执行文件自身。假如该符号已经在可执行文件中申请了一个过程链接表入口,并且该符号表入口st_value成员不为0,那么这个值即是包含的过程链接表入口的第一条指令的虚拟地址。否则,st_value成员为0。过程链接表入口地址被动态链接器用于解析函数地址的引用。看以下“函数地址”获取细节。

 

Relocation

重定位

RelocationTypes

重定位类型

Relocation entries describe how toalter the following instruction and data fields (bit numbers appear in thelower box corners).

重定位入口描述如何转换接下来的指令和数据字段(位编号在图示方框的下角处)

FigureA-2. Relocatable Fields

图A-2.重定位字段

 

word32

This specifies a 32-bit field occupying 4 bytes with arbitrary byte alignment. These values use the same byte order as other word values in the Intel architecture.

此处指定了一个占据任意4字节对齐的32位字段。Intel架构下的所有字的值都使用相同的字节序。

 

Calculations below assume theactions are transforming a relocatable file into either an executable or ashared object file. Conceptually, the link editor merges one or morerelocatable files to form the output. It first decides how to combine andlocate the input files, then updates the symbol values, and finally performsthe relocation. Relocations applied to executable or shared object files aresimilar and accomplish the same result. Descriptions below use the followingnotation.

   以下的计算假设转换一个重定位文件到一个可执行或者共享对象文件。概念上讲,链接编辑器合并一个或多个重定位文件来组成输出。它首先描述如何合并和定位输入文件,然后更新符号值,最后执行重定位。重定位应用到可执行或共享文件时是相似的并且达成相同的结果。后面的描述将使用以下的符号。

A

This means the addend used to compute the value of the relocatable field.

A表示这个加数被用来计算重定位字段的值。

B

This means the base address at which a shared object has been loaded into memory during execution. Generally, a shared object file is built with a 0 base virtual address, but the execution address will be different.

B表示一个共享对象在执行中被加载到内存中的基地址。通常,一个共享对象文件使用0的基虚拟机制进行创建,但执行的地址会不同。

G

This means the offset into the global offset table at which the address of the relocation entry's symbol will reside during execution. See "Global Offset Table'' below for more information.
G表示在执行中,重定位入口的符号驻留在全局偏移表中的偏移地址。看下面的“全局偏移表”获取更多信息。

GOT

This means the address of the global offset table. See "Global Offset Table'' below for more information.

GOT表示全局偏移表的地址。看下面的“全局偏移表”获取更多信息。

L

This means the place (section offset or address) of the procedure linkage table entry for a symbol. A procedure linkage table entry redirects a function call to the proper destination. The link editor builds the initial procedure linkage table, and the dynamic linker modifies the entries during execution. See "Procedure Linkage Table'' below for more information.

L表示一个符号在过程链接表入口位置。一个过程链接表入口重定向函数调用到适当的目的地址。链接编辑器建立初始的过程链接表,动态链接器在执行中修改这些入口。看下面的“过程链接表”获取更多信息。

P

This means the place (section offset or address) of the storage unit being relocated (computed using r_offset).

P表示存储位置单元的位置(分节偏移或地址)将被重定位(使用r_offset计算)。

S

This means the value of the symbol whose index resides in the relocation entry.

S表示索引位于重定位条目的符号值。

 

A relocation entry's r_offsetvalue designates the offset or virtual address of the first byte of theaffected storage unit. The relocation type specifies which bits to change andhow to calculate their values. The Intel architecture uses only Elf32_Rel relocationentries, the field to be relocated holds the addend. In all cases, the addendand the computed result use the same byte order.

   重定位条目的r_offset值指定了被影响到的存储单元的偏移或虚拟地址。重定位类型指明了哪些位需要被改变及如何计算它们的值。Intel架构只使用Elf32_Rel重定位条目,被重定位的字段包含加数。在所有情况下,加数和计算结果使用相同的字节序。

FigureA-3. Relocation Types

图A-3.重定位类型

名字(Name)

值(Value)

字段(Field)

计算(Calculation)

R_386_GOT32

R_386_PLT32

R_386_COPY

R_386_GLOB_DAT

R_386_JMP_SLOT

R_386_RELATIVE

R_386_GOTOFF

R_386_GOTPC

3

 4

 5

 6

 7

 8

 9

 10

word32

word32

none

word32

word32

word32

word32

word32

G + A

L + A - P

none

S

S

B + A

S + A - GOT

GOT + A - P

 

R_386_GLOB_DAT

This relocation type is used to set a global offset table entry to the address of the specified symbol. 

The special relocation type allows one to determine the correspondence between symbols and global offset table entries.

此重定位类型用于设置一个到指定符号的全局偏移表入口。这个特殊的重定位类型允许在符号和全局偏移表入口之间确定一个对应的关系。

R_386_JMP_SLOT

The link editor creates this relocation type for dynamic linking. Its offset member gives the location of a procedure linkage table entry. 

The dynamic linker modifies the procedure linkage table entry to transfer control to the designated symbol's address [see "Procedure Linkage Table'' below].

链接编辑器为动态链接创建这个重定位类型。它的偏移成员给出了到一个过程链接表入口的定位。

动态链接器编辑过程链接表的入口来转换控制到指定的符号地址[看下面的“过程链接表”]。

R_386_RELATIVE

The link editor creates this relocation type for dynamic linking. Its offset member gives a location within a shared object 

that contains a value representing a relative address. The dynamic linker computes the corresponding virtual address 

by adding the virtual address at which the shared object was loaded to the relative address.

 Relocation entries for this type must specify 0 for the symbol table index.

链接编辑器为动态链接创建这个重定位类型。它的偏移成员给出了一个在共享对象中的定位的相对地址。

动态链接器通过这个相对地址加上共享对象加载的虚拟地址来计算对应的虚拟地址。这个类型的重定位入口必须为符号表索引指定0。

R_386_GOTOFF

This relocation type computes the difference between a symbol's value and the address of the global offset table.

 It additionally instructs the link editor to build the global offset table.

这个重定位类型计算一个符号的值和全局偏移表之间的区别。此外,它指导链接编辑器建立全局偏移表。

R_386_GOTPC

This relocation type resembles R_386_PC32, except it uses the address of the global offset table in its calculation. 

The symbol referenced in this relocation normally is _GLOBAL_OFFSET_TABLE_, 

which additionally instructs the link editor to build the global offset table.

除了在计算中使用全局偏移表地址外,这个重定位类型和R_386_PC32类似。

在此重定位中的引用通常是_GLOBAL_OFFSET_TABLE_,额外指导链接编辑器建立全局偏移表。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值