Sections

Special Sections

Various sections hold program and control information. The sections listed in Table 2 are used by the system and have the types and attributes shown.

Table 2. Special Sections

Name

Type

Attributes

.got

SHT_PROGBITS

SHF_ALLOC + SHF_WRITE

.plt

SHT_PROGBITS

SHF_ALLOC + SHF_WRITE + SHF_EXECINSTR

Special sections are described in Table 3.

Table 3. Special Sections Description

Name

Description

.got

This section holds the Global Offset Table, or GOT. See the Section called Coding examples in the Chapter called Low-level system information and the Section called Global Offset Table in the Chapter called Program loading and dynamic linking for more information.

.plt

This section holds the Procedure Linkage Table, or PLT. See the Section called Procedure Linkage Table in the Chapter called Program loading and dynamic linking for more information.

Symbol Table

Symbol Values

If an executable file contains a reference to a function defined in one of its associated shared objects, the symbol table section for the file will contain an entry for that symbol. The st_shndx field of that symbol table entry contains SHN_UNDEF. This informs the dynamic linker that the symbol definition for that function is not contained in the executable file itself. If that symbol has been allocated a Procedure Linkage Table entry in the executable file, and the st_value field for that symbol table entry is nonzero, the value is the virtual address of the first instruction of that PLT entry. Otherwise the st_value field contains zero. This PLT entry address is used by the dynamic linker in resolving references to the address of the function. See the Section called Function Addresses in the Chapter called Program loading and dynamic linking for details.

Relocation

Relocation Types

Relocation entries describe how to alter the instruction and data relocation fields shown in Figure 1 (bit numbers appear in the lower box corners; byte numbers appear in the upper left box corners).

Figure 1. Relocation Fields

quad64

This specifies a 64-bit field occupying 8 bytes, the alignment of which is 4 bytes unless otherwise specified.

word32

This specifies a 32-bit field occupying 4 bytes, the alignment of which is 4 bytes unless otherwise specified.

pc32

This specifies a 32-bit field occupying 4 bytes with 2-byte alignment. The signed value in this field is shifted to the left by 1 before it is used as a program counter relative displacement (for example, the immediate field of a "Load Address Relative Long" instruction).

half16

This specifies a 16-bit field occupying 2 bytes with 2-byte alignment (for example, the immediate field of an "Add Halfword Immediate" instruction).

pc16

This specifies a 16-bit field occupying 2 bytes with 2-byte alignment. The signed value in this field is shifted to the left by 1 before it is used as a program counter relative displacement (for example, the immediate field of an "Branch Relative" instruction).

low12

This specifies a 12-bit field contained within a halfword with a 2-byte alignment. The 12 bit unsigned value is the displacement of a memory reference.

byte8

This specifies a 8-bit field with a 1-byte alignment.

Calculations in Table 4 assume the actions are transforming a relocatable file into either an executable or a shared object file. Conceptually, the linkage editor merges one or more relocatable files to form the output. It first determines how to combine and locate the input files, next it updates the symbol values, and then it performs relocations.

Relocations applied to executable or shared object files are similar and accomplish the same result. The following notations are used in Table 4:

A

Represents the addend used to compute the value of the relocatable field.

B

Represents 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.

G

Represents the section offset or address of the Global Offset Table. See the Section called Coding examples in the Chapter called Low-level system information and the Section called Global Offset Table in the Chapter called Program loading and dynamic linking for more information.

L

Represents the section offset or address of the Procedure Linkage Table entry for a symbol. A PLT entry redirects a function call to the proper destination. The linkage editor builds the initial PLT. See the Section called Procedure Linkage Table in the Chapter called Program loading and dynamic linking for more information.

O

Represents the offset into the GOT at which the address of the relocation entry's symbol will reside during execution. See the Section called Coding examples in the Chapter called Low-level system information and the Section called Global Offset Table in the Chapter called Program loading and dynamic linking for more information.

P

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

R

Represents the offset of the symbol within the section in which the symbol is defined (its section-relative address).

S

Represents the value of the symbol whose index resides in the relocation entry.

Relocation entries apply to bytes, halfwords or words. In either case, the r_offset value designates the offset or virtual address of the first byte of the affected storage unit. The relocation type specifies which bits to change and how to calculate their values. The zSeries family uses only the Elf64_Rela relocation entries with explicit addends. For the relocation entries, the r_addend field serves as the relocation addend. In all cases, the offset, addend, and the computed result use the byte order specified in the ELF header.

The following general rules apply to the interpretation of the relocation types in Table 4:

  • "+" and "-" denote 64-bit modulus addition and subtraction, respectively. ">>" denotes arithmetic right-shifting (shifting with sign copying) of the value of the left operand by the number of bits given by the right operand.

  • For relocation type half16, the upper 48 bits of the value computed must be all ones or all zeroes. For relocation type pc16, the upper 47 bits of the value computed must be all ones or all zeroes and the lowest bit must be zero. For relocation type pc32, the upper 31 bits of the value computed must be all ones or all zeroes and the lowest bit must be zero. For relocation type low12, the upper 52 bits of the value computed must all be zero and for relocation type byte8, the upper 56 bits of the value computed must all be zero.

  • Reference in a calculation to the value G or O implicitly creates a GOT entry for the indicated symbol and a reference to L implicitly creates a PLT entry.

Table 4. Relocation Types

Name

Value

Field

Calculation

R_390_NONE

0

none

none

R_390_8

1

byte8

S + A

R_390_12

2

low12

S + A

R_390_16

3

half16

S + A

R_390_32

4

word32

S + A

R_390_PC32

5

word32

S + A - P

R_390_GOT12

6

low12

O + A

R_390_GOT32

7

word32

O + A

R_390_PLT32

8

word32

L + A

R_390_COPY

9

none

(see below)

R_390_GLOB_DAT

10

quad64

S + A (see below)

R_390_JMP_SLOT

11

none

(see below)

R_390_RELATIVE

12

quad64

B + A (see below)

R_390_GOTOFF

13

quad64

S + A - G

R_390_GOTPC

14

quad64

G + A - P

R_390_GOT16

15

half16

O + A

R_390_PC16

16

half16

S + A - P

R_390_PC16DBL

17

pc16

(S + A - P) >> 1

R_390_PLT16DBL

18

pc16

(L + A - P) >> 1

R_390_PC32DBL

19

pc32

(S + A - P) >> 1

R_390_PLT32DBL

20

pc32

(L + A - P) >> 1

R_390_GOTPCDBL

21

pc32

(G + A - P) >> 1

R_390_64

22

quad64

S + A

R_390_PC64

23

quad64

S + A - P

R_390_GOT64

24

quad64

O + A

R_390_PLT64

25

quad64

L + A

R_390_GOTENT

26

pc32

(G + O + A - P) >> 1

Table 5. Relocation type descriptions

Name

Description

R_390_COPY

The linkage editor creates this relocation type for dynamic linking. Its offset member refers to a location in a writable segment. The symbol table index specifies a symbol that should exist both in the current object file and in a shared object. During execution, the dynamic linker copies data associated with the shared object's symbol to the location specified by the offset.

R_390_GLOB_DAT

This relocation type resembles R_390_64, except that it sets a Global Offset Table entry to the address of the specified symbol. This special relocation type allows one to determine the correspondence between symbols and GOT entries.

R_390_JMP_SLOT

The linkage 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 PLT entry to transfer control to the designated symbol's address (see the Section called Procedure Linkage Table in the Chapter called Program loading and dynamic linking).

R_390_RELATIVE

The linkage 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.