
TNS/E Native Object Files
eld Manual—527255-009
A-16
Relocation Tables
Relocation Tables
It is possible that the contents of one place in the code or data of an object file need to
be filled in with the address of another place in the code or data, or in some other way
based on such an address. If the compiler or assembler knows what needs to go
there, without later modification by the linker or runtime loader, then that's the end of
the story. But, if the linker or runtime loader will need to be involved, the compiler or
assembler must indicate that location accordingly, by creating relocation tables in
linkfiles to provide such information. Similarly, the linker must put relocation tables into
loadfiles if there is still work for the runtime loader to do.
The place that needs to be filled in is called the relocation site. It would either be an
operand within an executable instruction, which come in various sizes, or a data item,
which would be a 32-bit or 64-bit integer. The place whose address needs to be
calculated is called the target of the relocation. The relocation site is also said to be a
reference to the target symbol.
The target of a relocation site is described by giving an offset relative to a symbol that
is listed either in the .symtab section (in the case of a linkfile) or the .dynsym or
.dynsym.gblzd section (in the case of a loadfile). If the symbol is of type STB_LOCAL
then it must be defined with an address in this object file, and that is the address that is
used for the symbol. If the symbol is of type STB_GLOBAL then the definition of the
symbol that is used to resolve the reference might exist in this object file or in another
object file.
The process of figuring out the target address is called resolving the reference. After a
reference has been resolved, the proper way to fill in the contents of the relocation site
depends on the site's relocation type.
The relocation types that can occur in linkfiles and loadfiles are different, and the
names of the relocation table sections are different. In linkfiles, for each code or data
section named .x that contains relocation sites there is a relocation table section
named .rela.x that describes the relocation sites in that section. This also includes
relocation tables needed to describe relocation sites in the .procinfo section, the
unwind function sections, and the DWARF symbol table sections. In loadfiles there are
relocation table sections named .rela.dyn and .rela.gblzd that describe all the
relocation sites in the data segment of the loadfile. Loadfiles never have relocation
sites in the text segment. The entries in .rela.dyn are for relocation sites whose target
symbols are in .dynsym, while the entries in .rela.gblzd are for relocation sites whose
target symbols are the globalized symbols listed in .dynsym.gblzd.
The format of the relocation information is the same in all cases. The ELF section type
is SHT_RELA, and the format of a relocation table entry is the following:
typedef struct ELF64_Rela {
ELF64_Addr r_offset;
ELF64_Xword r_info;
ELF64_Xword r_addend;
}Elf64_Rela
The size of this structure is 24 bytes.
Summary of Contents for eld
Page 4: ......
Page 8: ...Contents eld Manual 527255 009 iv ...
Page 12: ...What s New in This Manual eld Manual 527255 009 viii Changes to the 527255 005 Manual ...
Page 34: ...Introduction to eld eld Manual 527255 009 1 14 Example of Use ...
Page 54: ...eld Input and Output eld Manual 527255 009 2 20 Using Archives ...
Page 98: ...Other eld Processing eld Manual 527255 009 4 20 Merging Source RTDUs ...
Page 242: ...Output Listings and Error Handling eld Manual 527255 009 6 132 Glossary of Errors ...